Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.
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
Solved! Go to 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.
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
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()
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?
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:
feels a little faster ... i have no idea if you can use images in the button ..
Can't find what you're looking for? Ask the community or share your knowledge.