Hi,
I am iterating through components in a section view of an assembly and trying to access the component Transforms for each component. I get the Transform2 value to be null for all the components. Is there a cast which I am missing? Please advise. Code is given below (C#).
Thanks,
Hersh
static void GetComponentsInView(SolidWorks.Interop.sldworks.View swView, ISldWorks app )
{
ModelDoc2 swModel = (ModelDoc2)app.ActiveDoc;
object[] vDrawChildCompArr = swView.GetVisibleComponents();
Component2 swComp = null;
StringBuilder componentNames = new StringBuilder();
foreach (object component in vDrawChildCompArr)
{
swComp = component as Component2;
ModelDoc2 swCompModel = (ModelDoc2)swComp.GetModelDoc2();
object[] edges = swView.GetVisibleEntities(swComp, (int)swViewEntityType_e.swViewEntityType_Edge);
string componentName = Path.GetFileNameWithoutExtension(swCompModel.GetPathName());
MathTransform transform = swComp.Transform2;
if(transform == null)
componentNames.AppendLine(componentName);
}
MessageBox.Show(componentNames.ToString());
}
SolidworksApi macros