What's new

Global Parameter for Part Suppression?

I have an assembly which I am controlling with a global parameter file. The assembly is somewhat complicated in that there are about a dozen or more different add-ons that can be added, like different adaptor plates, handles, and extra parts, etc. Is there a way to use the global parameter file to selectively hide or show these extra parts? Or selectively suppress or activate them? This would be very helpful, because a different configuration for each add on would be an enormous amount of configurations.
 
Last edited:

NateLiqGrav

Alibre Super User
An Alibre Script can do it fairly easily.

Code:
ScriptName = 'Optional Addons'

print("\n"*20) # lazy mans clear console

Win = Windows()

# define options to show in dialog window
Options = []

Options.append(['Adaptor Plate A', WindowsInputTypes.Boolean, 0])
Index_Adaptor_Plate_A = len(Options)-1

Options.append(['Adaptor Plate B', WindowsInputTypes.Boolean, 0])
Index_Adaptor_Plate_B = len(Options)-1

Options.append(['Adaptor Plate C', WindowsInputTypes.Boolean, 0])
Index_Adaptor_Plate_C = len(Options)-1

Options.append(['Handle A', WindowsInputTypes.Boolean, 0])
Index_Handle_A = len(Options)-1

Options.append(['Handle B', WindowsInputTypes.Boolean, 0])
Index_Handle_B = len(Options)-1

Options.append(['Extra A', WindowsInputTypes.Boolean, 0])
Index_Extra_A = len(Options)-1

Options.append(['Extra B', WindowsInputTypes.Boolean, 0])
Index_Extra_B = len(Options)-1

Values = Win.OptionsDialog(ScriptName, Options, 200)

if Values == None:
    print("Canceled... Exiting.")
    sys.exit()
# other error checking and program here

Assem = CurrentAssembly()
try:
    if Values[Index_Adaptor_Plate_A]:
        Assem.UnsuppressPart('Adaptor Plate A<1>')
    else:
        Assem.SuppressPart('Adaptor Plate A<1>')
except:
    print("No part named 'Adaptor Plate A' Found.")

try:
    if Values[Index_Adaptor_Plate_B]:
        Assem.UnsuppressPart('Adaptor Plate B<1>')
    else:
        Assem.SuppressPart('Adaptor Plate B<1>')
except:
    print("No part named 'Adaptor Plate B' Found.")

try:
    if Values[Index_Adaptor_Plate_C]:
        Assem.UnsuppressPart('Adaptor Plate C<1>')
    else:
        Assem.SuppressPart('Adaptor Plate C<1>')
except:
    print("No part named 'Adaptor Plate C' Found.")

try:
    if Values[Index_Handle_A]:
        Assem.UnsuppressPart('Handle A<1>')
    else:
        Assem.SuppressPart('Handle A<1>')
except:
    print("No part named 'Handle A' Found.")

try:
    if Values[Index_Handle_B]:
        Assem.UnsuppressPart('Handle B<1>')
    else:
        Assem.SuppressPart('Handle B<1>')
except:
    print("No part named 'Handle B' Found.")

try:
    if Values[Index_Extra_A]:
        Assem.UnsuppressPart('Extra A<1>')
    else:
        Assem.SuppressPart('Extra A<1>')
except:
    print("No part named 'Extra A' Found.")

try:
    if Values[Index_Extra_B]:
        Assem.UnsuppressPart('Extra B<1>')
    else:
        Assem.SuppressPart('Extra B<1>')
except:
    print("No part named 'Extra B' Found.")

print("Done")
 
Last edited:

NateLiqGrav

Alibre Super User
Did you change the names of all the parts to exactly match the parts?

You must also include the instance identifier in part names too. For example the first instance of a part:
Code:
Assem.UnsuppressPart('Adaptor Plate B<1>')
And the second instance:
Code:
Assem.UnsuppressPart('Adaptor Plate B<2>')
I have updated the code above to reflect that.
 
Did you change the names of all the parts to exactly match the parts?

You must also include the instance identifier in part names too. For example the first instance of a part:
Code:
Assem.UnsuppressPart('Adaptor Plate B<1>')
And the second instance:
Code:
Assem.UnsuppressPart('Adaptor Plate B<2>')
I have updated the code above to reflect that.

Yes I changed my part to match the names in the script. After adding the <1> it gives an error,
File "", line 11
Index_Adaptor_Plate_A<1> = len(Options)-1
^
SyntaxError: unexpected token '='

Does everything have to be in ' '?
 
Nevermind I got it working. The key is to remove the <1> when it references the index. Man this might be a sharp learning curve haha.

Thank you again for the help!
 
Top