Code to create mesh sizing based on NameSelection

Options

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