Page 1 of 1
Spiral hoops in circular column
Posted: Mon Jun 24, 2024 8:06 am
by KaushalPatel
Dear STKO Team,
I want to model the spiral hoops for circular columns in STKO in 3D. Could you tell me which tool I should use to model it?
Thank you.
Re: Spiral hoops in circular column
Posted: Mon Jun 24, 2024 2:57 pm
by kesavapraba
Hi, I wrote a piece of Python script that uses PyMpc library of STKO. You can try and modify according to your requirement.
Code: Select all
import math
from PyMpc import *
doc = App.caeDocument()
def create_helicalSpiral(start_x, start_y, start_z, radius, pitch, num_turns, num_points):
"""
Create a helical spiral line in 3D space.
Parameters:
start_x (float): X coordinate of the starting point
start_y (float): Y coordinate of the starting point
start_z (float): Z coordinate of the starting point
radius (float): Radius of the helix
pitch (float): Vertical distance between each turn of the helix
num_turns (int): Number of turns in the helix
num_points (int): Number of points to use in the spiral
Returns:
Wire: A PyMPC Wire object representing the helical spiral
"""
vertex = list(range(num_points))
for i in range(num_points):
t = i / (num_points - 1) * num_turns * 2 * math.pi
x = start_x + radius * math.cos(t)
y = start_y + radius * math.sin(t)
z = start_z + pitch * t / (2 * math.pi)
vertex[i] = FxOccBuilder.makeVertex(x, y, z)
edge = list(range(num_points-1))
for i in range(num_points-1):
edge[i] = FxOccBuilder.makeEdge(vertex[i], vertex[i+1])
w1 = FxOccBuilder.makeWire(edge)
next_id = doc.geometries.getlastkey(0)+1
geom = MpcGeometry(next_id,"Wire1",w1)
doc.addGeometry(geom)
App.runCommand('Regenerate',str(2))
create_helicalSpiral(0, 0, 0, 100, 50, 10, 500)
Re: Spiral hoops in circular column
Posted: Tue Jun 25, 2024 7:07 am
by KaushalPatel
Thanks for sharing. It works very nicely.
Re: Spiral hoops in circular column
Posted: Tue Jun 25, 2024 12:57 pm
by kesavapraba
You are welcome