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

11/15/2023

2023 Governor’s Celebration of Innovation Awards

11/15/2023

Twin Builder Updates in Ansys 2023 R2 - Webinar

11/01/2023

Webinar: Additive's Role in Factory 4.0

10/25/2023

Ansys LevelUp 2023

10/25/2023

Nerdtoberfest 2023

10/25/2023

Mechanical Updates in Ansys 2023 R2 (3) - Webinar

10/18/2023

2023 Southern Arizona Tech + Business Expo

10/18/2023

Fluent GPU Solver Updates in Ansys 2023 R2 - Webinar

10/09/2023

Structural Updates in Ansys 2023 R2 (2) - Webinar

10/02/2023

Colorado Life Sciences Innovation Forum 2023

09/27/2023

2023 AZ Bio Awards

09/26/2023

Experience Stratasys Truck Tour - Houston

09/22/2023

AIAA Rocky Mountain Section Technical Symposium 2023

09/22/2023

Experience Stratasys Truck Tour - Dallas, TX

09/21/2023

Accelerating the Energy Transition through Simulation

09/20/2023

3D Printing vs. CNC Machining - Webinar

09/13/2023

Maxwell Updates in Ansys 2023 R2 - Webinar

09/12/2023

Sandia Science & Technology Park 25th Anniversary

09/12/2023

Experience Stratasys Truck Tour - Tempe, AZ

09/08/2023

26th Annual New Mexico Flying 40 Awards

09/08/2023

New Mexico Tech Summit

09/07/2023

New Mexico Tech Summit

08/30/2023

Structures Updates in Ansys 2023 R2 (1) - Mechanical, Post & Graphics

08/23/2023

Improved Injection Molding with Additive - Webinar

08/22/2023

SPIE Optics & Photonics Exhibition 2023

08/16/2023

Fluids Updates in Ansys 2023 R2 - Webinar

08/04/2023

Experience Stratasys Truck Tour - Salt Lake City, Utah

08/01/2023

Experience Stratasys Truck Tour - Denver Colorado

07/26/2023

Solving Supply Chain Issues with Additive - Webinar

07/25/2023

Arizona Tech Leadership Golf Tournament

07/24/2023

Arizona Tech CEO Leadership Retreat

07/19/2023

System Automation & Optimization Updates in Ansys 2023 R1 - Webinar

07/13/2023

2023 AEROSPACE, AVIATION, DEFENSE AND MANUFACTURING CONFERENCE

07/12/2023

Materials Updates in Ansys Granta 2023 R1 - Webinar

06/30/2023

Turbo Expo 2023

06/29/2023

Turbo Expo 2023

06/28/2023

Turbo Expo 2023

06/28/2023

Revolutionize Packaging Design with Additive - Webinar

06/27/2023

Turbo Expo 2023

06/27/2023

2023 E-MOBILITY AND CLEAN ENERGY SUMMIT

06/26/2023

Turbo Expo 2023

06/21/2023

Optics Updates in Ansys 2023 R1 - Webinar

06/07/2023

LS-DYNA Updates in Ansys 2023 R1 - Webinar

05/31/2023

Driving Automotive Innovation with Additive - Webinar

05/24/2023

Hill Air Force Base Tech Expo

05/24/2023

Structural Updates in Ansys 2023 R1 (3) – Structural Optimization & Ex

05/23/2023

CROSSTALK 2023: Emerging Opportunities for Advanced Manufacturing Smal

05/10/2023

Signal & Power Integrity Updates in Ansys 2023 R1 - Webinar

04/26/2023

Additive Manufacturing Updates in Ansys 2023 R1 - Webinar

04/20/2023

38th Space Symposium Arizona Space Industry

More Info

04/19/2023

38th Space Symposium
Arizona Space Industry

04/19/2023

Additive Aids for Manufacturing - Webinar

04/18/2023

38th Space Symposium
Arizona Space Industry

04/17/2023

38th Space Symposium

04/13/2023

Venture Madness 2023

04/12/2023

Fluid Meshing & GPU-Solver Updates in Ansys 2023 R1 - Webinar

03/29/2023

8th Thermal and Fluids Engineering Conference

03/29/2023

Structural Updates in Ansys 2023 R1 - Composites, Fracture & MAPDL

03/28/2023

8th Thermal and Fluids Engineering Conference

03/27/2023

8th Thermal and Fluids Engineering Conference

03/26/2023

8TH Thermal and Fluids Engineering Conference

03/24/2023

Arizona BioPreneur Conference | Spring 2023

03/22/2023

2023 Arizona MedTech Conference

03/22/2023

Optimize Jigs & Fixtures with Additive - Webinar

03/15/2023

3D Design Updates in Ansys 2023 R1 - Webinar

03/08/2023

Competitive Advantages of 1D/3D Coupled Simulation - Webinar

03/01/2023

High Frequency Updates in Ansys 2023 R1 - Webinar

02/22/2023

Additive Advantages in Aerospace - Webinar

02/15/2023

Structural Updates in Ansys 2023 R1 (1) - Webinar

02/09/2023

IME 2023: MD&M | WestPack | ATX | D&M | Plastek

02/08/2023

IME 2023 MD&M | WestPack | ATX | D&M | Plastek

02/07/2023

IME 2023 MD&M | WestPack | ATX | D&M | Plastek

01/27/2023

Arizona Photonics Days, 2023

01/26/2023

Arizona Photonics Days, 2023

01/26/2023

TIPE 3D Printing | 2023

01/26/2023

Venture Cafe Phoenix Talent Night - Job Fari

01/26/2023

VFS 2023 Autonomous/Electric VTOL Symposium

01/25/2023

Arizona Photonics Days, 2023

01/25/2023

Building A.M.- Utah: Kickoff!

01/25/2023

TIPE 3D Printing | 2023

01/25/2023

VFS 2023 Autonomous/Electric VTOL Symposium

01/24/2023

VFS 2023 Autonomous/Electric VTOL Symposium

01/24/2023

TIPE 3D Printing | 2023

01/18/2023

2023 AZ Tech Council Golf Tournament

12/21/2022

Simulation Best Practices for 5G Technology - Webinar

12/14/2022

Digital Twins Updates in Ansys 2022 R2 - Webinar

12/08/2022

Tech the Halls - AZ Tech Council Holiday Mixer

12/07/2022

Electric Vehicle and Other Infrastructure Update Panel

11/30/2022

SPEOS Updates in Ansys 2022 R2 - Webinar

11/23/2022

Simulation Best Practices for Electronics Reliability - Webinar

11/16/2022

Discovery Updates in Ansys 2022 R2

11/10/2022

VentureCafe Phoenix Panel: Venture Capital in AZ

11/08/2022

2022 GOVERNOR’S CELEBRATION OF INNOVATION AWARDS + TECH SHOWCASE

11/03/2022

VentureCafe Phoenix Panel: Angel Investment in AZ

11/02/2022

High & Low Frequency Electromagnetics Updates in Ansys 2022 R2

10/26/2022

Simulation Best Practices For Chip-Package-System Design & Development

10/20/2022

Nerdtoberfest 2022

10/19/2022

2022 Southern Arizona Tech + Business Expo

10/19/2022

LS-DYNA Updates in Ansys 2022 R2 - Webinar

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: