Selecting Curves without User Input

rhinopython

(Zoey) #1

I want to be able to select objects in a layer without the get object command. I realize I can make use of the select object by layer command, but i have more then one curve in the layer. So after i select the objects in the layer, i want to further select just a few of them.
I was hoping to just pick by length or draw a bounding box and list them and then select.
But i have no idea how to do both. I want to do this without having to select the curve myself, trying to automate a small bit in a modelling process. Any help/examples would be greatly appreciated. Preferably in code form, i always understand better that way.


#2

Well, one way to go about this would be to first get the objects on the layer as a general list, then use one or more criteria to filter that list into what you want…

import rhinoscriptsyntax as rs

target_len=100.0
tolerance=1.0
#get a list of all objects on the layer you want
layer_objs=rs.ObjectsByLayer("LayerName")
if layer_objs:
    #create an empty list
    good=[]
    for obj in layer_objs:
        #find curves among the objects
        if rs.IsCurve(obj):
            if abs(rs.CurveLength(obj)-target_len)<tolerance:
                #curve meets selection criteria, append to "good" list
                good.append(obj)
#the object IDs in [good] (if any) will be the curves on specified layer
#that also meet the length criteria within tolerance
print "{} curves found with target length".format(len(good) if good else "No")

(Zoey) #3

Hey Sorry for thelate reply but thank you so so much :smile: definitely helped me out at work :slight_smile: