Too lazy to run your code... sorry, I'm all VBA, can't comment on your C#
Why is Bodies declared with upper bound 1 (meaning size 2)? I don't see where Bodies(1) is set to anything, so you're passing a 2 element array with nothing in the second element, right? Probably not gonna work. Also, I assume you've looked at the example in the API help? Of course, I haven't tested that one either, but they pass the variant array to swView.Bodies. You're passing the Object array. SW seems pretty picky about the types of arrays it actually likes.
Hi Josh, about vba it works nice as is in my example, i played a bit with the types passed to swView.Bodies to see if that could be a type problem, but it runs well with Object Array, so i assume it should run as well in c#...
in c# "bodies" is a array with all bodies in "swView" referenced part it has 22 bodies, so i take second body from it and put in b (object array to be passed to swView.Bobies) b = bodies;
about Bodies(1) was again playing with code to see if i find some poit where vba will also fail, but it runs even if Bodies(20)...
so the point is:
vb run perfect like it is in that snippet, somehow im making some mistake in converting it to c# or some other detail that i cant figure it out...
swView.Bodies is it self an object array (can be checked in vs debugger, it contains all 22 bodies from part) but somehow its not accessible to be replaced by the object array with the only body i want visible... im not a vba guy but i think i understood the main idea from the API help...
thanks for your time, and hope you can help me further...
In the .NET Framework, an object array can be used to store System.Object types like integer, double, etc. .NET marshals these data types automatically. However, non-standard object types like SOLIDWORKS interfaces must be explicitly marshaled to an IDispatch object array.
Some SOLIDWORKS methods and properties have input arrays of non-standard objects. Before passing these arrays, you must marshal them to IDispatch object arrays using the System.Runtime.InteropServices.DispatchWrapper class.
Several SOLIDWORKS methods and properties have input object arrays that must be marshaled to an IDispatch object array. The following Help topics contain links to VB.NET and C# examples that demonstrate how to marshal an array of non-standard input objects to an IDispatch object array.
Hello Amen, that solve the mystery , it works perfect.
Thank you very much.