[S8432] Script to obtain the setting value of conditions with unknown condition names and indexes

 

The following is an example of a script that obtains the setting values of conditions whose names and indexes are unknown.

app = designer.GetApplication()

# Get the number of conditions set in the study

CondNum = app.GetModel(0).GetStudy(0).NumConditions()

# Determining whether the “Motion: Rotation” condition exists

for i in range(CondNum):

   CondType = app.GetModel(0).GetStudy(0).GetCondition(i).GetType()

   if CondType == u"Motion: Rotation":

       # Get the revolution speed value

       rpm_data = app.GetModel(0).GetStudy(0).GetCondition(i).GetValue(u"AngularVelocity")

       # Display rotation speed value

       print(f"revolution speed: {rpm_data} rpm")

       break

else:

   print(f'"Motion: Rotation" conditions not found.')

How to use script file

Use the JMAG Script Library after reading and agreeing to the following terms of use.