TAGGED: Ansys Discovery, ansys-spaceclaim, python, python-scripting, spaceclaim
-
-
November 29, 2023 at 1:33 pm
Erkki Holopainen
SubscriberHi,Â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]).EvaluationsI get this result:But how can I extract Circle Origin locations and direction from my Circle_i ? -
November 30, 2023 at 12:25 pm
Atharv Joshi
Forum ModeratorHi Erkki,Â
Let me check this and get back to you.
Thanks and Regards
Atharv -
December 1, 2023 at 12:08 pm
Atharv Joshi
Forum ModeratorHi 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().Bodiesfor 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.
Ansys Innovation Space
Trending discussions
Top Contributors
-
3150
-
1013
-
956
-
858
-
797
Top Rated Tags
© 2025 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.