how to set paint type or chrome type via python script

how to set paint type or chrome type via python script

nexzhou
Participant Participant
663 Views
4 Replies
Message 1 of 5

how to set paint type or chrome type via python script

nexzhou
Participant
Participant

i'm working on python script on vred, try to set paint type on UMetallicPaintMaterial, or chrome type on UChromeMaterial, via python script,

 

nd = findNode("chrome")
fds = nd.getMaterial().fields()
fds.setString("chromeType","highlyReflective")

nd = findNode("paint")
fds = nd.getMaterial().fields()
fds.setString("paintType","2-coat")

but script does not work with error:

 

vrFieldAccess::setField: Couldn't find field 'chromeType'

vrFieldAccess::setField: Couldn't find field 'paintType'

how to set paint type or chrome type via python script, is there any documentation of python api on setting chromeType or paintType , or shows chromeType or paintType parameters 

 

need help for this question, thanks.

0 Likes
664 Views
4 Replies
Replies (4)
Message 2 of 5

marcus_fritzen
Autodesk
Autodesk

There is no real documentation for all the fields of each material. However, you can use the node editor to figure out which field to set and additionally the type of the field (tooltip when the mouse is over the value in the node editor). In your case:

 

# Chrome type
mat = findMaterial("Chrome")
mat.fields().setInt32("metalType",4)

# Paint type
mat = findMaterial("Paint")
mat.fields().setInt32("paintType",1)

Cheers,

Marcus

 



Marcus Fritzen
Principal Engineer
0 Likes
Message 3 of 5

nexzhou
Participant
Participant

Thanks a lot, 

and I tried more to set chome "use roughness" to true with script below:

# chrome matte, set useRoughness ?
mat = findMaterial("chrome-matte")
mat.fields().setBool("useRoughness",True)

ends with error 

error vrFieldAccess::setField: Couldn't find field 'useRoughness'

need help for this issue.

and if there is some documentation of python api on the things like these, that would be much better...

0 Likes
Message 4 of 5

sinje_thiedemann
Autodesk
Autodesk

Hi,

as Marcus has written, instead of documentation we have the Node Editor (a module in the GUI, Scene > Node Editor) where you can see all fields of a selected object. For materials, drag & drop them from the Material Editor into the module.

In this case, it is "isRough".

Kind regards

Sinje

NodeEditor_Chrome.png

 

0 Likes
Message 5 of 5

nexzhou
Participant
Participant
thanks a lot. that is very helpful
0 Likes