Hello, I student of computational design so I still practicing Python in rhino so I have some questions about coding.
from picture If x == 10 I wanna to print sin interpcurve else not 10 print sin points. How to code this condition? thank you
Hello, I student of computational design so I still practicing Python in rhino so I have some questions about coding.
Hi,
I’m not exactly sure what it is that you want to do, but the code on lines 16 to 20 - currently commented out - should do the trick. On line 18, get rid of the space between print
and (new_curve)
. print
in Python 3 is a function, thus the parentheses.
You can’t compute and thus print the sine of an interpolated curve or list or points. math.sin()
excepts a floating point or integer number, representing an angle in radians.
What exactly is x? Where does it come into play? Is it a number, a list of something?
Something like this?
import rhinoscriptsyntax as rs
import math
points = []
scale = 1.5
for i in range(100):
pt = ([scale * math.sin(i), i, 0])
points.append(pt)
x = 10
if x == 10:
[rs.AddPoint(pt) for pt in points]
else:
rs.AddInterpCurve(points)
It would probably be a good idea to make x
a boolean (True/False), instead of 10, since you only seem to want to switch between two cases.
Example:
import rhinoscriptsyntax as rs
import math
points = []
scale = 1.5
for i in range(100):
pt = ([scale * math.sin(i), i, 0])
points.append(pt)
bake_curve = False
if not bake_curve:
[rs.AddPoint(pt) for pt in points]
else:
rs.AddInterpCurve(points)