Preselection with -_SelLayer _Pick

Hi All,

I have an object preselected. Then I do:
-_SelLayer _Pick
My previously selected object is still selected.
I hit enter.

The selection does not change. I still have the initially selected object selected, but no other objects of the layer got selected. If I select the object inside the command, the other objects of the layer get selected as expected.

I would like the preselected object being used for the -_SelLayer _Pick. Can I adjust the macro to do so or is this not possible?

Thanks

Seems like this may not be possible - looks like a bug or an oversight…

Here is both a VB rhinoscript and a Python script (in case you’re on Mac) that do what you want…

–Mitch

Option Explicit

Call SelLayerEx()
Sub SelLayerEx()
    Dim objs, obj
    Rhino.UnselectAllObjects()
    objs = Rhino.GetObjects("Select objects",,, True)
    If Not IsArray(objs) Then Exit Sub
    Call Rhino.EnableRedraw(False)
    For Each obj In objs
        Call Rhino.ObjectsByLayer(Rhino.ObjectLayer(obj), True)
    Next
    Call Rhino.EnableRedraw(True)
End Sub
import rhinoscriptsyntax as rs

def SelLayerEx():
    rs.UnselectAllObjects()
    objs = rs.GetObjects("Select objects",preselect=True)
    if not objs: return
    rs.EnableRedraw(False)
    for obj in objs:
        rs.ObjectsByLayer(rs.ObjectLayer(obj), True)
SelLayerEx()

Hi Mitch, awesome. Many thanks for the scripts!

Mitch,

I made your script into a Rhinopython command within a plugin. Lets assume the command is called MitchSelLayer. I use it as follows in a macro:

_MitchSelLayer _Pause _Invert _Hide

Problem is, the macro does not stop at the _Pause, but hides all objects in the document. It does not seem to wait for the script to complete.

Any ideas?

Thanks

I don’t know - I’ve never used scripts in that way… I just have a tendency to integrate all the functions in the script itself. So you are trying to hide all other objects except those on selected layers? That’s just another couple of lines in the script. --Mitch

import rhinoscriptsyntax as rs

def SelLayerInvHide():
    rs.UnselectAllObjects()
    objs = rs.GetObjects("Select objects",preselect=True)
    if not objs: return
    rs.EnableRedraw(False)
    for obj in objs:
        rs.ObjectsByLayer(rs.ObjectLayer(obj), True)
    toHide=rs.InvertSelectedObjects()
    if toHide: rs.HideObjects(toHide)
SelLayerInvHide()

Thanks a lot for adding to the script. I was starting to like macros to make quick aliases. I would have used the MitchSelLayer in around 8 macros. I think I have to go back to scripting due to the limitations of macros to work in combination with scripts.

Hi Mitch, Silvano - this is probably by design, since it allows you to add specific layers’ objects to your current selection - I guess, absent another command line option, the right way is a matter of context- hard to win.

http://mcneel.myjetbrains.com/youtrack/issue/RH-30433

-Pascal