On 03/08/2018 at 07:21, xxxxxxxx wrote:
Hi Zac Davide, first of all, welcome in the PluginCafe forum.
It's actually not necessary to bump a thread if a day has not passed.
Regarding your question, take in consideration we can only support c4d related stuff, and give you advice about it.
But as you may know or not, a vrayMaterial, is nothing more than a MaterialData and a VrayAdvBitmap, is a ShaderData.
All ShaderData are part of a MaterialData. So with the following script, you will iterate over all the shader within the selected material.
And change the texture path
import c4d
# Change the texture path to another one for a VrayAdvBitmap
def changeTexture(shader) :
before = "wood_diffuse"
after = "texture_001"
oldPath = shader[c4d.VRAY_BITMAPCCGAMMA_BITMAP_FILENAME] # Read the current value, again I simply drag and drop the parameter in the consoel to knwo the ID
newPath = oldPath.replace(before, after) # Replace before value by new value
doc = shader.GetDocument()
doc.AddUndo(c4d.UNDOTYPE_CHANGE, shader)
shader[c4d.VRAY_BITMAPCCGAMMA_BITMAP_FILENAME] = newPath # Assign the new value
shader.Message(c4d.MSG_UPDATE)
# Iterate a hierarchy and check if the passed is a VrayAdvBitmap shader
def recurse_hierarchy(shader) :
while shader:
# Check if it's a VrayAdvBitmap, I know the ID by drag and drop a VrayAdvancedShader into the console
if shader.CheckType(1037364) :
changeTexture(shader)
recurse_hierarchy(shader.GetDown())
shader = shader.GetNext()
# Main function
def main() :
mats = doc.GetActiveMaterials()
doc.StartUndo()
# Iterate over selected material
for mat in mats:
recurse_hierarchy(mat.GetFirstShader())
doc.Endndo()
# Execute main()
if __name__=='__main__':
main()
If you have any question please let me know! :)
Cheers,
Maxime