Python Script - Push Button

Python Script - Push Button

Anonymous
Not applicable
1,628 Views
6 Replies
Message 1 of 7

Python Script - Push Button

Anonymous
Not applicable
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!
0 Likes
1,629 Views
6 Replies
Replies (6)
Message 2 of 7

j.kaestle
Enthusiast
Enthusiast

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

0 Likes
Message 3 of 7

Anonymous
Not applicable
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

0 Likes
Message 4 of 7

Anonymous
Not applicable
I will post a sample of the code I have written shortly
0 Likes
Message 5 of 7

j.kaestle
Enthusiast
Enthusiast

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.

0 Likes
Message 6 of 7

Anonymous
Not applicable
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!
0 Likes
Message 7 of 7

Anonymous
Not applicable

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

0 Likes