SelBoundary RVB Script to PY Help

I have a script @Helvetosaur kindly made for me that would be awesome if someone could help me with a python version.

It takes a picked curve and selects any curves inside and groups them with the picked curve.

Option Explicit
'Script by Mitch Heynick
'Version Wednesday, 10 November, 2010

'Call SelBoundaryForRyan()
Sub SelBoundaryForRyan()
	Dim arrSel,arrObjs,strGroup,msg,strBC
	arrSel=Rhino.SelectedObjects
	msg="Select closed curve to use as a selection boundary within the viewport"
	strBC = Rhino.GetObject(msg, 4,, True)	
	If IsNull(strBC) Then Exit Sub
	Call Rhino.EnableRedraw(False)
	Call Rhino.UnselectAllObjects

	Call Rhino.Command("_SelBoundary _SelectionMode=_Window _SelID "&strBC,False)
	arrObjs=Rhino.SelectedObjects
	
	If IsArray(arrObjs) Then
		strGroup=Rhino.AddGroup
		Call Rhino.AddObjectsToGroup(arrObjs,strGroup)
		Call Rhino.AddObjectToGroup(strBC,strGroup)
		Call Rhino.ObjectsByGroup(strGroup,True)
		If IsArray(arrSel) Then Call Rhino.SelectObjects(arrSel)
	End If
	Call Rhino.EnableRedraw(True)
End Sub

Here you go @kleerkoat.

def SelBoundForRyan():
    msg = "Select closed curve to use as selection boundary within the viewport"
    bound = rs.GetObject(msg, 4, True)
    if not bound: return 

    rs.EnableRedraw(False)

    rs.Command("_SelBoundary selid " + str(bound) + " _Enter", False)
    objs = rs.SelectedObjects()
    rs.UnselectAllObjects()

    if objs:
        group = rs.AddGroup()

        # Uncomment below to select just curves
        # res = [c for c in objs if rs.IsCurve(c)]
        # objs = res

        rs.AddObjectsToGroup(objs, group)
        rs.AddObjectToGroup(bound, group)
        rs.ObjectsByGroup(group, True)

    rs.EnableRedraw(True)

SelBoundForRyan()
1 Like

time to compare so I can learn from your help!

thank you so much!

1 Like