What's new

Problem getting AssembledPart ( IInstance )

NateLiquidGravity

Alibre Super User
My problem seems to be finding the AssembledPart ( IInstance ) from a user selected face, edge, point...

Take the following example. If I don't add "<1>" to the end of MyPart.Name then it won't return an AssembledPart. But at that point i'm just guessing they want the first instance of that part.
Code:
Win = Windows()
Options = []
Options.append(['Select a Face', WindowsInputTypes.Face, None])
Values = Win.OptionsDialog('My Utility', Options, 400)
if Values == None:
  sys.exit()

MyFace = Values[0]
MyFaceName = MyFace.Name
print(MyFaceName)
MyPart = Values[0].GetPart()
print(MyPart)
MyAssem = Values[0].GetSelectionAssembly()
print(MyAssem)
MyAssemPart = MyAssem.GetPart(MyPart.Name+"<1>")
print(MyAssemPart)
MyAssem.MovePart(MyAssemPart,10,10,10,0)

Also I can use ThisAssy = CurrentAssembly() to get the current assembly but I can't figure out how to get the IInstance of the current assembly to constrain to it.

Any help would be very appreciated.
 

ajayre

Alibre Super User
The problem is that a face is on a part but an assembly has instances of the parts, not the parts themselves. This allows more than one instance of a part to be used. There is no way to get from a face to an instance of a part.

The next release allows selecting a part in an assembly using the dialog windows avoiding this problem.

A workaround for now would be to prompt the user to enter the name of the part instead of selecting a face. This could then be trivially replaced with selection of the part when the next release comes out.

Andy
 

NateLiquidGravity

Alibre Super User
Good to hear part selection will be in next release. I will prompt for name for now.

Related issue: I think that AssembledPart.GetActiveConfiguration() is returning the active configuration the part has internally and not the one active in the assembly level. Is there a method to get the one active in the assembly level currently?
 
Top