Moderator: aoktar
import c4d
from c4d import gui
# Unique id numbers for each of the GUI elements
GROUP_OPTIONS = 20000
BTN_OK = 20001
BTN_CANCEL = 20002
COMBO1 = 1010
COMBO2 = 1011
COMBO3 = 1012
ID_OCTANE_DIFFUSE_MATERIAL = 1029501
ID_OCTANE_STANDARD_SURFACE = 1058763
ID_OCTANE_MIX_MATERIAL = 1029622
ID_OCTANE_PORTAL_MATERIAL = 1029623
ID_OCTANE_NULL_MATERIAL = 1061767
ID_OCTANE_CLIPPING_MATERIAL = 1056989
ID_OCTANE_SHADOWCATCHER_MAT = 1057003
ID_OCTANE_HAIR_MATERIAL = 1054119
ID_OCTANE_COMPOSITE_MATERIAL = 1040075
ID_OCTANE_LAYERED_MATERIAL = 1052933
OCT_MAT_TYPE_DIFFUSE = 2510
OCT_MAT_TYPE_GLOSSY = 2511
OCT_MAT_TYPE_SPECULAR = 2513
OCT_MAT_TYPE_METAL = 2514
OCT_MAT_TYPE_TOON = 2515
OCT_MAT_TYPE_UNIVERSAL = 2516
OCT_MAT_BRDF_OCTANE = 0
OCT_MAT_BRDF_BECKMANN = 1
OCT_MAT_BRDF_GGX = 2
OCT_MAT_BRDF_GGX_ENPRES = 6
OCT_MAT_BRDF_WARD = 3
OCT_MAT_BRDF_STD = 7
# Dialog for renaming objects
class OptionsDialog(gui.GeDialog):
def CreateLayout(self):
self.selMatType = ID_OCTANE_DIFFUSE_MATERIAL
self.selSubMatType = OCT_MAT_TYPE_DIFFUSE
self.SetTitle('Octane material selector')
self.AddStaticText(0, c4d.BFH_LEFT, name='Material type:')
self.AddComboBox(COMBO1, c4d.BFH_SCALEFIT, 80, 0, False)
self.AddChild(COMBO1, ID_OCTANE_DIFFUSE_MATERIAL, 'Octane material')
self.AddChild(COMBO1, ID_OCTANE_STANDARD_SURFACE, 'Standard surface')
self.AddChild(COMBO1, ID_OCTANE_MIX_MATERIAL, 'Mix material')
self.AddChild(COMBO1, ID_OCTANE_COMPOSITE_MATERIAL, 'Composite material')
self.AddChild(COMBO1, ID_OCTANE_LAYERED_MATERIAL, 'Layered material')
self.AddChild(COMBO1, ID_OCTANE_HAIR_MATERIAL, 'Hair material')
self.SetInt32(COMBO1, self.selMatType)
self.AddStaticText(0, c4d.BFH_LEFT, name='Sub material type:')
self.AddComboBox(COMBO2, c4d.BFH_SCALEFIT, 80, 0, False)
self.AddChild(COMBO2, 0, 'All types')
self.AddChild(COMBO2, OCT_MAT_TYPE_DIFFUSE, 'Diffuse')
self.AddChild(COMBO2, OCT_MAT_TYPE_GLOSSY, 'Glossy')
self.AddChild(COMBO2, OCT_MAT_TYPE_SPECULAR, 'Specular')
self.AddChild(COMBO2, OCT_MAT_TYPE_METAL, 'Metal')
self.AddChild(COMBO2, OCT_MAT_TYPE_UNIVERSAL, 'Universal')
self.AddChild(COMBO2, OCT_MAT_TYPE_TOON, 'Toon')
self.SetInt32(COMBO2, self.selSubMatType)
# Buttons - an Ok and Cancel button:
self.GroupBegin(GROUP_OPTIONS, c4d.BFH_CENTER, 2, 1)
self.AddButton(BTN_OK, c4d.BFH_SCALE, name='Select')
self.AddButton(BTN_CANCEL, c4d.BFH_SCALE, name='Cancel')
self.GroupEnd()
self.ok = False
return True
# React to user's input:
def Command(self, id, msg):
if id==COMBO1:
self.selMatType = self.GetInt32(COMBO1)
print(self.selMatType)
if id==COMBO2:
self.selSubMatType = self.GetInt32(COMBO2)
print(self.selSubMatType)
if id==BTN_CANCEL:
self.Close()
elif id==BTN_OK:
self.ok = True
self.option_find_string = self.GetString(TXT_FIND)
self.option_replace_string = self.GetString(TXT_REPLACE)
self.Close()
return True
def main():
doc = c4d.documents.GetActiveDocument()
mat = doc.GetActiveMaterial()
matList = doc.GetMaterials()
# Open the options dialogue to let users choose their options.
dlg = OptionsDialog()
dlg.Open(c4d.DLG_TYPE_MODAL, defaultw=300, defaulth=50)
if not dlg.ok:
return
selMatType = dlg.selMatType
selSubMatType = dlg.selSubMatType
mt = 0
cnt=0
for mat in matList:
t = mat.GetType()
sel=False
if t==selMatType:
mt = mat[c4d.OCT_MATERIAL_TYPE]
if t==ID_OCTANE_DIFFUSE_MATERIAL:
if mt==selSubMatType: sel=True
if selSubMatType==0: sel=True
else: sel=True
if sel==True:
print(mat.GetName(), mt)
if cnt==0:
doc.SetActiveMaterial(mat)
doc.SetSelection(mat,mode=c4d.SELECTION_NEW)
else:
doc.SetSelection(mat,mode=c4d.SELECTION_ADD)
cnt=cnt+1
c4d.EventAdd()
if __name__ == '__main__':
main()
SSmolak wrote:Hurricane046 wrote:To be completely frank the C4D one never worked for me in 15 years of using C4D.
hmm yes it doesn't work. I never used it. Why you didn't reported this before to Maxon
aoktar wrote:Looks like "Remove duplicate material" command is internal, I will make it accesible
eyeonestudio wrote:Can I set Live Viewer's Render Region and Film Region using Python? (Button and Region)
You can use Picture Viewer by modifying the render settings.
However, there is no way the live viewer.
aoktar wrote:eyeonestudio wrote:Can I set Live Viewer's Render Region and Film Region using Python? (Button and Region)
You can use Picture Viewer by modifying the render settings.
However, there is no way the live viewer.
There are not any way to change this via script. They are internal and temporal parameters, we don't have no any storage to reveal it. Sorry!
doc = c4d.documents.GetActiveDocument()
bc = doc[ID_OCTANE_LIVEPLUGIN]
print ("Octane version=",bc[c4d.SET_OCTANE_VERSION])
HSchoenberger wrote:Hi
I have a scripting question for C4D.
I have seen your script to get the Ocane version from the C4D document.
- Code: Select all
doc = c4d.documents.GetActiveDocument()
bc = doc[ID_OCTANE_LIVEPLUGIN]
print ("Octane version=",bc[c4d.SET_OCTANE_VERSION])
But the issue is that the document might not show the current version used, it might be a version that was used for the scene before.
Example:
End Customer has C4D 2023+Octane 12 and C4D 2024+Octane 13 installed.
They work with 2023 for their current project.
An artist accidentally opened the scene in Cinema 2024 and saved it.
But then he continues with 2023.
If I request the information from the C4D document in 2023, then it states Octane 13.
Which is wrong.
Is there any way to get an information from the loaded plugin itself?
aoktar wrote:It's already posted information this forum, see
viewtopic.php?f=87&t=56039&start=30#p422511
HSchoenberger wrote:aoktar wrote:It's already posted information this forum, see
viewtopic.php?f=87&t=56039&start=30#p422511
I stated that I have already tried that script
and it does not work.
Please read my message.
Thanks.
Users browsing this forum: No registered users and 9 guests