3D Design

3D Design

Topics related to Ansys Discovery and Ansys SpaceClaim.

Discovery Getting the Circle centers form Named selection

    • Erkki Holopainen
      Subscriber
      Hi,
       
      I have multiple hole edges in a Named selection group. How can I get edge center locations to variables in a script?
       
      With this command:
      Circle_i = Selection.Create(NamedSelection.GetGroup("BoltHeads").Members[0]).Evaluations
      I get this result:
      But how can I extract Circle Origin locations and direction from my Circle_i ?
    • Atharv Joshi
      Ansys Employee

      Hi Erkki, 

      Let me check this and get back to you.

      Thanks and Regards
      Atharv

    • Atharv Joshi
      Ansys Employee

      Hi Erkki, 

      I was trying this and currently was able to write a script without using named selection. It uses perimeter range to filter out the circular edges and then measure the co-ordinates for the center of the holes. 

      list=[]
      all_bodies=GetRootPart().Bodies
      for body in all_bodies:
          for i in body.Edges:
              ##I am using 0.0157-0.0158 range to filter out edges based on perimeter for the 5mm hole I have in my CAD
              ##Change it according to the hole diameter you have. 
              if i.Shape.Length >0.0157 and i.Shape.Length <0.0158: ##Units are in Meter for script so its 0.0157
                  list.append(i)
                  
          centre_cordinates=[]
          for i in list:
              centre=[]
              # Measure x
              selection = Selection.Create(GetRootPart().CoordinateSystems[0])
              secondarySelection = Selection.Create(i.GetChildren[ICurvePoint]()[0])
              gap = MeasureHelper.DistanceBetweenObjects(selection, secondarySelection)
              deltaX = gap.DeltaX
              # EndBlock
       
              # Measure y
              selection = Selection.Create(GetRootPart().CoordinateSystems[0])
              secondarySelection = Selection.Create(i.GetChildren[ICurvePoint]()[0])
              gap = MeasureHelper.DistanceBetweenObjects(selection, secondarySelection)
              deltaY = gap.DeltaY
              # EndBlock
       
              # Measure z
              selection = Selection.Create(GetRootPart().CoordinateSystems[0])
              secondarySelection = Selection.Create(i.GetChildren[ICurvePoint]()[0])
              gap = MeasureHelper.DistanceBetweenObjects(selection, secondarySelection)
              deltaZ = gap.DeltaZ
              # EndBlock
              centre.append(deltaX)
              centre.append(deltaY)
              centre.append(deltaZ)
              centre_cordinates.append(centre)
       
      print(centre_cordinates)

       

      I will further check this with named selection as input. You can also try to explore further. 

      Thanks and Regards
      Atharv

       

Viewing 2 reply threads
  • The topic ‘Discovery Getting the Circle centers form Named selection’ is closed to new replies.