Forgot password?

Create an account!

Forum

« back

RhinoScript – Layer helper scripts

Messages

Please log in to write a message.

  • 3. ledisnomad (Dec 08, 2009 16.19):

    Hi, Hanno.

    Thanks for the reply. I used the ObjectsByLayer method and it works perfectly. I thought I'd looked for a method like that, but obviously I didn't find it.

    I uploaded the script as well as a second one that is a pseudo-block editing script. A work-around.

    Thanks again,
    Damon

  • 2. Hanno (Dec 08, 2009 09.57):

    Hi!

    You can use a hyphen in order to prevent rhino commands from popping up dialogs: -_SelLayer will let you type the layer as a parameter.
    But there is also a RhinoScript method called ObjectsByLayer that directly gives you all object ids on a layer, so you don't need to use command scripting at all.

    Hope that helps!

    Hanno


    PS: you can of course upload your helper library to RhinoScript.org. I'm sure many people will find it useful!

  • 1. ledisnomad (Dec 07, 2009 20.25):

    I'm trying to create a set of simple helper scripts. The one I'm working on now I want to hide, isolate or make current the layer of the selected object. That is, a user selects and object, starts my command "ByLayer" and has a choice to

    1. Hide all objects on that layer (NOT turn the layer off).
    2. Isolate all objects on that layer (NOT turn off all other layers).
    3. Make that object's layer the current layer.

    I thought it was going to be a 10-minute script: got the thing started, option 3 is one line and works, but I can't get option 1 or 2 to work.

    Here are the functions:

    Function HideObjectLayer(strLayer)

            Call Rhino.UnselectAllObjects() 'first make sure nothing is selected
            Call Rhino.Command("!_SelLayer") 'Rhino command select by layer
           
            Dim arrObjs : arrObjs = Rhino.SelectedObjects()
            Call Rhino.HideObjects(arrObjs)
           
    End Function

    Function IsolateObjectLayer(strLayer)

            Call Rhino.CurrentLayer(strLayer)
            Call Rhino.UnselectAllObjects() 'first make sure nothing is selected
            Call Rhino.Command("'_SelLayer _". strLayer)
            Call Rhino.Command("'_Invert")
           
            Dim arrObjs : arrObjs = Rhino.SelectedObjects()
            Call Rhino.HideObjects(arrObjs)
                           
    End Function

    Function MakeCurrentObjectLayer(strLayer)

            Call Rhino.CurrentLayer(strLayer)
           
    End Function

    The problem is, the

    Call Rhino.Command("!_SelLayer")

    then pops up a dialog box for the user to select a layer, defeating the purpose. Do I have to iterate through all objects to check the layer? What am I missing?

    Any help would be appreciated. Thanks.

Recommend

Why are these buttons gray?