Hello,
Is there a way to get the diffuse color of standard_surface with python ?
I have tried in a python node :
matlist = doc.GetMaterials() mat = doc.SearchMaterial("AR Tire Sculpture (Ford A)") print mat[c4d.MATERIAL_COLOR_COLOR]
But I get none, I think it's only for c4d basematerial
Thanks you
You mean the base color? See "Modifying Parameters" here: https://support.solidangle.com/x/lgBeAg
Thank you Stephen
However, I feel a little lost with this code as I have tried this but I get an error "NameError: global name 'C4DTOA_MSG_TYPE' is not defined"
I would like to get the vector value (color) of the arnold material named "standard_surface"
Is there any library to import ?
Thanks
import c4d
from c4d import gui
#Welcome to the world of Python
def main():
mat = doc.SearchMaterial("standard_surface")
print mat
# query the network
msg = c4d.BaseContainer()
msg.SetInt32(C4DTOA_MSG_TYPE, C4DTOA_MSG_QUERY_SHADER_NETWORK)
mat.Message(c4d.MSG_BASECONTAINER, msg)
# modify parameter
shader = msg.GetLink(C4DTOA_MSG_RESP3)
C4DAIP_STANDARD_SURFACE_BASE_COLOR = 1044225467
shader[C4DAIP_STANDARD_SURFACE_BASE_COLOR] = c4d.Vector(0.9, 0.9, 0.4)
# trigger update
c4d.EventAdd()
if __name__=='__main__':
main()
got it, I have to declare some missing constants :
import c4d from c4d import gui #Welcome to the world of Python # from res/description/ainode_image.h C4DAIP_IMAGE_FILENAME = 1737748425 C4DTOA_MSG_TYPE = 1000 C4DTOA_MSG_RESP3 = 2013 C4DTOA_MSG_QUERY_SHADER_NETWORK = 1028 C4DAIP_STANDARD_SURFACE_BASE_COLOR = 1044225467 def main(): mat = doc.SearchMaterial("standard_surface") print mat # query the network msg = c4d.BaseContainer() msg.SetInt32(C4DTOA_MSG_TYPE, C4DTOA_MSG_QUERY_SHADER_NETWORK) mat.Message(c4d.MSG_BASECONTAINER, msg) # modify parameter shader = msg.GetLink(C4DTOA_MSG_RESP3) print shader[C4DAIP_STANDARD_SURFACE_BASE_COLOR] # trigger update c4d.EventAdd() if __name__=='__main__': main()
The shader network is an Xpresso graph attached to the material, which is a custom solution and the C4D python SDK does not offer any method to access it directly. That's why it works now via messages. If I have some time I will move this code to a module, so you don't have to worry about sending messages and ids and whatnot.