3D Design

3D Design

Topics related to Ansys Discovery and Ansys SpaceClaim.

SpaceClaim Scripting – Pinned Axis

    • Jake Garrison
      Subscriber

      Hello, 

       

      How can I pin an axis via SpaceClaim scripting that I created through the center of a circle? 

       

      # Create Datum Line
      selection = EdgeSelection.Create(GetRootPart().Bodies[0].Edges[462])
      result = DatumLineCreator.Create(selection, False, None)

      # check if the datum line is pinned or not
      GetRootPart().DatumLines[0].Pinned

       

      I would like to set the value of Pinned to True or False. 

      Thanks. 

    • mjmiddle
      Ansys Employee

      There is no published API for this. You have to do it through a call to the GUI command. Unfortunately, the recorded commands that create a datum line won't associate the datum with the selected edge, so it can't be pinned. So you also have to use a GUI command to create the datum line.

      from SpaceClaim.Api.V23 import Command
      selection = EdgeSelection.Create(GetRootPart().Bodies[0].Edges[462])
      selection.SetActive()
      Command.GetCommand("CreateDatumLine").Execute()    # the axis created will automatically be selected
      Command.GetCommand("PinDatum").Execute()

    • Jake Garrison
      Subscriber

      mjmiddle, 

       

      When I attempt to run "Command.GetCommand("CreateDatumLine").Execute()" in the interpreter I get the error "name 'Command' is not defined". 

    • mjmiddle
      Ansys Employee

      The first line will import the command. You are probably using too old a version if it does not work. What version are you using? Maybe the datum line creation is a different command in your version.

    • Jake Garrison
      Subscriber

      I'm using 2023 R1, I will try again using 2023 R2 after importing Command. 

    • mjmiddle
      Ansys Employee

      You need to change the V23 in the first line to match your version.

    • mjmiddle
      Ansys Employee

      I ran the script in 2023 R1 exactly as I printed it, and it worked. If it gives an error that "Command" is not defined, that would indicate the first line to import it was not run. If the first line was run and the Command object was not found, the first line would produce an error.

Viewing 6 reply threads
  • You must be logged in to reply to this topic.