TAGGED: python-scripting, spaceclaim
-
-
September 18, 2025 at 2:00 pm
Lumbdi
SubscriberI'm generating a geometry using a script in spaceclaim. It used to work in other projects, but since IÂ swapped from 24R2 to 25R1 it's inconsistent and only works sometimes.
It makes a 2D planesectionPlane = Plane.PlaneXY
result = ViewHelper.SetSketchPlane(sectionPlane, None)and adds lines
result = SketchLine.Create(start, end)
I then want to make named selections, but these lines get sometimes added to FFF/Sketching Plane1 / Sketch1 and sometimes to FFF / Surface (which is how it used to work).
If i delete the sketchContainer1, i get an alternating once it works and then it doesn't behaviourÂselection = SketchContainer1
Delete.Execute(selection)How do i make this consistent?
-
September 19, 2025 at 6:27 am
NickFL
SubscriberBased upon what you have said, my first instinct is to say that your sketch is not completely closed, or you have some inconsistent constraints. Do you have some geometry already created when this part of your script is executed?
Â
When you finish drawing your sketch and go to 3D Solid Mode, SpaceClaim will automatically try and fill. But if it does not do the fill automatically, you can force it to yourself. Use the commands:
sel = Selection.Create(GetRootPart.DatumPlanes[-1].Curves[:])
sel2 = Selection.Empty()
options = FillOptions()
result = Fill.Execute(sel,sel2,options)
The part you may want to look at here is the fill options. The default GapDistance is 0.0001 [m]. Depending on your situation this may not be sufficiently large. You could increase it to something more appropriate for this sketch.
Another thing, it is good to create a plane and then work off this plane instead of working in 3D Sketch containers. An example code would look like:
# Bezugsebene erstellen
selection = Selection.Create(GetRootPart().CoordinateSystems[0].Axes[0])
result = DatumPlaneCreator.Create(selection, False, None)
selection = Selection.Create(result.CreatedPlanes)
result = ViewHelper.SetSketchPlane(selection)
Â
# Set 3 Points and create lines
point1 = Point2D.Create(MM(9), MM(8))
point2 = Point2D.Create(MM(13), MM(17))
point3 = Point2D.Create(MM(25), MM(15))
result = SketchLine.Create(point1, point2)
result = SketchLine.Create(point2, point3)
result = SketchLine.Create(point3,point1)
Â
# Grab all the lines and fill
sel = Selection.Create(GetRootPart().DatumPlanes[-1].Curves[:])
sel2 = Selection.Empty()
options = FillOptions()
result = Fill.Execute(sel,sel2,options)
-
September 19, 2025 at 9:18 am
Lumbdi
SubscriberI have a loop in the beginning that deletes old geometries:
while GetRootPart().Components.Count > 0:
  GetRootPart().Components[0].Delete()
while GetRootPart().Bodies.Count > 0:
  GetRootPart().Bodies[0].Delete()
while GetRootPart().Curves.Count > 0:
  GetRootPart().Curves[0].Delete()Is there a better way to clear current geometries?
This also doesn't work anymore, since this lines are not in GetRootPart().Components. But even if I delete everything in FFF*, this occures.
If I include yourselection = Selection.Create(GetRootPart().CoordinateSystems[0].Axes[0])
result = DatumPlaneCreator.Create(selection, False, None)
selection = Selection.Create(result.CreatedPlanes)
result = ViewHelper.SetSketchPlane(selection)at the start and:
# Grab all the lines and fill
sel = Selection.Create(GetRootPart().DatumPlanes[-1].Curves[:])
sel2 = Selection.Empty()
options = FillOptions()
result = Fill.Execute(sel,sel2,options)at the end, the first run goes through, but the second one throws an error:
result = Fill.Execute(sel,sel2,options)
The Fill command must include a Face or Edge selectionWhich to me sounds like the same issue and GetRootPart() doesn't contain the drawn lines.
Thank you very much your help!
-
-
September 19, 2025 at 7:59 am
Lumbdi
Subscriber-> Reply
-
- You must be logged in to reply to this topic.
- FSAE CFD – Lesson 1 Preparation question (Using Discovery)
- Project lines/edges into a face with the direction normal to the face
- Script for subtracting models
- No preview in explorer with scdox file
- Multiple Instances of SpaceClaim taking multiple licenses
- Spaceclaim file reference error
- Issues after installing new service pack 2024R1 (sp5)
- Add-in Error Excel
- Problems with loading my Discovery Mesh into Fluent
- Missing SubDivWrapper.dll
-
3892
-
1414
-
1256
-
1118
-
1015
© 2025 Copyright ANSYS, Inc. All rights reserved.