#!/usr/bin/env python
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
import math
geompy = geomBuilder.New()
# ------------------------------------------------------------
# Golden Spiral Parameters
# ------------------------------------------------------------
TURNS = 3.0 # Number of turns
R0 = 1000.0 # Initial radius
NPTS = 500 # Number of sample points
phi = (1 + math.sqrt(5)) / 2
b = (2 * math.log(phi)) / math.pi
# ------------------------------------------------------------
# Generate points along the spiral
# ------------------------------------------------------------
points = []
t_max = 2 * math.pi * TURNS
for i in range(NPTS):
t = t_max * i / (NPTS - 1)
r = R0 * math.exp(b * t)
x = r * math.cos(t)
y = r * math.sin(t)
z = 0.0
p = geompy.MakeVertex(x, y, z)
points.append(p)
# ------------------------------------------------------------
# Create polyline curve through the points
# ------------------------------------------------------------
spiral_curve = geompy.MakePolyline(points)
# ------------------------------------------------------------
# Add to study and update browser
# ------------------------------------------------------------
geompy.addToStudy(spiral_curve, "Golden_Spiral")
if salome.sg.hasDesktop():
salome.sg.updateObjBrowser()
So far this script seems to run however nothing seems to show up in the drawing area when I have the geometry dashboard selected and am looking from “top view”….
What went wrong with the creation of the golden spiral?