How to run already exesisting SpaceClaim script using PyGeometry

Options
Suneel
Suneel Member Posts: 11
First Comment

Hi,
I have developed a script in SpaceClaim to clean the imported CAD and create additional bodies based on inputs.
Now I want to perform the same using PyGeometry, can I directly pass the SpaceClaim script from PyAnsys to Spaceclaim somthing like below (used to do it for Ansys ACT)
geometry1.RunScript(ScriptFile = SCScript, GeometryContainer = "Geometry",useAsMacro = "false")

Just for undaerstanding can you help me in executing following SC script using PyGeometry

#Creating a cylinder
def create_cyl(z1,h,d):
    r = d/2
    result = CylinderBody.Create(Point.Create(0, 0, z1), Point.Create(0, 0, h+z1), Point.Create(r, 0, h+z1), ExtrudeType.ForceIndependent)
    return

cyl1 = create_cyl(10,5,5)

Regards,
Suneel

Answers

  • Suneel
    Suneel Member Posts: 11
    First Comment
    Options

    Hi,
    I found out the way to run exesisting SC sript via PyAnsys, following is the code

    from ansys.geometry.core import launch_modeler 
    modeler = launch_modeler("spaceclaim")
    output = modeler.run_discovery_script_file(path = ".py file location")
    

    The above code is working fine but I have some additional question on the approach
    1. What is the best way to run (run the exesisting SC script from file like above). I feel error handling will be defficult
    2. Is it good to create/generage/modify the geometry using PyAnsys

    Regards,
    Suneel

  • RobPasMue
    RobPasMue Member, Employee Posts: 12
    First Comment First Answer Name Dropper First Anniversary
    Options

    HI @Suneel - PyAnsys Geometry has an already rich API. I recommend you give it a try since it will be more performant than running SC scripts directly.