What's the python comand toswitch to a certain item of a switchnode?

Anonymous

What's the python comand toswitch to a certain item of a switchnode?

Anonymous
Not applicable

What's the python comand toswitch to a certain item of a switchnode?

 

e.g. switch to the 3rd item "255_40_9.0x20" of node "***Tire***"

 

switch.JPG

0 Likes
Reply
Accepted solutions (1)
739 Views
3 Replies
Replies (3)

richardlevene
Collaborator
Collaborator

I do not know all the possibilities with the python in vred (I am sure one of the devs can help better) but I know for sure you can just create variantSets  for each tire option to be visible then just use selectVariantSet command to select the variantSet that shows the tire you desire.

 

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)

There is a vrSwitch python node but the example in the python docs doesn't seem to show you can explicitly call a particular option within a switch. Just toggle. Probably doable though but beyond my level now.

 

Richard

0 Likes

dlincol1
Advocate
Advocate
Accepted solution

s = findNode('***Tire***')

s.fields().setInt32("choice", 2)

 

The first child of a switch is 0, so 2 is item 3 from your example.

Open the Node Editor for a Switchnode to see the choice attribute.

Regards,
Dan

Anonymous
Not applicable

Super!

 

That works perfect!

0 Likes