Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5816

GetObject with toggle option in menu

$
0
0

@siemen wrote:

Hi guys, I’m stuck here. Trying to create a custom getobject with a toggle option. The toggle option should be flipable forever until I select an object. When I select a single object I want to check in which state that toggle option is and depending on that call the function belonging to that option using the selected object.

After calling the function I want it to return back to the getobject menu with the toggle option.
This repeats until I press Enter or Esc to exit the command.

Anybody that can help out here? I’ve had a look this old topic but I couldn’t solve it based on that.

import Rhino

def Option1(obj):
    print "Do this to obj"
    GetObjectOption()

def Option2(obj):
    print "Do that to obj"
    GetObjectOption()

def GetObjectOption():
    go = Rhino.Input.Custom.GetObject()
    go.SetCommandPrompt("Select object")
    
    go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve
    
    option = Rhino.Input.Custom.OptionToggle(True,"Option1","Option2")
    go.AddOptionToggle("Mode",option)
    
    go.Get()
    
    
    if I select an object while Option1 is activated:
        Option1(obj)
    
    elif I select an object while option2 is activated:
        Option2(obj)
    
    elif I press ESC or Enter:
        return

GetObjectOption()

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5816

Trending Articles