Hello,
can you help me to get value of highlighted parameter to python variable? Thank you
For properties that are not directly exposed in the API, there is a general work around that often works. In the example below I get the property based on its caption string. You can then get either the InternalValue, or the StringValue and often convert to a usable variable based on simple logic.
Geometry=ExtAPI.DataModel.Project.Model.Geometry PropCaption = "Import Facet Quality" for Prop in Geometry.VisibleProperties: if Prop.Caption==PropCaption: break MyProp = Prop print MyProp.InternalValue print MyProp.StringValue
@Mike.Thompson thank you for your feedback. I tried this way but somehow it returnes wrong value. I was searching for while and figured out it returns value of standart deviation of mesh insted of my CAD Parameter? What do you suspect here?
Geometry=ExtAPI.DataModel.Project.Model.Geometry
PropCaption = "Part1:pleat_thickness"
name=[]
for Prop in Geometry.VisibleProperties:
if Prop.Caption==PropCaption:
break
MyProp = Prop
print MyProp.InternalValue
print MyProp.StringValue
print(Prop.name)
#######################################
It returns this no matter what string I put to PropCaption variable.
0.219009462339
0.21901
MeshMetricSTDV
@Mike.Thompson
is there another option? This does not seem to work properly. Thank you
There's a similar procedure described in Vishnu's post:How to get CAD Parameters in Mechanical from Geometry by ACT - Community Forum
It seems that the thread I linked above is private, so I am repeating the solution here. The goal is to access the CAD parameters. Depending on the CAD software you are using there may be different ways the parameters are found in Mechanical. Here's an example:
When parameters are shown in the Details of the Part object, the following snippet can be used:
geo = ExtAPI.DataModel.Project.Model.Geometry.Children for part in geo: print part.Name for body in part.Children: total_cadparms = body.InternalObject.CADParameters.Count() for i in range(2,int(total_cadparms+1),1): print(body.InternalObject.CADParameters[i].Name()+'='+str(body.InternalObject.CADParameters[i].Value()))
When the parameters are shown under the Geometry object, the following variation can be used:
geo = ExtAPI.DataModel.Project.Model.Geometry total_cadparms = geo.InternalObject.CADParameters.Count() for i in range(1,int(total_cadparms+1)): print(geo.InternalObject.CADParameters[i].Name()+'='+str(geo.InternalObject.CADParameters[i].Value()))