This is a way to get all the parameterized properties and their values from mechanical.
"""
Find all parameters in the mechancial model tree
Write them to a .csv file
"""
#---------------------------------------------------------------------------------------
#user inputs:
output_path =r'C:\Users\mthompso\MyData\DeleteThis\Mech Params\output.csv'
#---------------------------------------------------------------------------------------
import csv
parameters = []
current_values = []
for obj in Tree.AllObjects:
try:
props = obj.VisibleProperties
for prop in obj.VisibleProperties:
try:
param = obj.GetParameter(prop.Caption)
parameters.append(param)
current_values.append(prop.StringValue)
except Exception as e:
pass
except Exception as e:
pass
csv_data = []
csv_data.append(["Param Name", "Object Name", "Object Id", "Property Name", "Value"])
for param, current_val in zip(parameters, current_values):
obj = param.Object
#print param.ID+": "+ obj.Name+" ("+ str(obj.ObjectId) +"): "+param.PropertyName+": "+current_val
csv_data.append([param.ID, obj.Name, Obj.ObjectId, param.PropertyName, current_val])
if output_path!=None:
with open(output_path, 'wb') as csvfile:
writer = csv.writer(csvfile)
writer.writerows(csv_data)
#---------------------------------------------------------------------------------------