Skip to main content

Script Tip Friday- How to navigate scripting in SCDM

| 05.27.2022

Welcome back to Script Tip Friday! This week, we have a new author willing to share his expertise. Bruno Gaudin is a Senior Application Engineer at Ansys and is here to answer two questions related to Ansys SpaceClaim Direct Modeler:

  1. How to navigate on SCDM for scripting ?
  2. How to access the different objects in SCDM by scripting (Solid, Faces, Edge etc.)?

"Navigating in the SCDM tree is always a bit complicated when you start SCDM scripting! You can find lot of different "objects" with different methods on each to perform the action you need : Obviously, there are "Body" object, "Face" object, "Edge" object, etc. But there are also non explicit object like "DesignBody" object, "TrimmedSurface", object etc.

This document shows you what are these different objects and how they are related between them. For example, if you want to apply a Function on a "TrimmedSurface" and you want access to this easily in the tree, this document could help you!

Simple case

Let's started with a very simple example: if your tree looks like this example :

  • 3 independent bodies

In the background, the tree will be something like this:

What is the difference between "Design Body" and "Body", "DesignFace" and "Face" , etc.?

  • Body, Faces etc. are the things stored in Acis kernel. Acis uses it to do all the geometry operations (Booleans)
  • DesignBody, DesignFaces, etc. are the SCDM version of Body, Faces etc. For body : It holds the Body (use designBody.Shape to get the body), and all the Information SpaceClaim needs for the body that Acis doesn’t (id, name, color, etc.)

    That is why there are two different object and some methods are only available for Body, other only on Design Body etc.

    It's look like very simple but in case of you have components and dependent component, it's a bit more complicated. Please see explanations below:

Complicated Case

Explanations :

  • If you want to access in a Component you can use : GetRootPart.Components[0].Content
  • If you want to access in a Component in a component, you can use in GetRootPart.Components[0].Components[0].Content
  • If you want to go in Components in a Components you have to use GetRootPart().Components[0] etc.

Here, there is a new concept : DesignBodyGeneral and Design Body, etc. :

  • When you create a component, it can be a Duplicated component. So, if you modify something inside the component, it's also be modified in the others duplicated components
  • So, SCDM, always creates a Part General and a Part. The methods applied on the part, will affect all the Objects and the method applied on 1 PartGeneral will only affect this Object
  • You can use .Master to go from the PartGeneral to the Part!
  • The common information are in the Part (with DesignBody Bodies etc.) and the "local" information are in the PartGeneral

Here is an example. The design body contains all the Geometry information and the DesignBodyGeneral contains "local" information, for example, the relative position from the initial position.

To go further :

  • The TrimmedSpace allows you to query info (Volume, Surface Area, etc.), but you can’t do geometry operations (the kernel doesn’t know about the TrimmedSpace, it only knows about the Body). The TrimmedSpace is necessary because the Body and TrimmedSpace may not be in the same location (depending on the transform of the component).
  • Any type with “General” in the name comes from a component. A component is essentially just a transform and pointer to a master -- it is structured this way so that you can create copies of parts without duplicating data. Similarly, you can think of a DesignBodyGeneral as a transform and a pointer to the master (DesignBody). When you call “.Shape” on a DesignBody you get the modeler body (type = Body). When you call “.Shape” on a DesignBodyGeneral you get a “graphical” copy of the modeler body (type = TimmedSpace).