 Script from tutorial generated 51 "bad objects"

I was trying to figure out how to write a script to help draw the first 180 degrees of a sine wave from, 90 through 270 degrees, when I searched YouTube for Rhino Python tutorials. I found a series by Jose Sanchez and worked through them all but have no idea whats causing the Check New Objects dialog box to appear.

Rhino file from Tutorial 12:
https://1drv.ms/u/s!AvbRThajlgqAhhhyBt3g4hE0FyHB

Python script from Tutorial 12 (may be a typo on my part):
https://1drv.ms/u/s!AvbRThajlgqAhhlBZggY2vGsOc13

On the original idea, here’s something similar to what I was trying to learn how to script when I started viewing Jose Sanchez’s tutorials:

https://1drv.ms/i/s!AvbRThajlgqAhhouWkRu7IsNxKvN

Any ideas? Thanks.

David

Here is a quick sample to plot the points:

import rhinoscriptsyntax as rs
import math

deg = 90.0
max_deg = 270.0
amp = 50.0
x = 0.0
while (deg <= max_deg):
deg += 1.0
x += 1.0

If you want a smooth curve, I’d push the points into the rs.AddInterpCurve method. Check the Rhino.Python help file for details.

– Dale

1 Like

Dale, thank you. That helps.
David

Awesome! I did some superficial testing on the code, below. It seems to do what I wanted, although I’ve got the nagging suspicion I’ve got some redundant steps in the math that could be eliminated.

• There are two identical ducts mirrored about the X-Y plane (only one is shown in the .3dm file at the link provided).

• Adjust points of sine wave vertically by half of duct separator wall thickness
by subtracting half of duct separator wall thickness.

• When the points are generated, generate an interpolated curve through the points
then mirror the curve about the X-axis. Surface > Revolve those curves about the vertical axis.

import rhinoscriptsyntax as rs
from math import *

dblStartDeg = 90.0
dblEndDeg = 270.0

dblXStart = rs.GetReal('Enter desired x-position at top of sine wave: ', 6.20)
dblXEnd = rs.GetReal('Enter desired x-position at bottom of sine wave: ', 9.20)
dblXStep = rs.GetReal('Entere desired step value for x-position of sine wave: ', 0.1)
dblAmp = rs.GetReal('Enter desired y-position (amplitude) at top of sine wave: ', 1.387)
dblWallThknss = rs.GetReal('Enter material thickness of Duct Mid-section separator wall: ', 0.03125)

\# y-coordinate of wave at peak of wave, e.g. at beginning of curve

dblYCoordAtPeakOfWave = dblAmp - dblWallThknss / 2

dblDegStep = (dblEndDeg - dblStartDeg) / ((dblXEnd - dblXStart) / dblXStep)

dblDeg = dblStartDeg
dblX = dblXStart

SineCurveList = []
while (dblDeg <= dblEndDeg):
# y-coordinate of wave at distance from datum (vertical axis) minus half of duct separator wall thickness

dblYCoordTranslatedUp = dblYCoordAtPeakOfWave + dblYCoordAtDistFrDatum

dblYCoordDividedBy2 = dblYCoordTranslatedUp / 2

# move the curve up by half the duct separator wall thickness
dblYCoordUpByHalfWallThickness = dblYCoordDividedBy2 + dblWallThknss / 2

dblNextPoint = [dblX, 0.0, dblYCoordUpByHalfWallThickness]
SineCurveList.append([dblX,0.0,dblYCoordUpByHalfWallThickness])
dblDeg += dblDegStep
dblX += dblXStep
# per Dale Fugier: "...I'd push the points into the rs.AddInterpCurve
# method..."