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 behaviourselection = 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 22, 2025 at 6:59 am
NickFL
SubscriberInstead of the 3 while loops to delete everything, try the ClearAll().
You are also using Workbench based upon the FFF nomenclature. I am not sure what is "saved" in the background with Workbench as I avoid it if at all possible. Can you try running in Standalone?
-
October 1, 2025 at 12:35 pm
Lumbdi
Subscriberso if anyone ever has a similar problem for some reason - ClearAll() made everything stable - in that it stopped working alltogether - now the communication with the mesher stopped working as well...
So long story short - I have absoluetely no clue why it worked sometimes, but It is now stable after swapping to solid interaction mode in the end.
mode = InteractionMode.Solid
result = ViewHelper.SetViewMode(mode, None)Lines are now not created in GetRootPart().Components anymore but in GetRootPart().DatumPlanes[0] - or GetRootPart().Bodies[0].Edges after switching View mode - why does that have an influence?
-
-
-
September 19, 2025 at 7:59 am
Lumbdi
Subscriber-> Reply
-
- You must be logged in to reply to this topic.
- Project lines/edges into a face with the direction normal to the face
- No preview in explorer with scdox file
- Add-in Error Excel
- Fileformats
- Spaceclaim problem
- Using SpaceClaim scripts vs recorded blocks for parametric optimization workflow
- Different Body Naming and Extra Surfaces after Importing Solid Edge Part
- racing royals
- New Computer
- Inconsistent Script
-
4602
-
1510
-
1386
-
1209
-
1021
© 2025 Copyright ANSYS, Inc. All rights reserved.