3D Design

3D Design

Topics related to Ansys Discovery and Ansys SpaceClaim.

SCDM – Accessing Sketch from Script

    • NickFL
      Subscriber

      I have a script that creates a set of points and then it draw lines between these points. I then need to move to a new plane, and hence different new sketch, and do the same thing. Both of these planes already have sketches on them, and I want to add these lines to the existing sketches. My goal was to have all this scripted, but it doesn’t seem like there is a way to access the sketch using the Index method, only the SmartVariable method. Is that correct? I have not worked much with these SmartVariable and it does not seem like the user has much control over what is defined.

      I am using R23.1 and the API version 23.

    • Aniket
      Forum Moderator

      Hi NickFL, have you tried to use the inbuilt feature of using formatted text files that can create the points as well as lines in the model? Please check "Point Curve Text" imports at the following link:

      https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v231/en/spaceclaim/Discovery/user_manual/file/r_file-operation_import-export_import-file-formats.html

      -Aniket

      How to access Ansys help links

      Guidelines for Posting on Ansys Learning Forum

       

    • mjmiddle
      Ansys Employee

      The smart variable is binary data tied to the model.

      I have asked for an enhancement request before to be able to select sketches under a plane using script, but it doesn't look to have been done yet. There is the only way to currently do it, and it's a bit awkward:

      Multiple sketches under the same plane can only be made when constraint based sketching is turned on, and you right click on the datum plane to choose "New sketch."
       
      dp = GetRootPart().DatumPlanes[0]
      dp.Curves    # a list of all 8 curves
       
      dp.GetChildren[DocObject]()
      This gets a list where every DatumLine,DatumLine,DatumPoint triplet defines a sketch plane under the datum plane.  DesignCurves are also in the list for actual sketched curves. It will also list SketchConstraint types. For example, with one datum plane and two sketches under the plane with 4 curves under each sketch, you get a list in this order after the SketchConstraint types:
      DatumLine
      DatumLine
      DatumPoint
      DesignCurve
      DesignCurve
      DesignCurve
      DesignCurve
      DatumLine
      DatumLine
      DatumPoint
      DesignCurve
      DesignCurve
      DesignCurve
      DesignCurve
       
      You could check this list for the DatumLine,DatumLine,DatumPoint triplets, and each triplet found is a sketch in the order listed.
    • NickFL
      Subscriber

      Thank you both. I am glad I wasn't missing something straightforward. Maybe one day the developers will listen to us and that functionality will appear ? . Until then, your input has given me a couple things to try, and I have a couple of avenues now to pursue. Thanks again!

Viewing 3 reply threads
  • The topic ‘SCDM – Accessing Sketch from Script’ is closed to new replies.