Can Automate selection be divided by Grid Line Centre?

There are so many commands of Selection [Sel],such as “sel block , sel volume, sel polsrf” etc.Is it possible to select left sided or right sided objects of the grid line centre,or above or bottom objects of the grid line[C Plane]?

Here is a python script that selects objects on the left side of the Y axis.

#! python 2
import rhinoscriptsyntax as rs
import scriptcontext as sc

# deselect all objects
rs.UnselectAllObjects()

# allow user to select some objects
guids = rs.GetObjects('Select objects')

# get bounding box for each object
# (note: each bounding box is a list of points)
bboxes = []
for guid in guids:
    bbox = rs.BoundingBox(guid)
    bboxes.append(bbox)

# see if each bounding box's points are on left side of Y axis
# and collect the corresponding GUIDs so that those objects can be selected later
# (note: an object on the left side of the Y axis will have an X value less than zero)
good_guids = []
for i in range(len(bboxes)):
    bbox = bboxes[i]
    on_wrong_side = False
    for point in bbox:
        if point[0] >= 0:
            # point is on wrong side of axis
            on_wrong_side = True
            break
    # collect object if not on wrong side of axis
    if not on_wrong_side:
        good_guids.append(guids[i])

# select the "good" objects (the objects that passed the test above)
rs.SelectObjects(good_guids)









1 Like

Thanks a lot

1 Like

Sir, is it possible to select objects on the right side of the Y axis also and how to toggle the selection?

Try this:

import rhinoscriptsyntax as rs

def select_direction():
	point = rs.GetPoint("base point")
	if not point:
		print("Cancel")
		return
	direction = rs.GetPoint("direction", point)
	if not direction:
		print("Cancel")
		return
	
	origin = point
	normal = rs.ViewCPlane().ZAxis
	xaxis = direction - point
	plane = rs.PlaneFromNormal(origin, normal, xaxis)

	rs.SelectObjects([obj for obj in rs.NormalObjects() if rs.BoundingBox(obj, plane, False)[0].X >= 0])

select_direction()

This is showing ,sir.what’s the problem ?

Did the tabs not copy over properly? Here it is with spaces:

import rhinoscriptsyntax as rs

def select_direction():
    point = rs.GetPoint("base point")
    if not point:
        print("Cancel")
        return
    direction = rs.GetPoint("direction", point)
    if not direction:
        print("Cancel")
        return
    
    origin = point
    normal = rs.ViewCPlane().ZAxis
    xaxis = direction - point
    plane = rs.PlaneFromNormal(origin, normal, xaxis)

    rs.SelectObjects([obj for obj in rs.NormalObjects() if rs.BoundingBox(obj, plane, False)[0].X >= 0])

select_direction()