Much Ado About Scripting in Ansys SpaceClaim – Part 1

By: Robert McCathren
– May 5, 2022
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.

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:

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! 

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!

Categories

Certified Elite Channel Partner

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

Product Development
Diamond Partner

Technical Expertise to Enable your Addictive 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: Phoenix Analysis and Design Technologies, 7755 S. Research Dr., Tempe, AZ, 85284, https://www.padtinc.com. 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:

Share on twitter
Share on facebook
Share on linkedin
Share on pinterest

Upcoming Events

05/19/2022

RAPID + tct 2022

05/19/2022

Venture Cafe Roundtable: AI & Healthcare

05/18/2022

Tucson after5 Tech Mixer: World View

05/18/2022

RAPID + tct 2022

More Info

05/18/2022

Signal & Power Integrity Updates in Ansys 2022 R1 - Webinar

05/18/2022

Simulation World 2022

05/17/2022

RAPID + tct 2022

05/11/2022

Experience Stratasys Manufacturing Virtual Event

05/04/2022

Mechanical Meshing Updates in Ansys 2022 R1 - Webinar

04/27/2022

04/22/2022

12TH ANNUAL TUCSON GOLF TOURNAMENT

04/21/2022

04/20/2022

Additional Fluids Updates in Ansys 2022 R1

04/20/2022

Experience Stratasys Tour – Tempe Arizona

04/18/2022

Experience Stratasys Tour - Flagstaff Arizona

04/14/2022

D&M West | MD&M West

04/13/2022

D&M West | MD&M West

04/13/2022

Experience Stratasys Tour - Albuquerque New Mexico

04/12/2022

D&M West | MD&M West

04/12/2022

Experience Stratasys Tour - Los Alamos New Mexico

04/12/2022

Optimizing Engineering Workflows f​​​​or Propulsion System Design

04/07/2022

Experience Stratasys Tour - Austin Texas

04/07/2022

37th Space Symposium - Arizona Space Industry

04/06/2022

Transforming Digital Engineering with Ansys Discovery 2022 R1

04/06/2022

37th Space Symposium - Arizona Space Industry

04/05/2022

37th Space Symposium - Arizona Space Industry

04/04/2022

37th Space Symposium - Arizona Space Industry

03/30/2022

Simulation Best Practices for Vehicle Engineering - Webinar

03/23/2022

03/23/2022

High & Low Frequency Electromagnetics Updates in Ansys 2022 R1

02/24/2022

Arizona Technology Council After 5 Tech Mixer "Pandemic Pivot Pizza Pa

02/23/2022

SciTech Festival: Spend an Hour with 3D Printing Experts

02/11/2022

Webinar: Mechanical overview for Ansys 2022 R1

More Info

02/09/2022

Webinar: Product Development 101 (FAKE)

02/08/2022

Webinar: Navigating the Additive Landscape

01/27/2022

Arizona Technology Council 1st Quarter VIP Tech Mixer

More Info

01/26/2022

Simulation Best Practices for Gas Turbine Design & Development - Webin

More Info

01/19/2022

Arizona Photonics Days

More Info

11/04/2021

ExperienceIT, New Mexico

More Info

11/03/2021

Additive Manufacturing & Structural Optimization in Ansys 2021 R2 - We

More Info

11/03/2021

Optics Valley Technical Series: The Future of Simulation in the Optics

More Info

11/02/2021

SBIR Liftoff AZTC Virtual Breakfast Series

More Info

10/10/2021

Stratasys Mobile Truck Stop - Tucson Arizona

More Info

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: