Working with vrMenu

Anonymous

Working with vrMenu

Anonymous
Not applicable

Hi,

 

I've tried for hours now to create a menu for my vred-scene using vrMenu. I failed 😞 The online help for this modul is not really helpful and even the example doesn't work in Vred 2017 SP1.

 

Are there any better examples or working scripts, that I could us as basis?

 

Thanks a lot!

 

Kind regards, Clemens

0 Likes
Reply
Accepted solutions (1)
1,092 Views
7 Replies
Replies (7)

Anonymous
Not applicable
Accepted solution

Have you looked at the menu_2D.py file in the examples folder? I'm on 2017.2 on OSX and this is working for me:

 

def hello():
    print "Hello World!"

menu1 = vrMenu(2, 1, 1)
menu1.setPosition2D(10,10)
menu1.addLabel("<font color=red>Menu</font>")
menu1.addCheckBox("Show statistics", "showStatistic(item_state)")
menu1.addPushButton("Hello World", "hello()")
menu1.setAlpha(1)
menu1.show()

It for a simple 2D overlay menu that should give you the basic idea.

0 Likes

Anonymous
Not applicable

Hi Stefan,

 

great, this gives me a good idea - thank you!

 

I've got a further question: I tried to activate a variantset with a push-button, but I received a syntax error (invalid syntax). Here is the line:

 

menu1.addPushButton("Vset01", "getVariantSet(Vset01)")

 Does anyone have an idea, what could be wrong with that?

 

Thanks! kind regards, Clemens

0 Likes

Anonymous
Not applicable

Hi Clemens,

 

the error you get is a name error, that means that python does not recognize VSet01. No Variable in your code is named like this.

 

The function you are calling expects the name of the variant set as a string variable. That means you'll have to wrap it in quotes. Since the command itself is already wrapped in quotes you can either escape them or just use single quotes. the command you are using however will only return a variantset, not activate it. try activateCapturedVariantSet() .. see the code and the screenshot below for reference.

 

menu1 = vrMenu(2, 1, 1)
menu1.setPosition2D(10,10)
menu1.addLabel("<font color=red>Menu</font>")
menu1.addPushButton("Variant 1", "activateCapturedVariantSet('variant1')")
menu1.addPushButton("Variant 2", "activateCapturedVariantSet('variant2')")
menu1.setAlpha(1)
menu1.show()

Bildschirmfoto 2017-02-20 um 11.52.35.png

Anonymous
Not applicable

Hi,

 

great, that worked very well!Thank you!

 

The only problem is, if I switch the car via the menu, it take minutes to see the variants. If i switch the car within the variant set window, it changes immediately.

 

Seems Vred is checking the variantsets everytime again? Did you ever ran into this behaviour, too?

0 Likes

Anonymous
Not applicable

And another question 🙂 Is it somehow possible to replace the push buttons with images?

0 Likes

Anonymous
Not applicable

You can try this one:

 

menu1 = vrMenu(2, 1, 1)
menu1.setPosition2D(10,10)
menu1.addLabel("<font color=red>Menu</font>")
menu1.addPushButton("Variant 1", "selectVariantSet('v1',True)")
menu1.addPushButton("Variant 2", "selectVariantSet('v2',True)")
menu1.setAlpha(1)
menu1.show()

The reference says the following:

  • selectVariantSet(name, excludeViewpoint)

    Activates a variant set. The variant set will activate all states of its defined node and material variants.
    Parameters:
    name - The name of the variant set.
               (type=string)
    excludeViewpoint - exclude viewpoint from this variant set.
               (type=bool)

feels a little faster ... i have no idea if you can use images in the button ..

0 Likes

Anonymous
Not applicable

Hi again,

 

great! This works perfect now - thank you! Smiley Happy

0 Likes