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: 

Python Script - Push Button

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
1092 Views, 6 Replies

Python Script - Push Button

Please bare with me, I'm new to python scripting but have been working with VRED for the last 4 years.

I have set up a Menu with Push Buttons that activate different Variant Sets that I have created. What I would like to do is......When I push one of the buttons, i would like to have the activated Button highlight so I can see which button/variant is active. Is there a command that i could plug in that would make this happen? Any response would be appreciated.

Thanks!
6 REPLIES 6
Message 2 of 7
j.kaestle
in reply to: Anonymous

Hi,

 

define a Material Switch in the Material Editor with the highlighted and the non-highlighted material. Drag & drop it to the Variant Set to the tab "Material" and to the node in the Scenegraph. In the State column you can define which material is shown when selecting the Variant set. So Python is not necessarily required. You can also explore the example here:

https://knowledge.autodesk.com/support/vred-products/learn-explore/caas/simplecontent/content/adding...

 

If you want to controll the Material Variant by script, you must also aplly a material Switch to the Variant Set as described above. Then you can select the Material Variant with the Python command

selectMaterialVariant(name, state)

Name = Name of the Material Switch

State = the Name of the state

 

Regards

Jochen

Message 3 of 7
Anonymous
in reply to: Anonymous

Jochen,

I appreciate your detailed response but I believe the solution isn't for the problem I am trying to solve. The issue is not with a material or variant set. What I want to happen is have the Push Button stay pressed down or highlight or show some sort of indication that would show what Push Button (variant set) is active.

Thanks!
Brandon

Message 4 of 7
Anonymous
in reply to: Anonymous

I will post a sample of the code I have written shortly
Message 5 of 7
j.kaestle
in reply to: Anonymous

I still think I have described what you want. We have created a Menue. I attached a screenshot. The green button is active, the blue one is inactive.

Message 6 of 7
Anonymous
in reply to: Anonymous

Oh, wow! I may have misread your reply. My apologies! I will try and confirm when I get to work. Thank you very much for your reply!
Message 7 of 7
Anonymous
in reply to: Anonymous

Hi

 

just to maybe Add a version which works with Python Buttons:

 

from PythonQt import QtCore, QtGui

def handleButton():
    button.setStyleSheet("background-color: red")

demo = QtGui.QWidget()
demo.setWindowTitle("Demo")


button =  QtGui.QPushButton("TEST")
button.clicked.connect(handleButton)
layout = QtGui.QVBoxLayout(demo)
layout.addWidget(button)

demo.show()

 

Hope that helps, (You would have to write a logic which changes the Background of the Button based on which State it is in)

 

cheers

Klaus

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

Post to forums  

Autodesk Design & Make Report