TAGGED: Moderator SpaceClaim, python-scripting, scripting
-
-
February 1, 2024 at 5:42 pmJoana AlmeidaSubscriber
I have successfully replicated BlockBodies using a function (‘def’) and a ‘for’ loop (as per shown in image below). However, when I try to replicate different types of bodies (cylinders, spheres, ellipsoids, pyramids, …) it gives me an error. I believe the problem lies either in how I store the created object in a variable (‘ta = result.CreatedBody’) or on the identification of said object when creating a List (‘bodyList = List[IDocObject]()’). However, I do not know how to fix it… could anyone help me out?
-
February 2, 2024 at 3:08 pmAtharv JoshiForum Moderator
Hi Joana,
Let me check this and get back to you.
Thanks and Regards
Atharv -
February 5, 2024 at 6:00 amAtharv JoshiForum Moderator
Hi Joana,
Can you please try "ta=result.CreatedBodies" instead of "ta=result.CreatedBody"?
Let me know if this resolves your problem.
Thanks and Regards
Atharv-
February 5, 2024 at 3:43 pmJoana AlmeidaSubscriber
Hi Atharv,
Thank you so much for the quick response, though I’m afraid it didn’t solve my problem yet. Once I switch to what you suggest, an error appears concerning the creation of the list to store the cylinders (‘ expected IDocObject, got List[IDesignBody] ‘ ). Do you have any idea on how I can fix it?
-
-
February 9, 2024 at 7:22 amAtharv JoshiForum Moderator
Hi Joana,
"ta=result.CreatedBodies" forms a list of bodies. You can check this using the type function.
You need to include the index of the element to overcome the problem "bodylist.Add(ta[0])"Is their a specific reason you are creating a bodylist with IDocObjects?
What's your exact goal with this script?Thanks and Regards
Atharv-
February 10, 2024 at 10:31 amJoana AlmeidaSubscriber
Hi Atharv,
Once I include the index of the element “bodylist.Add(ta[0])”, a new error appears: “’bool’ object is unsubscriptable”.The only reason I created the bodylist with IDocObjects was because I checked the examples provided by SpaceClaim and the one where it generated stairs did their list with IDocObjects.
My goal with the script is to be able to duplicate one single (varying) object (cube, cylinder, sphere, pyramid, …) in a certain pattern that I have designed and tested with cubical tools (as it can be seen above). For the cubical solids, the bodylist with IDocObjects worked, but with every other different type of object it does not…
Thank you again for the helpJoana
-
-
February 9, 2024 at 2:45 pmJoana AlmeidaSubscriber
Once I include the index of the element “bodylist.Add(ta[0])”, a new error appears: “’bool’ object is unsubscriptable”.
-
- The topic ‘Ansys SpaceClaim scripting – replicating objects’ is closed to new replies.
- Unable to attach geometry 2024 R2
- Data Center Simulation
- Overlapping contact face
- DXF file loaded incorrectly
- plugin error failed to import assembly from spaceclaim
- Inventor 2025 files
- Issue Seeing Explore
- solidwork parameters for optimization in ansys
- Ansys SpaceClaim and Discovery 2024 Facet shelling bug – 2022 version is better
- Fan flow simulation
-
1882
-
802
-
599
-
591
-
366
© 2025 Copyright ANSYS, Inc. All rights reserved.