3D Design

3D Design

There is a way to change Bodies’ name when we use ANSYS ACT to create primitives in DesignModeler

    • banghuazhao
      Subscriber

      When we use ANSYS ACT in DesignModeler, we can use API to create primitives. Those primitives become the bodies. Is there a way to change the bodies' name before or when we add those bodies to feature. 

       

      For example, I want to create a square pack microstructure. Is there a way to change and the name of fiber and matrix? The codes are following:

       

      ExtAPI.Log.WriteMessage("Generating Square Pack Microstucture 2D...")

       

      # Unit Length of the SG

      L = 1.0e3

       

      # Collect the volume fraction of the fiber

      volume_fraction = feature.Properties["Volume Fraction of Fiber"].Value

       

      # Calculate the radius of the fiber

      radius = L * ( volume_fraction / math.pi ) ** (1./2.)

       

      # Empty SG (array) to collect the entities generated

      SG = []

       

      # Some useful builder

      primitive = ExtAPI.DataModel.GeometryBuilder.Primitives  

      operation = ExtAPI.DataModel.GeometryBuilder.Operations

       

      # Created matrix

      sheet_square = primitive.Sheet.CreatePolygon([L/2., L/2., 0., -L/2., L/2., 0., -L/2., -L/2., 0., L/2., -L/2., 0.]).Generate()

      wire = primitive.Wire.CreateArc(radius, [0., 0., 0.], [1., 0., 0.], [0., 0., 1.]).Generate()

      sheet_circle = operation.Tools.WireToSheetBody(wire)

      matrix = operation.CreateSubtractOperation([sheet_circle]).ApplyTo([sheet_square])[0]

       

      # Create fiber

      wire = primitive.Wire.CreateArc(radius, [0., 0., 0.], [1., 0., 0.], [0., 0., 1.]).Generate()   

      fiber = operation.Tools.WireToSheetBody(wire)

       

      # Create Part

      part = operation.Tools.CreatePart([fiber, matrix])

      part.Name = 'Square Pack Microstucture 2D'

       

      SG.Add(part)

       

      # Add resultant entities to feature

      feature.Bodies = SG

      # Assign material type to the entities. Different options are Add, Cut, Freeze

      feature.MaterialType = MaterialTypeEnum.Freeze

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