Spiral hoops in circular column

Post Reply
KaushalPatel
Posts: 19
Joined: Thu Dec 21, 2023 3:17 pm

Spiral hoops in circular column

Post by KaushalPatel » Mon Jun 24, 2024 8:06 am

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.

kesavapraba
Posts: 348
Joined: Sat Mar 28, 2020 2:25 pm

Re: Spiral hoops in circular column

Post by kesavapraba » Mon Jun 24, 2024 2:57 pm

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)


:: With best wishes ::
Prabakaran Kesavan

KaushalPatel
Posts: 19
Joined: Thu Dec 21, 2023 3:17 pm

Re: Spiral hoops in circular column

Post by KaushalPatel » Tue Jun 25, 2024 7:07 am

Thanks for sharing. It works very nicely.

kesavapraba
Posts: 348
Joined: Sat Mar 28, 2020 2:25 pm

Re: Spiral hoops in circular column

Post by kesavapraba » Tue Jun 25, 2024 12:57 pm

You are welcome
:: With best wishes ::
Prabakaran Kesavan

Post Reply