C# : Get edge, bodies etc using SolidWorks api

19 Sep

Body2 SwBody;
if (SwBody == null) return null;
int n = SwBody.GetEdgeCount();

Array AllEdges = (Array) SwBody.GetEdges(); //This is important
Edge [] AllEdges = (Edge []) SwBody.GetEdges(); //Wrong!

for (int i=0;i<n;i++)
Edge e = AllEdges.GetValue(i) as Edge;
double[] ReturnValue = e.Evaluate(0.5) as double[]; //Ok
if (ReturnValue != null && ReturnValue.Length >= 3)
double X = ReturnValue[0];
double Y = ReturnValue[1];
double Z = ReturnValue[2];
string LabelText = string.Format(“E{0}”, i);

Leave a comment

Posted by on September 19, 2008 in CAD, Dotnet/C#


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: