Slowly picking up RhinoPython, like again…Really appreciate for the help!
it is a basic question while trying to read the McNeel tutorial, about the “Conditional Evaluation - if”:
import rhinoscriptsyntax as rs
somenumber = rs.GetReal(“Line length”)
line = rs.AddLine( (0,0,0), (somenumber,0,0) )
if line is None:
print(“Something went wrong”)
else:
print(“Line curve inserted with id”, line)
Question: if I type in “0”, it will stop immediately after line 3 with the traceback “Unable to add line to document”,
ASK:
Is there a way for me to bypass this “null” data, and keep going to the “if” statement.
I would run it this way. The AddLine function is failing with a 0 length line. So this will protect against that.
import rhinoscriptsyntax as rs
somenumber = rs.GetReal("Line length")
if somenumber != 0:
line = rs.AddLine( (0,0,0), (somenumber,0,0) )
print("Line curve inserted with id", line)
else:
print("Something went wrong")
Probably should mension that using rhinocommon allows a different logic, in that the line is created before adding it to the document. This is effective in grasshopper: