TAGGED: Moderator SpaceClaim, python-scripting, scripting
-
-
February 1, 2024 at 5:42 pm
Joana Almeida
SubscriberI 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 pm
Atharv Joshi
Forum ModeratorHi Joana,
Let me check this and get back to you.
Thanks and Regards
Atharv -
February 5, 2024 at 6:00 am
Atharv Joshi
Forum ModeratorHi 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 pm
Joana Almeida
SubscriberHi 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 am
Atharv Joshi
Forum ModeratorHi 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 am
Joana Almeida
SubscriberHi 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 pm
Joana Almeida
SubscriberOnce 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
- DXF file loaded incorrectly
- Inventor 2025 files
- Ansys SpaceClaim and Discovery 2024 Facet shelling bug – 2022 version is better
- Masonry Brick Simulation
- Spaceclaim 2024 error FNE activation failed
- Simulating PCB
- How to do the snap fit insertion FEA?
-
1987
-
896
-
599
-
591
-
408
© 2025 Copyright ANSYS, Inc. All rights reserved.