What's new

Can't select axis/plane in an OptionsDialog in assembly view

Bodhizafa

Member
I'm trying to write a script that will generate multiple parts in an assembly, and I can't get the geometry selection options dialogs to work. Either the box stays empty no matter what I click, or I can select an axis, but the 'OK' button doesn't work. The following code works fine in part view, but not assembly view. It also doesn't work if I use Plane, but does work if I use most of the other geometry selection options.

Python:
Win = Windows()
Values = Win.OptionsDialog("Test", [
  ['Axis 1', WindowsInputTypes.Axis, None]
])
print repr(Values)
print "Done"

Anyone know what's going on?
 

NateLiquidGravity

Alibre Super User
OK, Stefan is right and I had forgot. You can't select ANY reference geometry from ANY assemblies using the default Win functions. That is a current limitation of Alibre Script.
 

Bodhizafa

Member
No...
Your code only returns axes of parts.

View attachment 35861

Regards
Stefan
What API should I use to make it work in assembly view then? In this case, the axes I want to select aren't actually part of any constituent part, they're in the assembly itself.

I'm trying to make a script that creates meshing gears with a given ratio between two axes, and I want them to be separate parts. It would be disappointing if it turns out to be impossible because axis selection in assembly view doesn't work...

Additionally, that error dialog only comes up for me the first time I try. If I try running the same script again, the error does not appear, and the 'ok' button in the axis selection does nothing. I have to completely close Alibre to get the actual error again.
 

NateLiquidGravity

Alibre Super User
With the Alibre Script Windows functions the user can select the axis of a part in the assembly, but not the axis of the assembly (or a subassembly) . Simply right click the parts and select "Show Reference Geometry" to be able to select the part's axis.

If you need to find if the user selected the axis of an assembly then you could do something like this in Alibre Script.
Python:
assem = CurrentAssembly()
sel = assem.Selections
for x in sel:
    if 'Axis' in str(type(x)):
        print(x)
However you may end up with other problems down the line with AlibreScript and assemblies (if you are doing what I think you might): https://www.alibre.com/forum/index.php?threads/constraints-to-assembly-planes.21010/

The API works roughly the same way but way more complicated.
Python:
TopSess = Global.Root.TopmostSession
sel = TopSess.SelectedObjects

for x in range(0, sel.Count):
    if 'AlibreDesignAxis' in str(type(sel.Item(x).Target)):
        print(sel.Item(x).Target.Name)

NOTE: Either way the user can select many things at the same time and you will need to narrow them down to just what you need.
 
Top