


{"id":407961,"date":"2025-02-01T02:29:41","date_gmt":"2025-02-01T02:29:41","guid":{"rendered":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/error-script-generating-sinusoidal-geometry\/"},"modified":"2025-02-18T16:00:03","modified_gmt":"2025-02-18T16:00:03","slug":"error-script-generating-sinusoidal-geometry","status":"answered","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/error-script-generating-sinusoidal-geometry\/","title":{"rendered":"Error script generating sinusoidal geometry"},"content":{"rendered":"<p>&lt;p&gt;&lt;p&gt;<strong>Context: <\/strong>Need to generate a parmetric cylindrical geometry as seen below.&lt;\/p&gt;&lt;p&gt;<img decoding=\"async\" src=\"https:\/\/innovationspace.ansys.com\/forum\/wp-content\/uploads\/sites\/2\/2025\/02\/01-02-2025-1738376910-mceclip0.png\" \/>&lt;\/p&gt;&lt;p&gt;<strong>Problem: <\/strong>I generated the points needed for the surface but I don&#8217;t know how to join the dots to generate the surface.&lt;\/p&gt;&lt;p&gt;<strong>Summary of code: <\/strong>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.&lt;br&gt;<img decoding=\"async\" src=\"https:\/\/innovationspace.ansys.com\/forum\/wp-content\/uploads\/sites\/2\/2025\/02\/01-02-2025-1738376938-mceclip1.png\" \/>&lt;\/p&gt;&lt;p&gt;<strong>Help wanted:<\/strong>&lt;\/p&gt;&lt;p&gt;1) Is there a method or function that can help me connect these points to form a surface?&lt;\/p&gt;&lt;p&gt;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 &#8211; was unable to include record equation in script and as a result unable to parametrise it)&lt;\/p&gt;&lt;p&gt;<strong>Code so far:&lt;br&gt;<\/strong>&lt;\/p&gt;&lt;p&gt;import math&lt;\/p&gt;&lt;p&gt;# Define parameters&lt;br&gt;D = 0.06 &nbsp;# Diameter of the cylinder (meters)&lt;br&gt;A = 0.0016 &nbsp;# Amplitude of sinusoidal wave (meters)&lt;br&gt;W = 0.02 &nbsp;# Wavelength of sinusoidal wave (meters)&lt;br&gt;length = 0.15 &nbsp;# Length of the cylinder (meters)&lt;br&gt;segments = 100 &nbsp;# Number of points used to make the structure&lt;br&gt;revolution_steps = 36 &nbsp;# Number of steps for full 360&deg; revolution&lt;\/p&gt;&lt;p&gt;# Create a list to store the 3D coordinates&lt;br&gt;ptList = List[Point]()&lt;\/p&gt;&lt;p&gt;# Generate the 3D points by revolving the profile&lt;br&gt;for i in range(segments):&lt;br&gt;&nbsp; &nbsp; x = i * (length \/ (segments &#8211; 1))&lt;br&gt;&nbsp; &nbsp; y_base = (D \/ 2) + A * math.sin((2 * math.pi \/ W) * x) &nbsp;# Radius at current x&lt;\/p&gt;&lt;p&gt;&nbsp; &nbsp; # Generate points along the revolution&lt;br&gt;&nbsp; &nbsp; for j in range(revolution_steps):&lt;br&gt;&nbsp; &nbsp; &nbsp; &nbsp; angle = (2 * math.pi \/ revolution_steps) * j &nbsp;# Angle for revolution&lt;br&gt;&nbsp; &nbsp; &nbsp; &nbsp; y = y_base * math.cos(angle) &nbsp;# Rotate radius in the yz-plane&lt;br&gt;&nbsp; &nbsp; &nbsp; &nbsp; z = y_base * math.sin(angle)&lt;br&gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;br&gt;&nbsp; &nbsp; &nbsp; &nbsp; # Create a point and add to the list&lt;br&gt;&nbsp; &nbsp; &nbsp; &nbsp; ptList.Add(Point.Create(x, y, z))&lt;\/p&gt;&lt;p&gt;&lt;br&gt;# Create the NURBS curve from the points&lt;br&gt;ncurve = NurbsCurve.CreateThroughPoints(False, ptList, 0.0001)&lt;\/p&gt;&lt;p&gt;# Create a curve segment from the NURBS curve&lt;br&gt;curveSegment = CurveSegment.Create(ncurve)&lt;\/p&gt;&lt;p&gt;# Create a design curve from the segment&lt;br&gt;designCurve = DesignCurve.Create(GetRootPart(), curveSegment)&lt;\/p&gt;&lt;\/p&gt;<\/p>\n","protected":false},"template":"","class_list":["post-407961","topic","type-topic","status-answered","hentry","topic-tag-moderator-spaceclaim","topic-tag-scripting","topic-tag-spaceclaim"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_forum_id":["27789"],"_bbp_topic_id":["407961"],"_bbp_author_ip":["129.94.6.193"],"_bbp_last_reply_id":["422129"],"_bbp_last_active_id":["422129"],"_bbp_last_active_time":["2025-02-18 09:46:01"],"_bbp_reply_count":["1"],"_bbp_reply_count_hidden":["0"],"_bbp_voice_count":["2"],"_bbp_engagement":["274006","2328"],"_btv_view_count":["491"],"_bbp_topic_status":["answered"],"_bbp_notification_enabled":["274006"],"_bbp_subscription":["2328"],"_edit_last":["2328"]},"test":"e5cf2fb3b531780a984f74b91ac54432ea877455"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/407961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/407961\/revisions"}],"predecessor-version":[{"id":422208,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/407961\/revisions\/422208"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=407961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}