Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5793

Wouldn't it be nice if

$
0
0

…the rs.Add… methods returned None if the method was unable to add a valid object to the document instead of simply failing and erroring out the script? That way you could at least error check the return instead of having to analyze all the input arguments first to see if they will allow a valid result.

This applies to AddLine, AddCircle, AddEllipse, AddArc, etc.

Please note also that the equivalent VB Rhinoscript methods all simply return Null if the function is unable to work with the input, and do not error out the script. @dale

For example, trying to add a zero-length line:

import rhinoscriptsyntax as rs
test=rs.AddLine([0,0,0],[0,0,0])

>>>Message: Unable to add line to document (entire script fails at that point)

vs

Option Explicit
Call Main()
Sub Main()
	Dim test
	test = Rhino.AddLine(Array(0, 0, 0), Array(0, 0, 0))
	If IsNull(test) Then
		Call Rhino.Print("It's Null")
	End If
End Sub

>>> It's Null

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5793

Trending Articles