import rhinoscriptsyntax as rs import random as ran rs.DeleteObjects(rs.AllObjects()) # Parameters for the spiral start_point = rs.AddPoint(0, 0, 0) # Starting point of the spiral length = 10 # Length of the first segment distance = 2 # Distance by which each step grows height = 5 # Height increase for each level corner = 20 # Number of corners for the spiral points = [start_point] # Loop to create the square spiral for i in range(corner): last_point = points[-1] # Get the last point of the spiral x, y, z = rs.PointCoordinates(last_point) # Calculate the new point based on the current direction (right or up) if i % 4 == 0: # Move right (first direction) x += length elif i % 4 == 1: # Move up (second direction) y += length elif i % 4 == 2: # Move left (third direction) x -= length elif i % 4 == 3: # Move down (fourth direction) y -= length # Add the new point and increase the Z-coordinate for height new_point = rs.AddPoint(x, y, z + height) # Increase height each time points.append(new_point) # Increase the length for the next step and adjust for the next spiral turn length += distance # Create a polyline from the points to visualize the spiral rs.AddPolyline(points)