TAGGED: act, application, scripting, spaceclaim, workbench
-
-
July 20, 2021 at 9:05 amBJMELSubscriber
Hello everyone
I'm having difficulties implementing my previously developed SpaceClaim script, into an ACT scripting environment. I want to roll out this script solution out to my colleagues, as this design/analysis is quite repetitive and I thought an ACT (APP) would be quite suitable for the task.
The SpaceClaim script works perfectly within the SpaceClaim scripting environment. I've modified the IronPython SpaceClaim script slightly to work better with ACT by:
- Splitting it into two .py files, the script and the definition (def) I've defined
- Modified the input geometry variables to extract the values from the user (see example below)
br_h.Add(step.Properties["Geometry/br_h_top"].Value)Â
br_h.Add(step.Properties["Geometry/br_h_bot"].Value)Â
     ÂÂ
AC_geo.Add('br_h',br_h)
So far I've achieved the following in ACT:
- Defining the steps
- Setting up the workbench interface (separate load cases)
- Opening SpaceClaim
- Defining the geometry input
- Extracting the geometrical values from 4., to be used further in the IronPython code.
After that the ACT program crashes on a line where I define:
 variable = Direction.Create(1,0,0)
or:
variable = List[IComponent]()
My conclusion is therefore that: ACT does not recognize the internal SpaceClaim IronPython functions as default.
I've tried to define the following default definition that "imports" the default SpaceClaim IronPython definitions. ACT can call and run the definition , but it doesn't work.....
def script_import():
  '''
  This function imports SpaceClaim scripting for ACT
  '''
  import clr
  clr.AddReference("Ansys.ACT.Interfaces")
  import Ansys
  clr.AddReference("SpaceClaim.Api.V19")
  import SpaceClaim
  clr.AddReference('SpaceClaim.Api.V19.Scripting')
  from SpaceClaim.Api.V19 import Geometry
Â
 from SpaceClaim.Api.V19 import Modeler
  return
I've searched for days for some kind of solution online and in the ANSYS guides, but I cannot find my way around this problem. Do any of you have any suggestions?
Note: I cannot share the source code as it owned by the company I work for, but I can share some of if it would help
July 27, 2021 at 12:54 pmRajesh MeenaAnsys EmployeeHello
The SpaceClaim scripting function can not be used in ACT app without importing the spaceclaim libraries.
I would recommend you to first of all use ACT console in SpaceClaim for developing/Testing the code. Please refer to the help manual to check the parent libraries to be imported for a function (C:\Program Files\ANSYS Inc\v211\scdm\SpaceClaim.Api.V19).
For example, to use Direction.Create(0,0,1) you can simply search for this function in the help manual to find that you would need SpaceClaim.Api.V19.Geometry to be imported.
#-------------------------------------------------
SpaceClaim.Api.V19.Geometry as geometry
geometry.Direction.Create(0,0,1) #Create a direction object
#-------------------------------------------------
Similarly, List is nothing but a .Net array of type System.Collections.Generic.List.
Hope it helps.
Thanks Rajesh
July 27, 2021 at 8:03 pmBJMELSubscriberGood day Rajesh
After some trial and error, I had stumbled onto this as well, that if I run the code in the ACT console in SpaceClaim I get access to the SC library.
The only problem is that for some reason only V17 of the script library is available in ACT/SpaceClaim, so I need go through my original code and modify it to work with V17.
Do you know why that is? I cannot find anything in the documentation about it.
Regards
BJMEL
May 31, 2022 at 7:31 pmtricha122SubscriberBJMEL, did you ever find a solution for API's beyond V17?
i am having similar issues, but related to extensions:
for instance if i have a DesignEdge named "edge" and i want to evaluate its midpoint, i would do so in SC as follows:
px = edge.EvalMid().Point.X
however if i have this in a separate script, and run it using execfile, i will get an error that 'DesignEdgeGeneral' has no attribute 'EvalMid'
If i try to bring in the extensions, it still fails:
import SpaceClaim.Api.V20.Scripting.Extensions
px = edge.EvalMid().Point.X
and if i try to name the extensions, doesnt work:
import SpaceClaim.Api.V20.Scripting.Extensions as extension
px = edge.extension.EvalMid().Point.X
I wonder if youve come across a better solution?
Viewing 3 reply threads- The topic ‘How to execute SpaceClaim script within ACT?’ is closed to new replies.
Ansys Innovation SpaceTrending discussions- Unable to attach geometry 2024 R2
- Getting Mesh Faces With Specified Normal Via SpaceClaim Scripting (V241)
- How to provide blade angles in bladegen.
- DXF file loaded incorrectly
- plugin error failed to import assembly from spaceclaim
- Overlapping contact face
- Thermoelectric Cooler Model
- Issue Seeing Explore
- Warning Plugin Error Geometry in Design Modeler
- SpaceClaim stops sharing topology
Top Contributors-
1406
-
599
-
591
-
555
-
366
Top Rated Tags© 2025 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-