hey so i try to run this code but get always an error, the code is below and i tried changing line 24 to something else like : radians = angle * math.pi / 180 or import math then radians = math.radians(angle) but none of it works, i also tried in both rhino 7 and 8 same error:
import Rhino
import rhinoscriptsyntax as rs
Define circle parameters
radius = 5.0 # meters
num_pillars = 10
Calculate angular spacing
angle_spacing = 360.0 / num_pillars
Function to create a pillar object at a specific location
def create_pillar(x, y, height):
pt = Rhino.Geometry.Point3d(x, y, 0.0)
circle = Rhino.Geometry.Circle(pt, radius)
cylinder = Rhino.Geometry.Cylinder(circle, height)
rs.AddObject(cylinder)
Loop to place pillars
for i in range(num_pillars):
# Calculate angle for current pillar position
angle = i * angle_spacing
# Convert angle to radians for trigonometric functions
radians = Rhino.Geometry.DegreesToRadians(angle)
# Calculate x and y coordinates based on radius and angle
x = radius * math.cos(radians)
y = radius * math.sin(radians)
# Create the pillar object
create_pillar(x, y, 2.0) # Adjust height as needed
Print completion message
print(“Created”, num_pillars, “pillars in a circular arrangement.”)
This might help (not how I would go about this, just trying to patch your code).
import Rhino
import math
cylinders = []
# Define circle parameters
radius = 5.0 # meters
num_pillars = 10
# Calculate angular spacing
angle_spacing = 360.0 / num_pillars
# Function to create a pillar object at a specific location
def create_pillar(x, y, height):
pt = Rhino.Geometry.Point3d(x, y, 0.0)
circle = Rhino.Geometry.Circle(pt, radius)
cylinder = Rhino.Geometry.Cylinder(circle, height)
cylinders.Add(cylinder)
# Loop to place pillars
for i in range(num_pillars):
# Calculate angle for current pillar position
angle = i * angle_spacing
# Convert angle to radians for trigonometric functions
radians = Rhino.RhinoMath.ToRadians(angle)
# Calculate x and y coordinates based on radius and angle
x = radius * math.cos(radians)
y = radius * math.sin(radians)
# Create the pillar object
create_pillar(x, y, 2.0) # Adjust height as needed
a = cylinders