SelectByID2 : retrieve ID from selected component
Posted: Thu May 06, 2021 1:39 pm
I am using selectByID2 to add mates in the top level assembly. I select two entites in the graphics area or model tree and get their component using
Then I use selectByID2 to grab each primary plane from the two components and add a mate between them.
Currently I am hard coding the format of the ID because this macro is used on assemblies where the file structure is known. Now I want to generalize my program for any assembly structure.
How can I build or get the ID of swComponentA with respect to the top assembly for use in SelectByID2? The macro recorder gives something like this
Eventually I want to be able to specify a feature in swComponentA to use during mating in a loop.
Example: myFeature would be all three primary planes.
Code: Select all
swEntity := SelMgr.GetSelectedObject6(1, 0)
swComponentA := swEntity.GetComponent
'or
swComponentA := SelMgr.GetSelectedObject6(1, 0)
swEntity := SelMgr.GetSelectedObject6(2, 0)
swComponentB := swEntity.GetComponent
'or
swComponentB := SelMgr.GetSelectedObject6(2, 0)
Currently I am hard coding the format of the ID because this macro is used on assemblies where the file structure is known. Now I want to generalize my program for any assembly structure.
How can I build or get the ID of swComponentA with respect to the top assembly for use in SelectByID2? The macro recorder gives something like this
Code: Select all
boolstatus = Part.Extension.SelectByID2("Right Plane@HMC-ADPT1200-NB-1-1@HMC-ADPT1200-1/HMC-PLCD-539-3@HMC-ADPT1200-NB-1", "PLANE", -9.84228209404137E-05, 1.09972117172674E-04, -0.154934245329059, True, 0, Nothing, 0)
Example: myFeature would be all three primary planes.
Code: Select all
id = myFeature & "@HMC-ADPT1200-NB-1-1@HMC-ADPT1200-1/HMC-PLCD-539-3@HMC-ADPT1200-NB-1"