algorithmic modeling for Rhino
Tags:
It's probably something simple, not a bug.
What are your inputs and what error do you get?
No inputs? So what does x stand for? or y or z in that respect. What kind of data do you have? Is x a list
x =[]
or
x = None
can you post the file?
either way you can use the following,
#check for inputs
if x is None:
x=0.0
print("there is no x input --> use 0.0 instead")
if y is None:
y=0.0
print("there is no y input --> use 0.0 instead")
if z is None:
z=0.0
print("there is no z input --> use 0.0 instead")#outputs
X=x
Y=y
Z=z
Best,
M.
If you write this line in code:
'If not x:'
python will attempt to convert 'x' into a True or False value. In order to do this, x must be set to some value, such as `None`, `False`, '0.0', an empty list '[]' (all of which would be evaluated as 'False'), or 'x' could be a number, a piece of text, a Point3d, whatever.
The important thing here is that you must set a variable to some value (it can be any value, including 'None') before you can use it. If 'x' is not one of the inputs to your script, then you must set 'x' to some value within your script, before you evaluate it with the line 'if not x:'.
try this:
print x # this will show you the value contained in x
print type( x) # this will show you what kind of data is in x
Also, you should always post the error you receive. It makes it much easier for others to help you.
Thanks for help. I tested against 'None' and it works as expected. Much better than the way I was doing it.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by