Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Community
VRED Forum
Welcome to Autodesk’s VRED Forums. Share your knowledge, ask questions, and explore popular VRED topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Working with vrMenu

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
1052 Views, 7 Replies

Working with vrMenu

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

Tags (3)
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

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.

Message 3 of 8
Anonymous
in reply to: Anonymous

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

Message 4 of 8
Anonymous
in reply to: Anonymous

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

Message 5 of 8
Anonymous
in reply to: Anonymous

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?

Message 6 of 8
Anonymous
in reply to: Anonymous

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

Message 7 of 8
Anonymous
in reply to: Anonymous

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 ..

Message 8 of 8
Anonymous
in reply to: Anonymous

Hi again,

 

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report