Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import c4d
- #-- Gr4ph0s
- # visit graphos.fr
- def getEntry(mat):
- buffer = []
- try :
- diffuse = mat[c4d.OCT_MATERIAL_DIFFUSE_LINK]
- if diffuse.CheckType(5833):
- buffer.append([1,diffuse[c4d.BITMAPSHADER_FILENAME]])
- except:
- pass
- try :
- roughness = mat[c4d.OCT_MATERIAL_ROUGHNESS_LINK]
- if roughness.CheckType(5833):
- buffer.append([2,roughness[c4d.BITMAPSHADER_FILENAME]])
- except:
- pass
- try :
- bump = mat[c4d.OCT_MATERIAL_BUMP_LINK]
- if bump.CheckType(5833):
- buffer.append([3,bump[c4d.BITMAPSHADER_FILENAME]])
- except:
- pass
- try :
- normal = mat[c4d.OCT_MATERIAL_NORMAL_LINK]
- if normal.CheckType(5833):
- buffer.append([4,normal[c4d.BITMAPSHADER_FILENAME]])
- except:
- pass
- try :
- displace = mat[c4d.OCT_MATERIAL_DISPLACEMENT_LINK]
- if displace.CheckType(5833):
- buffer.append([5,displace[c4d.BITMAPSHADER_FILENAME]])
- except:
- pass
- try :
- opacity = mat[c4d.OCT_MATERIAL_OPACITY_LINK]
- if opacity.CheckType(5833):
- buffer.append([6,opacity[c4d.BITMAPSHADER_FILENAME]])
- except:
- pass
- try :
- transmission = mat[c4d.OCT_MATERIAL_TRANSMISSION_LINK]
- if transmission.CheckType(5833):
- buffer.append([7,transmission[c4d.BITMAPSHADER_FILENAME]])
- except:
- pass
- try :
- emission = mat[c4d.OCT_MATERIAL_EMISSION]
- if emission.CheckType(5833):
- buffer.append([8,emission[c4d.BITMAPSHADER_FILENAME]])
- except:
- pass
- try :
- medium = mat[c4d.OCT_MATERIAL_MEDIUM]
- if medium.CheckType(5833):
- buffer.append([9,medium[c4d.BITMAPSHADER_FILENAME]])
- except:
- pass
- try :
- specular = mat[c4d.OCT_MATERIAL_SPECULAR_LINK]
- if medium.CheckType(5833):
- buffer.append([10,specular[c4d.BITMAPSHADER_FILENAME]])
- except:
- pass
- try :
- filmwidth = mat[c4d.OCT_MATERIAL_FILMWIDTH_LINK]
- if filmwidth.CheckType(5833):
- buffer.append([11,filmwidth[c4d.BITMAPSHADER_FILENAME]])
- except:
- pass
- try :
- reflection = mat[c4d.OCT_MATERIAL_REFLECTION_LINK]
- if reflection.CheckType(5833):
- buffer.append([12,reflection[c4d.BITMAPSHADER_FILENAME]])
- except:
- pass
- return buffer
- def get_shader(mat):
- shader = mat.GetFirstShader()
- while shader:
- if shader.CheckType(5833):
- test = c4d.BaseShader(1029508)
- test[c4d.IMAGETEXTURE_FILE] = "testbbbbbb"
- mat.InsertShader(test)
- mat.Message(c4d.MSG_UPDATE)
- mat.Update(True, True)
- print shader[c4d.BITMAPSHADER_FILENAME]
- shader = shader.GetNext()
- def remplaceEntry(mat,data):
- for i in xrange(0,len(data)):
- id = data[i][0]
- imageTexture = c4d.BaseShader(1029508)
- if id == 1:
- path = mat[c4d.OCT_MATERIAL_DIFFUSE_LINK][c4d.BITMAPSHADER_FILENAME]
- imageTexture[c4d.IMAGETEXTURE_FILE] = path
- mat[c4d.OCT_MATERIAL_DIFFUSE_LINK] = imageTexture
- if id == 2:
- path = mat[c4d.OCT_MATERIAL_ROUGHNESS_LINK][c4d.BITMAPSHADER_FILENAME]
- imageTexture[c4d.IMAGETEXTURE_FILE] = path
- mat[c4d.OCT_MATERIAL_ROUGHNESS_LINK] = imageTexture
- if id == 3:
- path = mat[c4d.OCT_MATERIAL_BUMP_LINK][c4d.BITMAPSHADER_FILENAME]
- imageTexture[c4d.IMAGETEXTURE_FILE] = path
- mat[c4d.OCT_MATERIAL_BUMP_LINK] = imageTexture
- if id == 4:
- path = mat[c4d.OCT_MATERIAL_NORMAL_LINK][c4d.BITMAPSHADER_FILENAME]
- imageTexture[c4d.IMAGETEXTURE_FILE] = path
- mat[c4d.OCT_MATERIAL_NORMAL_LINK] = imageTexture
- if id == 5:
- path = mat[c4d.OCT_MATERIAL_DISPLACEMENT_LINK][c4d.BITMAPSHADER_FILENAME]
- imageTexture[c4d.IMAGETEXTURE_FILE] = path
- mat[c4d.OCT_MATERIAL_DISPLACEMENT_LINK] = imageTexture
- if id == 6:
- path = mat[c4d.OCT_MATERIAL_OPACITY_LINK][c4d.BITMAPSHADER_FILENAME]
- imageTexture[c4d.IMAGETEXTURE_FILE] = path
- mat[c4d.OCT_MATERIAL_OPACITY_LINK] = imageTexture
- if id == 7:
- path = mat[c4d.OCT_MATERIAL_TRANSMISSION_LINK][c4d.BITMAPSHADER_FILENAME]
- imageTexture[c4d.IMAGETEXTURE_FILE] = path
- mat[c4d.OCT_MATERIAL_TRANSMISSION_LINK] = imageTexture
- if id == 8:
- path = mat[c4d.OCT_MATERIAL_EMISSION][c4d.BITMAPSHADER_FILENAME]
- imageTexture[c4d.IMAGETEXTURE_FILE] = path
- mat[c4d.OCT_MATERIAL_EMISSION] = imageTexture
- if id == 9:
- path = mat[c4d.OCT_MATERIAL_MEDIUM][c4d.BITMAPSHADER_FILENAME]
- imageTexture[c4d.IMAGETEXTURE_FILE] = path
- mat[c4d.OCT_MATERIAL_MEDIUM] = imageTexture
- if id == 10:
- path = mat[c4d.OCT_MATERIAL_SPECULAR_LINK][c4d.BITMAPSHADER_FILENAME]
- imageTexture[c4d.IMAGETEXTURE_FILE] = path
- mat[c4d.OCT_MATERIAL_SPECULAR_LINK] = imageTexture
- if id == 11:
- path = mat[c4d.OCT_MATERIAL_FILMWIDTH_LINK][c4d.BITMAPSHADER_FILENAME]
- imageTexture[c4d.IMAGETEXTURE_FILE] = path
- mat[c4d.OCT_MATERIAL_FILMWIDTH_LINK] = imageTexture
- if id == 12:
- path = mat[c4d.OCT_MATERIAL_REFLECTION_LINK][c4d.BITMAPSHADER_FILENAME]
- imageTexture[c4d.IMAGETEXTURE_FILE] = path
- mat[c4d.OCT_MATERIAL_REFLECTION_LINK] = imageTexture
- mat.InsertShader(imageTexture )
- mat.Message(c4d.MSG_UPDATE)
- mat.Update(True, True)
- def main():
- allMat = doc.GetActiveMaterials()
- for mat in allMat:
- data = getEntry(mat)
- remplaceEntry(mat,data)
- mat = mat.GetNext()
- c4d.EventAdd()
- if __name__=='__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement