3D Design

3D Design

Topics related to Ansys Discovery and Ansys SpaceClaim.

Driving parameter and script parameter

    • Jimmy
      Subscriber

      Is there any method to change script parameter as driving parameter in SpaceClaim script? Is parametric study only possible in driving parameters?

      I want to use those script parameters in optiSLang. Is there any way to plug optiSLang in to SpaceCalim?

    • Aniket
      Forum Moderator

      Hi Jinwhan,

      Can you explain the query in more detail? Please note, SpaceClaim rebuilds the model from nothing when replaying scripts and assigns new IDs to all the entities. If you are generating the geometry via script, you should not declare design parameters to individual parts in downstream applications (for example, Mechanical). To properly scope loads and boundary conditions for geometries generated via script, you should generate Named Selections for them in the script itself, and then scope the loads or boundary conditions to the Named Selections downstream.

      -Aniket

      How to access Ansys help links

      Guidelines for Posting on Ansys Learning Forum

    • mjmiddle
      Ansys Employee

       

      Driving parameters are normally created using Pull and Move tools, but a few tools you can create a driving parameter during just selection mode, such as a pattern. I’m not sure what kind of script parameter you are referring since a script parameter behaves just like a driving parameter made with Pull and Move. You right click on the Groups panel and choose “Create Script Parameter”:

      Then right click to “Rename” as you choose:

      So if I rename to “myVar1” you can reference it anywhere in your script as “Parameters.myVar1″

      This will appear in the workbench project “Parameter Set” as a design parameter exactly as a driving dimension created by Pull and Move. Note that for a script to work with design points, you should “Publish as Group” the script so that it is saved with the SpaceClaim document (*.scdoc):

      It will then appear in the Groups tab and be associated with the scdoc file (saved inside the scdoc file):

      Note that some good practice in script design is to have a command at the beginning that deletes everything so you know the script started from the same model state each time:

      ClearAll()

      Also, as Aniket mentiond, have your script create named selections at the end since this is the best way to communicate selections in Mechanical for Outline items such as connections, loads, supports, results, etc…

       

    • Jimmy
      Subscriber

       

       

       

      Thank you very much indeed for your reply.

      I want to make cylinders in a slot box and move these geometry a certain height.

      I want to calculate these geomery change effect by optiSLang.

      So I want to set 3 parameters, circle radius, Block_height, Block_Width.  All three parameters should be in parmeter set.

      There is no problem to make circles and extrude them by parametric radius which located in Block_Width x Block_Lenght(15999mm, constant).

      But the Block_Width cannot be define in script parameters. I think it is driving parameters. 

      Because the number of circles are determined by the area of Block_Width x BlockLength, it is impotant to set Block_Width as parameter which I want to use in parameter set in Workbench.

      And I move these whole set of cyliners in slot(Block_WidthxBlockLenght x thickness) into a certain height(Block_Height).

      Unfortunately “move” geometry in SpaceClaim cannot be a driving parameters. 

      And driving parameters only can be parameter set in DX or optiSLang, isn’t it true?

      Help in SpaceClaim don’t help me. SpaceClaim Script document doesn’t decribe script parameter in detail.

      Where can I find proper document except this Forum?

       

       

      ——————————————————————————————————————

      # Python Script, API Version = V23
      # Library import 
      import math

      Block_radius=Parameters.Block_radius

      B_W=Parameters.Block_Width
      B_H=Parameters.Block_Height

      B_M=12.0 /1000.0                # margine
      B_W=400.0/1000-2*B_M     # Width of Rectangle
      B_L=1599.0/1000.0-2*B_M # Length of Rectangle
      thickness=6.0/1000             # extrude thickness of  circle (or the depth of slot)

      r=Block_radius                    # radius of perforate plate holes     

      print(B_M)
      print(B_W)
      print(B_L)
      print(r)
      print(thickness)

      # making circle surface 
      circular_radius = MM(r)*1000.00     
      circle_pitch = MM(r) * 3 * 1000.00  
      print (circular_radius)
      print (circle_pitch)

      # start location of circle surface
      start_x = -B_W/2+circle_pitch/2
      print(start_x)

      start_y = 93939.0/1000.0
      print(start_y)

      start_z = -B_L/2+circle_pitch/2
      print(start_z)

      # number of circle
      num_circles_x=int(math.ceil(B_W/circle_pitch))
      num_circles_z=int(math.ceil(B_L/circle_pitch))
      print(num_circles_x)
      print(num_circles_z)

       

      surfaces=[] # Empty list

      for i in range(num_circles_z): # width direction of circle
          for j in range(num_circles_x): #length direction of circle
               circle_x=start_x + j*circle_pitch
               circle_z=start_z + i*circle_pitch
               
               # 
               if (
               circle_x + r > B_W / 2 or
               circle_x – r < -B_W / 2 or
               circle_z + r > B_L / 2 or
               circle_z – r < -B_L / 2     ):
                  continue
               
               if i%2==1:
                   circle_x +=circle_pitch/2

               circle_result = CircularSurface.Create(r, Direction.DirY, 
          Point.Create(
              circle_x+(13236.0-B_W/2*1000.0-B_M*2*1000)/1000.0, 
          start_y, circle_z+(9105.0-B_L/2*1000)/1000.0))
               if circle_result.Success:
                   circle_face = circle_result.CreatedBodies[0].Faces[0]
                   surfaces.append(circle_face)        
                                         
                                         
               # Extrude circle surfaces
      if surfaces:
          selection = Selection.Create(surfaces)
          options = ExtrudeFaceOptions()
          options.ExtrudeType = ExtrudeType.Add
          result = ExtrudeFaces.Execute(selection, thickness, options)
      else:
          print(“There is no selections”)

      Selection.Clear()
      ViewHelper.ZoomToEntity()

       

       

    • mjmiddle
      Ansys Employee

      I don't see a problem here.

      A parameter made during the Move tool is a driving parameter as well as the script parameters. So you will have 3 driving parameters. But it is not good practice to make parameters with the native tools such as Move tool and also use script parameters. There may be an unintended result depending on which parameter is updated first. It is better to record the Move tool as script commands, and make another script parameter to use in that code.

      Driving parameters can be tagged as optimization parameters in DX. I don't use OptiSlang, but it probably can use the same driving parameters as optimization parameters.

    • Jimmy
      Subscriber

      Is there any SpaceClaim function to call Driving Dimensions in SpaceClaim script? Script Parameters are easy to use in script but Driving Dimensions are not.

    • mjmiddle
      Ansys Employee

      The parameter value in workbench likely not recognize the change to driving dimensions made by script:

      dims_NS = Window.Groups.GetValue(Window.ActiveWindow)   # gets list of named selections and driving dimensions in Groups tab, not published scripts or script parameters
      dims_NS[0].TryGetDimensionValue()    # 1st dimension, 3-tuple type. value is index 1, type is index 2 (Angular, Arc, Area, Diametric, Linear, Mass, Volume
      dims_NS[0].SetDimensionValue(value)

Viewing 6 reply threads
  • The topic ‘Driving parameter and script parameter’ is closed to new replies.