X and Y components of the Named Selection object.

Hi
I'm adding the remote force and assigning a named selection edge as a scoping method.
Then I need to set X an Y coordinates to be equal to Centroids X and Y of the same edge. At the moment they are located at the origin of the global coordinate system.

  1. MESH = ExtAPI.DataModel.Project.Model.Mesh
  2. ANALYSIS = ExtAPI.DataModel.Project.Model.Analyses[0]
  3. select_NS_load = DataModel.GetObjectsByName('load')
  4. add_force = ANALYSIS.AddRemoteForce() # force
  5. add_force.Name = 'force'
  6. add_force.Location = select_NS_load[0]

How to to return the coordinates of the named selection point/edge like below?

add_force.XCoordinate = CentroidX of the select_NS_load[0].Geometry
same for YCoordinate

Best Answer

  • Member, Employee Posts: 385
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    Answer ✓

    NS.Entities for all the edges in the named selection
    For each edge: E.Centroid property
    This returns the XYZ centroid of the edge in the GeoData unit.
    If you have multiple edges in the selection use the E.Length to get also a weighted average of the centroids.

Answers

  • Member Posts: 32
    10 Comments First Anniversary Name Dropper
    **
    edited December 2023

    @Mike.Thompson Thanks
    This solution works for me:

    1. ANALYSIS = ExtAPI.DataModel.Project.Model.Analyses[0]
    2. select_NS_load = DataModel.GetObjectsByName('load')
    3. add_force = ANALYSIS.AddRemoteForce() # force
    4. x_coord = select_NS_load[0].Entities[0].Centroid[0]
    5. y_coord = select_NS_load[0].Entities[0].Centroid[1]
    6. add_force.Location = select_NS_load[0]
    7. add_force.XCoordinate = Quantity(x_coord, 'm')
    8. add_force.YCoordinate = Quantity(y_coord, 'm')

Welcome!

It looks like you're new here. Sign in or register to get started.