Code to create mesh sizing based on NameSelection
I have this code that creates three mesh sizing. After that I need to set the scoping method to NameSelection and choose the particular NS for each sizing. When I try to change to the scoping method to NS it gives me an error:
This property is parameterized and is read-only.
import csv GEOMETRY = ExtAPI.DataModel.Project.Model.Geometry MESH = ExtAPI.DataModel.Project.Model.Mesh with open("path_to_data.csv", "r") as csvfile: csvreader = csv.DictReader(csvfile) bodies_names = [] mesh_size_ids = [] for row_name in csvreader: if row_name['analysis_type'] == '2D_LinearSolidRectangularBeam': bodies_names.append(row_name['id']) for index, name, body in zip(range(0, GEOMETRY.Children.Count), bodies_names, GEOMETRY.Children): body.Children[0].Name = name MESH.AddSizing() MESH.Children[index].Name = name mesh_size_ids.append(MESH.Children[index].ObjectId) for mesh in mesh_size_ids: change_to_NS = DataModel.GetObjectById(mesh) change_to_NS.ScopingMethod = GeometryDefineByType.Component # here is a problem
Answers
-
Hi @sombodyfromtheworld You don't need to change the scoping methid to NS. In the mesh sizing location, scope directly the named selection, it will work.
1 -
@Pernelle Marone-Hitz Thank you for a reply
0 -
@sombodyfromtheworld ,
you also should use the best practice of returning the created object like this:
MySizingObj = MESH.AddSizing()There is no need to track it with the 'child' logic you have: MESH.Children[index]
This is pervasive to any "Obj.AddSomething" type methods.
1 -
@Mike.Thompson yes this a good tip, thanks
0