-
-
June 19, 2023 at 6:14 am
Jimmy
SubscriberI want to use "select.xxx", or other script to chose all surfaces and extrude them. How can I use "select script" properly? select.SelectAll() doesn't work.Â
Python Script, API Version = V23
import math
B_W=Parameters.Block_Width
B_L=Parameters.Block_Lengthr=Parameters.Block_radius
thickness=Parameters.Block_extrusioncircular_radius = MM(r)*1000 Â
circle_pitch = MM(r) * 3 * 1000 Âstart_x = -B_W/2+circle_pitch/2
start_z = -B_L/2+circle_pitch/2num_circles_x=int(math.ceil(B_W/circle_pitch))
num_circles_z=int(math.ceil(B_L/circle_pitch))surfaces=[]
for i in range(num_circles_z):Â
  for j in range(num_circles_x):Â
     circle_x=start_x + j*circle_pitch
     circle_z=start_z + i*circle_pitch
     circle = CircularSurface.Create(r, Direction.DirY,
                  Point.Create(circle_x, 0, circle_z))
     surfaces.append(circle)selection = Selection.Create(FaceSelection.SelectAll())
options = ExtrudeFaceOptions()
options.ExtrudeType = ExtrudeType.Add
result = ExtrudeFaces.Execute(selection, thickness, options)Â
-
June 20, 2023 at 8:03 am
mjmiddle
Ansys EmployeeThe format of the following command is incorrect:
selection = Selection.Create(FaceSelection.SelectAll())
The FaceSelection() function already creates a selection type, so just do:
selection = FaceSelection.SelectAll()
Also, for later use, you'll want to get the DesignBody or DesignFace from the CircularSurface() function:
circlebody = circle.CreatedBodies[0]
circleface = circle.CreatedBodies[0].Faces[0]
Â
-
June 20, 2023 at 8:26 am
Jimmy
SubscriberThank you very much indeed. But I still have an error message below,
'Selection must be a Face.' in result = ExtrudeFaces.Execute(selection, thickness, options)
seclection=FaceSelection.SelectAll() means surface selection as Face? Or is there any method to change surface to Face?
-
June 20, 2023 at 9:05 am
mjmiddle
Ansys EmployeeYou can see what you have by running the following:
for geom in selection.Items:
  print str(geom.GetType())It looks the SelectAll() method under the FaceSelection class just selects all objects. It does not just select only DesignFace type. You could loop through all bodies and faces and build a list of faces. But it seems your script is supposed to operate on the circle you just created, so why not just use what the CircularSurface.Create() just created?:
circle = CircularSurface.Create(r, Direction.DirY, Point.Create(circle_x, 0, circle_z)
circleface = circle.CreatedBodies[0].Faces[0]
surfaces.append(circleface)Once the loop is done:
selection = Selection.Create(surfaces) -
June 21, 2023 at 9:01 am
Jimmy
SubscriberThank you very much indeed.Â
-
- The topic ‘How can I select all surfaces(Faces) that I made script?’ is closed to new replies.
-
3477
-
1057
-
1051
-
940
-
912
© 2025 Copyright ANSYS, Inc. All rights reserved.