3D Design

3D Design

Topics related to Ansys Discovery and Ansys SpaceClaim.

SpaceClaim Script: from scratch for fully meshed model

    • richard.polzer
      Subscriber

      Dear Ansys Learning Forum Community,

      I am rather new to ANSYS, but delighted about the power of recording and running python script to generate geometry and create a mesh. I am more familiar with ANSA but I will swap my toolset for SPACECLAIM. However, I am still running in a few issues where i could not find a solution yet.

      My aim is to create a model of concentric solid tubes. So far I only achieved to create one tube and mesh it, see below.

      However, I want to create three different parts first (let's call it part1 part2 part3) and with some logic create a tube, assign it to one of the parts, create the next concentric tube, assign it to another part and so forth. The parts are repeating (e.g. part1, part2, part3, part1, part2, part3, ...).

      Does anyone have a suggestion how I could achieve that possibly?

       

      # Python Script, API Version = V232

      # delete selection
      #selection = Selection.Create(GetRootPart().GetAllBodies())
      #result = Delete.Execute(selection)

      ClearAll()

      mode = InteractionMode.Solid
      result = ViewHelper.SetViewMode(mode)
      GetRootPart().ClearAllPartData()

      # Define Sketch Plane
      plane = Plane.PlaneXY
      result = ViewHelper.SetSketchPlane(plane)

      # Sketch Inner Circle 1 
      origin = Point2D.Create(MM(0), MM(0))
      result = SketchCircle.Create(origin, MM(2))

      # Sketch Inner Circle 1
      origin = Point2D.Create(MM(0), MM(0))
      result = SketchCircle.Create(origin, MM(4))

      # Solidify Sketch
      mode = InteractionMode.Solid
      result = ViewHelper.SetViewMode(mode, Info1)

      # Extrude 1 Face
      selection = Face1
      options = ExtrudeFaceOptions()
      options.ExtrudeType = ExtrudeType.Add
      result = ExtrudeFaces.Execute(selection, MM(95), options, Info3)

      # Create/Edit Mesh
      options = CreateMeshOptions()
      options.SolidElementShape = ElementShapeType.Hexahedral
      options.SurfaceElementShape = ElementShapeType.QuadDominant
      options.BlockingType = BlockingDecompositionType.Standard
      options.ElementSize = MM(1)
      options.MidsideNodes = MidsideNodesType.Kept
      bodySelection = Body1
      sweepFaceSelection = Selection.Empty()
      result = CreateMesh.Execute(bodySelection, sweepFaceSelection, options)


      # Rename Project
      GetRootPart().SetName('4695_detailed')

      # Rename Part
      GetRootPart().Bodies[0].SetName("Ring1")
      GetRootPart()


    • Rob
      Forum Moderator

      Others might have suggestions, but from the Ansys Staff team we can only point you at  https://github.com/ansys   You may want to focus effort onto Discovery over SpaceClaim given the former is the newer of the two tools. 

    • richard.polzer
      Subscriber

      Hello Rob,

      that's a pity. I am doing the the Discovery Scripting Introduction, but as up to now I have not found information that I am looking for. 

    • Rob
      Forum Moderator

      I'll flag to the Discovery team as they may know of more content. Also, 25R1 is due "soon" so watch for that as there may be additional information coming with that - I don't know as yet as I don't know what's public information. 

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