Cannot get MultiListBox to work


#1

Trying out various input boxes using a script. Cannot get past error using MultiListBox. Other 2 box input routines I try work fine. What am I missing?

Here is error:

Message: 'type' object has no attribute 'ShowMultiListBox'

Traceback:
  line 1005, in MultiListBox, "/Applications/RhinoWIP.app/Contents/Resources/ManagedPlugIns/RhinoDLR_Python.rhp/RssLib/rhinoscript/userinterface.py"
  line 19, in <module>, "/Users/.../Library/Application Support/McNeel/Rhinoceros/Scripts/Foils/testinput.py"

Here is testinput.py script I am using:

import rhinoscriptsyntax as rs
#
layers = rs.LayerNames()
if layers:
    layer = rs.ComboListBox(layers, "Select current layer")
if layer: rs.CurrentLayer(layer)
#
layers = rs.LayerNames()
if layers:
    items  = [(layer, rs.IsLayerOn(layer)) for layer in layers]
    results  = rs.CheckListBox(items, "Turn layers on/off", "Layers")
    if results:
        for layer, state in results: rs.LayerVisible(layer, state)
#
layers = rs.LayerNames()
print("Layers: ",layers)
if layers:
    print("Layers: ",layers)
    layer = rs.MultiListBox(layers, "Layers to lock", "Layer Menu")
    if layer:
        for layer in layers:
            rs.LayerLocked(layer, True)

(Pascal Golay) #2

Hi Matt - your variable ‘layer’ is a list of selected items in the multi list box - you should be iterating ‘layer’ not ‘layers’ which is the entire set of layers in the file.

for item in layer:
    rs.LayerLocked(item, True)

To get a little fancy, you might exclude the current layer from the list of layers that show up in the MultiListBox, since it cannot be locked and will show an error message if the user selects it in your list.

-Pascal


#3

Thank you for your reply.

I think I understand what you wrote, but I still get the same “object has no attribute” error in the call to the MultiListBox (a couple lines before what you comment on). I am not sure where to look next. Also started to add some logic to capture and exclude the current layer, as you suggest. Not sure how that will work yet, but I am still hung up on the MultiListBox call.

Current script:

import rhinoscriptsyntax as rs


(Pascal Golay) #4

Oh, OK - I’m on Windows at the moment and your script runs OK here - I’ll test it on the Mac as well.

-Pascal


#5

Looking into this a little further, I suspect the ShowMultiListBox module is not found on the Mac, or not in the right place, or something like that?


(Pascal Golay) #6

Hi Matt - I see the error on mac - it’s hard to debug on the mac but my guess of the moment is that there is an error in that support file ( userinterface.py) - the import statements at the top, are, possibly, incorrect - I’ll check with the bigger brains.

https://mcneel.myjetbrains.com/youtrack/issue/RH-37573

-Pascal