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…

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.

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

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.

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.

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:

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!

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:

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:


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!

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!