It is, ive been hand holding gpt while it structures it. Of course its out of date though unfortunately. It struggles the most with redshift scripts, for some reason it doesn't properly know how to create a material. I did some digging and found that post you shared before posting here to try and use it. However im not skilled enough yet in python or in the knowledge of the plugins to that extent to structure it myself. GPT and I did manage to make a working conversion script for octane to C4D native materials though with some lengthy troubleshooting. Don't know if this would help with the current topic at hand at all. But either way I appreciate the reply.
import c4d
from c4d import documents
ID_OCTANE_MATERIAL = 1029501
ID_OCTANE_IMAGE_TEXTURE = 1029508
ID_OCTANE_COLORCORRECTION = 1029512
ID_OCTANE_INVERT_TEXTURE = 1029514
ID_OCTANE_MULTIPLY_TEXTURE = 1029516
ID_OCTANE_MIXTEXTURE = 1029505
mainLayerId = 526336
def CheckSelection(doc, mats):
oct_mats = []
if mats:
count = len(mats)
for i in range(count):
if mats[i].GetType() == ID_OCTANE_MATERIAL:
oct_mats.append(mats[i])
return oct_mats
def GetTexture(doc, oct_mat, channel):
image_name = None
image_shader = oct_mat[channel]
if image_shader:
shader_type = image_shader.GetType()
if shader_type == ID_OCTANE_MULTIPLY_TEXTURE:
image_shader = image_shader[c4d.MULTIPLY_TEXTURE1]
if image_shader:
shader_type = image_shader.GetType()
if shader_type == ID_OCTANE_MIXTEXTURE:
image_shader = image_shader[c4d.MIXTEX_TEXTURE1_LNK]
if image_shader:
shader_type = image_shader.GetType()
if shader_type == ID_OCTANE_COLORCORRECTION:
image_shader = image_shader[c4d.COLORCOR_TEXTURE_LNK]
if image_shader:
shader_type = image_shader.GetType()
if shader_type == ID_OCTANE_INVERT_TEXTURE:
image_shader = image_shader[c4d.INVERT_TEXTURE]
if image_shader:
shader_type = image_shader.GetType()
if shader_type == ID_OCTANE_IMAGE_TEXTURE:
image_name = image_shader[c4d.IMAGETEXTURE_FILE]
print(image_name)
return image_name
def ReAssign(doc, oct_mat, c4d_mat):
obj_link = oct_mat[c4d.ID_MATERIALASSIGNMENTS]
link_count = obj_link.GetObjectCount()
for i in range(link_count):
tex_tag = obj_link.ObjectFromIndex(doc, i)
doc.AddUndo(c4d.UNDOTYPE_CHANGE, tex_tag)
tex_tag[c4d.TEXTURETAG_MATERIAL] = c4d_mat
tex_tag.Message(c4d.MSG_CHANGE)
def RebuildMats(doc, oct_mats):
c4d_mats = []
count = len(oct_mats)
for i in range(count):
oct_mat = oct_mats[i]
c4d_mat = c4d.BaseMaterial(c4d.Mmaterial)
name = oct_mat[c4d.ID_BASELIST_NAME]
c4d_mat[c4d.ID_BASELIST_NAME] = name
diff_file = GetTexture(doc, oct_mat, c4d.OCT_MATERIAL_DIFFUSE_LINK)
if diff_file:
diff_shader = c4d.BaseShader(c4d.Xbitmap)
diff_shader[c4d.BITMAPSHADER_FILENAME] = diff_file
c4d_mat[c4d.MATERIAL_COLOR_SHADER] = diff_shader
c4d_mat.InsertShader(diff_shader)
opac_file = GetTexture(doc, oct_mat, c4d.OCT_MATERIAL_OPACITY_LINK)
if opac_file:
opac_shader = c4d.BaseShader(c4d.Xbitmap)
opac_shader[c4d.BITMAPSHADER_FILENAME] = opac_file
c4d_mat[c4d.MATERIAL_ALPHA_SHADER] = opac_shader
c4d_mat.InsertShader(opac_shader)
c4d_mat[c4d.MATERIAL_USE_ALPHA] = True
normal_file = GetTexture(doc, oct_mat, c4d.OCT_MATERIAL_NORMAL_LINK)
if normal_file:
normal_shader = c4d.BaseShader(c4d.Xbitmap)
normal_shader[c4d.BITMAPSHADER_FILENAME] = normal_file
c4d_mat[c4d.MATERIAL_NORMAL_SHADER] = normal_shader
c4d_mat.InsertShader(normal_shader)
c4d_mat[c4d.MATERIAL_USE_NORMAL] = True
bump_file = GetTexture(doc, oct_mat, c4d.OCT_MATERIAL_BUMP_LINK)
if bump_file:
bump_shader = c4d.BaseShader(c4d.Xbitmap)
bump_shader[c4d.BITMAPSHADER_FILENAME] = bump_file
c4d_mat[c4d.MATERIAL_BUMP_SHADER] = bump_shader
c4d_mat.InsertShader(bump_shader)
c4d_mat[c4d.MATERIAL_USE_BUMP] = True
rough_file = GetTexture(doc, oct_mat, c4d.OCT_MATERIAL_ROUGHNESS_LINK)
if rough_file:
rough_shader = c4d.BaseShader(c4d.Xbitmap)
rough_shader[c4d.BITMAPSHADER_FILENAME] = rough_file
c4d_mat[c4d.MATERIAL_USE_REFLECTION] = True
c4d_mat[mainLayerId + c4d.REFLECTION_LAYER_MAIN_DISTRIBUTION] = 2
c4d_mat[mainLayerId + c4d.REFLECTION_LAYER_MAIN_SHADER_ROUGHNESS] = rough_shader
c4d_mat.InsertShader(rough_shader)
ReAssign(doc, oct_mat, c4d_mat)
c4d_mats.append(c4d_mat)
doc.InsertMaterial(c4d_mat)
doc.AddUndo(c4d.UNDOTYPE_NEW, c4d_mat)
return
def main():
my_doc = documents.GetActiveDocument()
my_mats = my_doc.GetActiveMaterials()
my_oct_mats = CheckSelection(my_doc, my_mats)
if my_oct_mats:
doc.StartUndo()
RebuildMats(my_doc, my_oct_mats)
doc.EndUndo()
c4d.EventAdd()
if __name__ == '__main__':
main()