Forgot password?

Create an account!

Forum

« back

RhinoScript – Why Doesn't ObjectsByLayer work on Meshes in Rhino5?

Messages

Please log in to write a message.

  • 1. TylerW (Oct 31, 2012 21.33):

    I've been working on a simple script in Rhino5 that should go through and join all meshes in the same childlayer, however, I've found putting all the meshes in a layer into an array to be hard. I've been using the "ObjectsByLayer" method, but it doesn't seem to work on arrays. The following code tries to put meshes (after clicking on a mesh object that is one of many in a childlayer) into an array "arrObjects" using the ObjectsByLayer method, and it returns information on if the array was formed correctly. My questions are (1) is there an easier way of joining meshes by sublayer (without going through each and clicking the "join" tool), and/or (2) is there a way of putting all the meshes in a given sublayer into an array (that can later be used to join). Thanks!

    Call Main()
    Sub Main()
    Dim arrObjects, strObject, strLayer

    strObject = Rhino.GetObject("Pick any object")

    If Not IsNull(strObject) Then

                    strLayer = Rhino.ObjectLayer(strObject)
                    arrObjects = Rhino.ObjectsByLayer(strLayer, True)
                   
            End If
           
            Rhino.Print"arrObjects dimmed = " & IsArrayDimmed(arrObjects)
    End Sub
           
           
           
    Function IsArrayDimmed(arr)
            IsArrayDimmed = False
            If IsArray(arr) Then
                    On Error Resume Next
                    Dim ub : ub = UBound(arr)
                    If (Err.Number = 0) And (ub >= 0) Then IsArrayDimmed = True
            End If  
    End Function
Recommend

Why are these buttons gray?