We have an exciting announcement about badges coming in May 2025. Until then, we will temporarily stop issuing new badges for course completions and certifications. However, all completions will be recorded and fulfilled after May 2025.
3D Design

3D Design

Topics related to Ansys Discovery and Ansys SpaceClaim.

Error script generating sinusoidal geometry

    • z5360540
      Subscriber

      Context: Need to generate a parmetric cylindrical geometry as seen below.

      Problem: I generated the points needed for the surface but I don't know how to join the dots to generate the surface.

      Summary of code: Generates x,y an z coordinates of points along surface. Draws curves that links up the surface (this is the best I can do right now). Image below shows this.

      Help wanted:

      1) Is there a method or function that can help me connect these points to form a surface?

      2) Is there a better way of creating this geometry? E.g. instead of generating x,y and z locations for points and generating a surface you can use the equation feature in space-claim and revolve it (NB: Tried this method - was unable to include record equation in script and as a result unable to parametrise it)

      Code so far:

      import math

      # Define parameters
      D = 0.06  # Diameter of the cylinder (meters)
      A = 0.0016  # Amplitude of sinusoidal wave (meters)
      W = 0.02  # Wavelength of sinusoidal wave (meters)
      length = 0.15  # Length of the cylinder (meters)
      segments = 100  # Number of points used to make the structure
      revolution_steps = 36  # Number of steps for full 360° revolution

      # Create a list to store the 3D coordinates
      ptList = List[Point]()

      # Generate the 3D points by revolving the profile
      for i in range(segments):
          x = i * (length / (segments - 1))
          y_base = (D / 2) + A * math.sin((2 * math.pi / W) * x)  # Radius at current x

          # Generate points along the revolution
          for j in range(revolution_steps):
              angle = (2 * math.pi / revolution_steps) * j  # Angle for revolution
              y = y_base * math.cos(angle)  # Rotate radius in the yz-plane
              z = y_base * math.sin(angle)
              
              # Create a point and add to the list
              ptList.Add(Point.Create(x, y, z))


      # Create the NURBS curve from the points
      ncurve = NurbsCurve.CreateThroughPoints(False, ptList, 0.0001)

      # Create a curve segment from the NURBS curve
      curveSegment = CurveSegment.Create(ncurve)

      # Create a design curve from the segment
      designCurve = DesignCurve.Create(GetRootPart(), curveSegment)

    • Atharv Joshi
      Forum Moderator
      Hello, 
       
      I think this is creating a continuous curve but is open ended. 
      Instead you can think of an approach of creating crest and trough and then use blend tool. 
      You can also use guide curve to follow the geometric shape.  
       
       
      Thanks and Regards
      Atharv
Viewing 1 reply thread
  • You must be logged in to reply to this topic.