Scripting SelBox and SelVolumeSphere

So, I’m trying to script selection of grips to make it easier to replicate a bug I’ve got in my own code.

If I type

-SelVoumeSphere 0 4

into the Rhino window, I get the expected selection.

However, if I paste the same string, the command runs, I see the arguments in the command history as expected, and it exits with no error message, but nothing is selected.

I’m seeing the same behavior for -SelBox

Any ideas?

Hi Tom,

This Python script seem to to work for me.

import rhinoscriptsyntax as rs
rs.Command("_SelVolumeSphere 0 4", True)

So does this:

import rhinoscriptsyntax as rs
rs.Command("_SelBox 0,0,0 5,0,0 5,5,0 5,5,5", True)

If you are trying to script these commands from a plug-in, see the following.

Hi Dale,

In Rhino 4 I used to be able to copy a macro (from notepad or something), give focus to Rhino, and ctrl-v to execute the macro. That’s what I was having trouble with. I ended up making a toolbar button, and it works there.

Thanks,
Tom

Hi Dale,
I am using SelBox function in my python script. However, I dont know how to set
the selection mode (Window , Crossing etc.). It would be great if you can also give some insights
how to embed function modes in command string for different functions.

The code is below

Area_with = 1000;
Area_length = 1000;
Area_height = 1000;

FirstCor = rs.GetPoint(“Start Volume”);
SecCor = [FirstCor[0]+ Area_with, FirstCor[1], FirstCor[2] ]
ThirdCor = [FirstCor[0]+ Area_with, FirstCor[1]+ Area_length, 0 ];
TopCor = [FirstCor[0]+ Area_with, FirstCor[1]+ Area_length,
FirstCor[2] + Area_height ];

Str_o = str(FirstCor[0]) +’,’+ str(FirstCor[1]) +’,’+ str(FirstCor[2]);
Str_y = str(SecCor[0]) +’,’+ str(SecCor[1]) +’,’+ str(SecCor[2]);
Str_xy = str(ThirdCor[0])+’,’+ str(ThirdCor[1])+’,’+str(ThirdCor[2]);
Str_xyz = str(TopCor[0])+ ‘,’+str(TopCor[1])+ ‘,’+ str(TopCor[2]);

string = ‘_SelBox’ + ’ ’ + Str_o + ’ ’ + Str_y + ’ ’ \

  • Str_xy + ’ ’ + Str_xyz

rs.Command(string,True);

Hi @celebihaluk36,

Does this help?

import Rhino

def test_sel_box():
    rc, box = Rhino.Input.RhinoGet.GetBox()
    if rc == Rhino.Commands.Result.Success:
        corners = box.GetCorners()
        p0 = corners[0].ToString()
        p1 = corners[1].ToString()
        p3 = corners[3].ToString()
        p4 = corners[4].ToString()
        cmd = '_SelBox {0} {1} {2} {3}'.format(p0, p1, p3, p4)
        Rhino.RhinoApp.RunScript(cmd, True)

test_sel_box()

– Dale

Hi Dale,
Thank you for the reply. I run the code it works fine for Window selection.

When I type the command SelBox on Rhino terminal. It asks me to choose
the selection mode (i.e. Selection Mode (Window, Crossing, InvertWindow InvertCrosing) )
However, I don`t know how to put the selection mode into scripting.

Like this:

cmd = '_SelBox _SelectionMode=_Window {0} {1} {2} {3}'.format(p0, p1, p3, p4)

– Dale

thanks it works now