Trying to get a standalone Solidworks C# app to roll over each part in a loaded assembly and return that parts xform in assembly space to describe the parts offset in the assembly. The end goal is to write out a dictionary of each part name with each occurring instance's transform offset via a 16 long double[] for a rebuild operation outside of Solidworks.
So far I've learned how to get the C# standalone program to loop over each part in the assembly. Below is a code snippet showing the loop that gains access to each part. Would anyone have any pointers on how to gain access to the instance transform data? I've tried "comp.GetXform()", which returns a System.Double[], but I'm failing to figure out how to actually extract that object's data. Thank you in advance! This is the one thing I need to do in C# before I can escape and go back to Python.
AssemblyDoc swAssyDoc = (AssemblyDoc)model;
foreach (IComponent2 comp in swAssyDoc.GetComponents(false) as object[])
{
if (comp.GetModelDoc2() is IPartDoc)
{
//Console.WriteLine(comp.GetXform());
}
}
SolidworksApi/macros