What's new

Access the existing part parameters in the equation editor.

Knickstab

Member
Alibre Script is very good when creating something from scratch.

But I need drawings of components that are constantly changing slightly.

E.g.: For a staircase, the measurement changes every time
the inclination of the individual runs, step height, tread width...

Updates to the drawing are usually only necessary if you do so
changes appropriate parameters in the assembly and parts.

Unfortunately, if you create everything from scratch with Alibre Script,
you have to use the drawings completely rebuild.

Is there a way to do this directly in Alibre Script or in the API
to access the parameters of a part or assembly?

The only way I've found is via global variables.
But that is very complicated.

Knickstab
 

stepalibre

Alibre Super User
To get the parameter objects in CurrentPart() or CurrentAssembly().

Python:
param = CurrentPart()
param.Parameters

The Excel add-in?

 

Knickstab

Member
hello idslk
your code works in assemblies. But more than 90% of the changes have to be made in the parts. Change the length by a few mm, adjust the angle, realign the holes for screws...
In the Python code I only get the identifier of the variable back, I don't see a value or I can't change it.
The only thing that works is inserting a new parameter.name and parameter.value...
Deleting a parameter isn't possible either...


Units.Current = UnitTypes.Millimeters param = CurrentPart() print ('Aktuelles Teil : '), param.Parameters parametername = 'Breite' M = -1 for i in range(len(param.Parameters)): # Für alle Parameter in param # For all Parameter in param if param.Parameters[i].Name == parametername: M = i print 'actual internal parameter number: ', M # if not( M == -1 ): # Falls M nicht -1 ist, gibt es den Parameter 'Breite' # if M is not -1 , then exist an Parameter 'Breite' Name = param.Parameters[M] print ('Der Bezeichner des Parameters heißt : '), Name param.Parameters[M] = 20 # no errormessage (!!) and no value changing print ('Der Bezeichner des Parameters heißt : '), param.Parameters[M]
 

Attachments

  • para1.py
    758 bytes · Views: 1
  • Part_Test.jpg
    Part_Test.jpg
    246.7 KB · Views: 10

idslk

Alibre Super User
Hello Knickstab,

take a "second look" to the code...
In your code it should be "param.Parameters[M].Value = 20"

Regards
Stefan
 

Knickstab

Member
Thanks idslk, that was too easy again.
Thank you stepalibre.
I tried param.Parameters[M].value several times...

Attached is the working version.

You don't know how much work this little tool saves...

regards Knickstab
 

Attachments

  • test (ID 93912).AD_PRT
    251 KB · Views: 2
  • test (ID 93913).py
    1.4 KB · Views: 6

albie0803

Alibre Super User
If you only have particular parameters that you want to change then you could filter for them, for example, by starting the name with pm_ then have an input box pop up to enter the new value.
If your parameter names were consistent across your parts, you could probably write a script to input all the variables, then have it open each part and run through the parameters and if the name matches a list, edit it, then update the assembly. (It sounds reasonable but don't hold me to it)
 
Top