3D Design

3D Design

Topics relate to Discovery SpaceClaim, Discovery Live and Discovery AIM

How do Smart Variables work in SpaceClaim?

    • Bruno Iwanczyk
      Subscriber

      Hi,

      I've been learning how to make a parametric model by scripting in SpaceClaim, but haven't been able to find much information on how Smart Variables work.

      If I select a body, click Insert Selection, rerun the script (with a ClearAll() at the beginning), select the same body and click Insert Selection I end up with two smart variables: Body1 and Body2. However they seem to be interchangeable, I can type either one into a function and the result is the same. So why do they have different names?

      I'm also curious as to how the smart variable is linked to the body it describes, so that I can know what will or won't break it.

    • mjmiddle
      Ansys Employee

      The smart variable is compiled data to identify a selection. This means you can't look at any code to see exactly how it works. It is only saved to the script when you save as .scscript format. The .py format is only a text format and so will not save this complied data.

      The smart variable, also known as metadata, is very much tied to the curent geometry. Because of this, I personally prefer to get rid of any compiled data so the script is more interchangable with other models. You can do this by setting index selection type:

      You can also make sure your script continues by using the return values of previous functions:

      result.CreatedPlanes, result.CreatedCurves, result.CreatedBodies, result.CreatedFaces, result.CreatedPlanes[0]

      Normally your Body1 and Body2 smart variables would not work interchangeably, because each is tied to the specific body that you then deleted. It is only working because you are clearing everything and each seems to point to the first body.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.