==== Octane useful scripts ====

Forums: ==== Octane useful scripts ====
Sub forum for help and tutorials.

Moderator: aoktar

Re: ==== Octane useful scripts ====

Postby aoktar » Tue Dec 12, 2023 5:25 pm

aoktar Tue Dec 12, 2023 5:25 pm
Looks like "Remove duplicate material" command is internal, I will make it accesible
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
aoktar
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 15970
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye

Re: ==== Octane useful scripts ====

Postby aoktar » Wed Dec 13, 2023 7:24 am

aoktar Wed Dec 13, 2023 7:24 am
Here is a new script, which does the work. It's a start point to make selections for Octane plugin materials
Code: Select all
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()
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
aoktar
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 15970
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye

Re: ==== Octane useful scripts ====

Postby Hurricane046 » Wed Dec 13, 2023 10:36 am

Hurricane046 Wed Dec 13, 2023 10:36 am
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 :)

I've been using the Octane feature for this. It works really great. This whole problem stems only from me trying to access this feature via Python. The feature itself is great and completely negates the need for the native C4D one.

aoktar wrote:Looks like "Remove duplicate material" command is internal, I will make it accesible

Thanks, you're awesome!
2x RTX 2080 Ti | 2x RTX 2070 | 2x GTX 1080 Ti | 1x GTX 1080 | 1x GTX980 Ti
User avatar
Hurricane046
Licensed Customer
Licensed Customer
 
Posts: 78
Joined: Wed Jul 25, 2018 6:57 am

Re: ==== Octane useful scripts ====

Postby eyeonestudio » Mon Mar 18, 2024 1:24 pm

eyeonestudio Mon Mar 18, 2024 1:24 pm
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.

RR.png
CINEMA 4D R2023
Win10 / 10GbE / AMD3995X*2ea, AMD3990X*2ea, 10980XE*2ea / 256Gb RAM / RTX3090*14ea
User avatar
eyeonestudio
Licensed Customer
Licensed Customer
 
Posts: 323
Joined: Fri Oct 18, 2013 5:49 pm
Location: Seoul, South Korea

Re: ==== Octane useful scripts ====

Postby aoktar » Mon Mar 18, 2024 4:12 pm

aoktar Mon Mar 18, 2024 4:12 pm
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.

RR.png

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!
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
aoktar
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 15970
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye

Re: ==== Octane useful scripts ====

Postby eyeonestudio » Mon Mar 18, 2024 7:46 pm

eyeonestudio Mon Mar 18, 2024 7:46 pm
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.

RR.png

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!

Oh, I see. Thank you for answer
CINEMA 4D R2023
Win10 / 10GbE / AMD3995X*2ea, AMD3990X*2ea, 10980XE*2ea / 256Gb RAM / RTX3090*14ea
User avatar
eyeonestudio
Licensed Customer
Licensed Customer
 
Posts: 323
Joined: Fri Oct 18, 2013 5:49 pm
Location: Seoul, South Korea

Re: ==== Octane useful scripts ====

Postby HSchoenberger » Tue Mar 26, 2024 12:55 pm

HSchoenberger Tue Mar 26, 2024 12:55 pm
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?
HSchoenberger
Licensed Customer
Licensed Customer
 
Posts: 5
Joined: Tue Jan 23, 2024 10:16 am

Re: ==== Octane useful scripts ====

Postby aoktar » Tue Mar 26, 2024 1:02 pm

aoktar Tue Mar 26, 2024 1:02 pm
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?

It's already posted information this forum, see
viewtopic.php?f=87&t=56039&start=30#p422511
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
aoktar
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 15970
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye

Re: ==== Octane useful scripts ====

Postby HSchoenberger » Thu Mar 28, 2024 12:49 pm

HSchoenberger Thu Mar 28, 2024 12:49 pm
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.
HSchoenberger
Licensed Customer
Licensed Customer
 
Posts: 5
Joined: Tue Jan 23, 2024 10:16 am

Re: ==== Octane useful scripts ====

Postby aoktar » Thu Mar 28, 2024 4:02 pm

aoktar Thu Mar 28, 2024 4:02 pm
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.

I don't understand your request. You have two different point to read numbers, current plugin version or saved version number in to scene. What do you want to get exactly if scene version number overwritten?
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
aoktar
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 15970
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye
PreviousNext

Return to Help / Tutorials


Who is online

Users browsing this forum: No registered users and 12 guests

Sat Apr 27, 2024 8:55 pm [ UTC ]