Much Ado About Scripting in Ansys SpaceClaim – Part 1

Categories:

If you’re a fan of Ansys SpaceClaim then you know and love the direct modeling capabilities within that program. However, because of the Direct Modeling focus, it has historically been a little soft when it comes to parametric-CAD-esque modeling features…but that’s a bit of a lie as, under the hood, rests some powerful scripting functionality just waiting to be utilized.

But I know what you’re asking…

PADT Ansys SpaceClaim Scripting - Part 1: Fig. 1

And yes, you can! It is not a technique the Jedi Council ANSYS would keep from you, and it can be accessed in two ways: Script Record and Block Record, both accessible within the “Design” Ribbon as shown below.

PADT Ansys SpaceClaim Scripting - Part 1: Fig. 2

You can also access the Script Record feature via “File”->”New”->”Script”

PADT Ansys SpaceClaim Scripting - Part 1: Fig. 3

Script Recording in Ansys SpaceClaim

“Script Record” provides the ability to record scriptable features and operations as you click around in the display menu creating and modifying geometry, as well as the ability to write lines of code, and then execute those scripts. Within the Scripting window, there is also a snippet/script “Interpreter”, and a virtual console to test things out. Ansys SpaceClaim uses Python as its scripting language so you can dust off those programming skills you learned in school and put them to good use.

PADT Ansys SpaceClaim Scripting p1 f04 1

You can also utilize some pre-made example scripts to get you started via the “Insert Code Snippet” button (aka the “[…]” button next to the big red record button), change the API version, and publish a script so that it will be saved with that particular *.scdoc or *.scdocx file. Scripts can also be saved independently of a Ansys SpaceClaim document.

PADT Ansys SpaceClaim Scripting p1 f05

The example scripts have some interesting features presented within them (complex curves, gear creation, etc.) and are easy to scavenge odds and ends from for your own scripting endeavors:

PADT Ansys SpaceClaim Scripting p1 f0b6
Wait, is that Metal Gear!?!? (Hey, somebody on this team has to make video game references).

Another major benefit of script recording is that script variables can be promoted to “Script Parameters” via the right-click menu and will then be editable via the “Groups” window, and they can be used downstream in Ansys design studies within Workbench! 

PADT Ansys SpaceClaim Scripting p1 f07

Block Recording

As mentioned previously, “Block Record” is the alternative to “Script Record”, and it functions much like a standard Parametric-type CAD system. It records a history of operations performed by the user which can then be altered at any point by clicking on that “block” and altering the information within:

PADT Ansys SpaceClaim Scripting p1 f08

Just like with script recording, you can promote certain entities within each block as Parameters for use in design studies. This is denoted by the “P” button next to applicable items within that block.

Note that standard parametric CAD caveats apply with Block Recording i.e.: you have to be mindful of constraints and dependencies of upstream blocks as it is possible to invalidate operations by making changes that effectively remove a later block’s geometry in an earlier step.

Reference me this, Bat-ManTM!

If you have access to the ANSYS Learning Hub then I recommend taking the Ansys SpaceClaim Scripting course located here: Structures | Customization – Scripting in Ansys SpaceClaim (sapjam.com). Included with that course are several workshops that go over various scripting aspects for selections, operations, groups, etc.

If you need to find the Ansys SpaceClaim API, then it is located in your Ansys SpaceClaim installation folder (somewhere along the lines of “C:\Program Files\ANSYS Inc\v212\scdm”). Each installed version of the API is listed within that directory:

PADT Ansys SpaceClaim Scripting p1 f09
PADT Ansys SpaceClaim Scripting p1 f10

The API documentation lays out classes, commands, and general programming structure. I will note that I have learned more from just using the Script Record feature than scanning through the API. But hey, different strokes for different folks!

On a different note: did you know that Ansys SpaceClaim scripting is not limited to just SpaceClaim? It can be used in Ansys Discovery now as well! SpaceClaim sits under the hood of Ansys Discovery so most of the geometry scripting carries over between Ansys SpaceClaim and Ansys Discovery (depending on if that feature is supported within Discovery) and simulation features like forces and boundary conditions are scriptable as well!

PADT Ansys SpaceClaim Scripting p1 f11

The availability of having a fully fleshed-out scripting window via CAD (and not just a “live” single-line scripting bar) is immensely helpful if you are creating any range of complex or repetitive operations. I’ve really just glanced at the surface with what you can do in Ansys SpaceClaim scripting so expect more posts showing off this tech!

Until next time!

Categories

Get Your Ansys Products & Support from the Engineers who Contribute to this Blog.

Technical Expertise to Enable your Additive Manufacturing Success.

PADT’s Pulse Newsletter

Keep up to date on what is going on at PADT by subscribing to our newsletter.


By submitting this form, you are consenting to receive marketing emails from: . You can revoke your consent to receive emails at any time by using the SafeUnsubscribe® link, found at the bottom of every email. Emails are serviced by Constant Contact

Share this post:

Upcoming Events

04/22/2024

Experience Stratasys Truck Tour: Houston, TX

04/24/2024

Structures Updates in Ansys 2024 R1 (2)

04/24/2024

Experience Stratasys Truck Tour: Houston, TX

05/07/2024

Experience Stratasys Truck Tour: Albuquerque, NM

05/07/2024

Dynamic Simulation for Rocket Propellant Systems! - Webinar

05/08/2024

Fluent Materials Processing Updates in Ansys 2024 R1 - Webinar

05/13/2024

Experience Stratasys Truck Tour: Tempe, AZ

05/14/2024

Simulation World 2024

05/15/2024

Simulation World 2024

05/16/2024

Simulation World 2024

05/22/2024

Optics Updates in Ansys 2024 R1 - Webinar

06/12/2024

Connect Updates in Ansys 2024 R1 - Webinar

06/26/2024

Structures Updates in Ansys 2024 R1 (3) - Webinar

06/27/2024

E-Mobility and Clean Energy Summit

07/10/2024

Fluids Updates in Ansys 2024 R1 - Webinar

08/05/2024

2024 CEO Leadership Retreat

10/23/2024

PADT30 | Nerdtoberfest 2024

Search in PADT site

Contact Us

Most of our customers receive their support over the phone or via email. Customers who are close by can also set up a face-to-face appointment with one of our engineers.

For most locations, simply contact us: