Comment on page
Insulation automatic drafter
To automate the drawing of zigzag-shaped insulation
This script is written in Python and uses the rhinoscriptsyntax library. It allows the user to select a rectangle in Rhino and creates a polyline that follows a zigzag pattern. The zigzag pattern is inscribed in the rectangle and its wave size is equal to the zigzag's pattern side size.
- Inscribes a zigzag pattern in a rectangle
- Wave size of the zigzag pattern is equal to the zigzag's pattern side size
- The script works with both horizontal and vertical rectangles
- 1.Make sure you have Rhino and RhinoPython installed
- 2.Download the script
- 3.Open Rhino and use the
RunPythonScript
command to load the script - 4.Select a rectangle
- 5.The script will create a zigzag pattern inscribed in the rectangle
- 1.The script starts by asking the user to select a rectangle in Rhino
- 2.The script gets the bounding box of the selected rectangle and calculates the width and height
- 3.The script calculates the zigzag pattern side by getting the smaller side of the rectangle and applying some math operations
- 4.The script checks if the rectangle is horizontal or vertical and creates the polyline points accordingly
- 5.The script creates a polyline that passes through all the points
- Rhino
- rhinoscriptsyntax library (included in Rhino)
- The script won't work on rotated rectangles that are not strictly horizontal or vertical
import rhinoscriptsyntax as rs
# Create an empty list to store the points
points = []
# Ask the user to select a rectangle
rectangle = rs.GetObject("Select a rectangle")
if rectangle is None: exit()
# Get the bounding box of the rectangle
bbox = rs.BoundingBox(rectangle)
# Get the width and height of the bounding box
width = rs.Distance(bbox[0], bbox[1])
height = rs.Distance(bbox[0], bbox[3])
# Get the smaller side of the rectangle
zigzag_side = (min(width, height) / 0.866025403) / 2
# Check if the rectangle is horizontal or vertical
if width > height:
# Rectangle is horizontal
for i in range(int((width+zigzag_side)/zigzag_side + 1)):
x = bbox[0][0] + i * zigzag_side
y = bbox[0][1] + (i % 2) * height
points.append((x, y, 0))
else:
# Rectangle is vertical
for i in range(int((height+zigzag_side)/zigzag_side + 1)):
x = bbox[0][0] + (i % 2) * width
y = bbox[0][1] + i * zigzag_side
points.append((x, y, 0))
# Draw a line that passes through all the points
rs.AddPolyline(points)
Last modified 10mo ago