Navigation

    • Register
    • Login
    • Search
    1. Home
    2. Dunhou
    Dunhou

    Dunhou

    @Dunhou

    32
    Reputation
    143
    Posts
    67
    Profile views
    3
    Followers
    2
    Following
    Joined Last Online
    Website www.boghma.com Location China

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    Dunhou Follow

    Best posts made by Dunhou

    A Free custom api helper for Octane/Redshift/Arnold

    Hi community!

    This is my free python api hleper for most popular third-part render engines. Now renderEngine support Octane /Redshift /Arnold .You can find it on my github : renderEngine

    I try to keep it as same as possible, but each renderer has their own logic, so there are some compromises.

    If you like it, please hit me a github star and also very welcome for your contributions.:blush:

    Cheers~
    DunHou


    renderEngine

    This is a custom api for most popular render engine like Octane\Redshift\Arnold in Cinema 4D, which is also wiil contains in 'boghma' library.

    All the boghma plugins and boghma library is FREE.
    

    Installation

    To use this library, you have two options:

    1. Download the source and import it to your Cinema 4D
    2. (Recommend) You can also download Boghma Plugin Manager and install any plugin, the boghma lib will auto installed.

    Limit

    • Due to Otoy use a custom userarea for the node editor, and don't support python. We can not get the selection of the node edtor, so it is not possible to interact with node editor.
    • Redshift and Arnold material helper only support NodeGragh, so the Cinema 4D before R26 is not support.
    • AddChild() and AddTextureTree() may return a not auto-layout node network now.
    • GetID() is broken, wait Maxon fix it, GetParamDataTypeID() can not get vector id
    • Arnold mask tag SetPrameter has a refresh bug.

    Examples

    • Octane Example
    • Redshift Example
    • Arnold Example

    Class Presentation and Highlights

    node_helper

    • NodeGraghHelper : helper class for Cinema 4D NodeGragh.
    • TexPack : helper class to get texture data.
    • methods : helper functions.

    octane_helper

    • octane_id : unique ids for octane object, and name map of aovs.
    • octane_helper : all the helper class and function.
      • methods
      • VideoPostHelper (class)
      • AOVHelper (class)
      • NodeHelper (class)
      • MaterialHelper (class)
      • SceneHelper (class)

    redshift_helper

    • redshift : unique ids for redshift object, and name map of aovs.
    • redshift_helper : all the helper class and function.
      • methods
      • VideoPostHelper (class)
      • AOVHelper (class)
      • MaterialHelper (class)
      • RSMaterialTransaction (class)
      • SceneHelper (class)

    arnold_helper

    • arnold : unique ids for arnold object, and name map of aovs.
    • arnold_helper : all the helper class and function.
      • methods
      • VideoPostHelper (class)
      • AOVHelper (class)
      • MaterialHelper (class)
      • SceneHelper (class)
      • ArnoldShaderLinkCustomData (class)
      • ArnoldVColorCustomData (class)

    Version & Updates

    • Change Log
    posted in General Talk •
    Free plugin : Octane Light Manager

    A free plugin for manage octane lights in the active document.

    Here is the dialog looks like, hope it can help you:blush:

    :clown_face: Octane verison : oc-light-manager v1.0.2.zip
    :clown_face: Redshift verison : rs-light-manager v1.0.1.zip

    preview.png


    Cinema 4D Octane Light Manager

    🔒:Cinema 4D R2023.2.0 above

    Online Help

    Standalone Download

    • Boghma Community(Chinese Language)

    • Gitee(Chinese Language)

    • Github( .pypv)

    Plugin Manager Download

    • Boghma Plugin Manager (Beta)

    Function Highlights

    • track document Octane lights and get/set some key parameter
    • Drag to set Light ID
    • Quickly set Texture or Distribution slot with RGB or Texture
    • Solo / Enable / As Camera for Octane Light
    • And so on, please check document

    Cheers~
    DunHou

    posted in General Talk •
    RE: Get the Name of the Node?

    @bentraje

    I think name atttribute is not easy as old c4d SDK to use . It cann't print in console .

    I use this to get Name , and Set Name .
    some codes in python sdk didn't work and return None .Maxon SDK has a example to get info form node retrieve_information_r26.py

        # 获取名称 : 
        def GetNodeName(self, node, display=False):
            """
            Retrieve the displayed name of a node.
            
            Parameters
            ----------        
            Args:
                node: (maxon.GraphNode): The node to retrieve the name from.
                display: print info when display is True
            Returns:
                Optional[str]: The node name, or None if the Node name can't be retrieved.
            """
            if node is None:
                return None
    
            nodeName = node.GetValue(maxon.NODE.BASE.NAME)
    
            if nodeName is None:
                nodeName = node.GetValue(maxon.EffectiveName)
    
            if nodeName is None:
                nodeName = str(node)
            if display ==True :
                print(nodeName)
            return nodeName   
    
    posted in Cinema 4D SDK •
    RE: A Free custom api helper for Octane/Redshift/Arnold

    Hi community!

    the renderEngine helper is beta now, I set version number to 1.0.0, it contains three renderer now:

    • Octane
    • Arnold ( MaterialHelper only support NodeGragh )
    • Redshift ( MaterialHelper only support NodeGragh )

    I personally not use Vray and Corona quite often, if anyone is a pro user of these , very welcome to add them to renderEngine

    You can modify the aovs/materials with renderEngine quickly and easliy . See the examples above this topic.

    Hope you can have fun with it, and any improvement and fix is very appreciated.

    Cheers~
    DunHou

    posted in General Talk •
    RE: Running Automatic UV for all objects

    @BineeMan here is my unwrap script, but I didn't find how to change to cubic or angle mode, there seems not a symbol in the .h file.

    import c4d
    
    MCOMMAND_AUTOMATICUV = 1053624
    
    def unwrap(node: c4d.BaseObject):
        doc = node.GetDocument()
        if isinstance(node, c4d.PolygonObject) and node.GetTag(c4d.Tuvw) is not None:
            pass
        elif isinstance(node, c4d.PolygonObject) and node.GetTag(c4d.Tuvw) is None:
            doc.AddUndo(c4d.UNDOTYPE_CHANGE, node)
            settings = c4d.BaseContainer()
            settings[c4d.MDATA_AUTOMATICUV_TAGINDEX] = 0
            settings[c4d.MDATA_AUTOMATICUV_FORCESEAMS] = False
            settings[c4d.MDATA_AUTOMATICUV_OVERLAPMIRRORED] = False
            settings[c4d.MDATA_AUTOMATICUV_OVERLAPIDENTICAL] = False
            settings[c4d.MDATA_AUTOMATICUV_SPACING] = 0.01
            settings[c4d.MDATA_AUTOMATICUV_USENORMALS] = True
            settings[c4d.MDATA_AUTOMATICUV_SPACINGASPECT] = 1.0
            c4d.utils.SendModelingCommand(command = MCOMMAND_AUTOMATICUV,
                                        list=[node],
                                        mode=c4d.MODELINGCOMMANDMODE_POLYGONSELECTION,
                                        bc=settings,
                                        doc=doc)
    
    def do_it():
        doc = c4d.documents.GetActiveDocument()
        for node in doc.GetActiveObjects(0):
            unwrap(node)
        c4d.EventAdd()
    
    if __name__ == '__main__':
        do_it()
    
    posted in Cinema 4D SDK •
    Free plugins all in one : Boghma HUB

    Hi community!

    Here is a new plugin to manage all my(boghma) plugins and some open source librarys like ualib and renderEngine for Cinema 4D.

    All the boghma plugin is 100% Free
    

    About boghma: boghma is the pronounce of python in Uighur, It is a free community for Cinema 4D and operated by me and my two friends.If you want to share your plugins for free and put it into the manager, please contact me:+1:

    Hope it can help you.

    Cheers~
    DunHou


    Boghma-Plugin-HUB

    This plugin manage all the boghma plugin, and install/update/uninstall them.

    Install

    1. Download boghma hub and unzip it.

    2. Put boghma hub folder to your ssd disk,Like:D:/boghma hub

    3. Start Cinema 4D,Preference - Plugins - Add Folder,Add the boghma hub folder and keep active,like:D:/boghma hub

    4. Restart Cinema,find boghma menu and enjoy
      15633e63-cbd0-4294-9452-a003199b1088-image.png

    Do not change the folder structure of boghma hub
    

    How to use

    53c621b5-1b83-4e0e-b0a8-ab68115b9811-image.png

    • Install
    • Update
    • Unstall
    posted in General Talk •
    RE: A Free custom api helper for Octane/Redshift/Arnold

    Hi community!

    Th renderEngine library has been updated to the 1.0.4 version, there are some re-write functions and may not incompatible with older versions,see the main changes as follows:

    • rename all node & material functions to Capitalize style.
    • remove transaction in node_helper, use it in the final scripts.
    • organize the functions in node_helper with comments ( node\port\wire\util )
    • add some functions to check node or port info, like if it is connected , see the README.
    • add a InserShader function to create a shader into a wire.
    • re-write RemoveConnection in node_helper and support one argument(port) to remove connection.
    • see the Version & Updates

    Cheers~
    DunHou

    posted in General Talk •
    RE: Free plugin : Octane Light Manager

    Redshift Manager Here, and Octane also had a huge update, please use my plugin manager version to check new furtures.

    49845e69-c2ef-4d79-a429-4c1433f5a773-image.png

    posted in General Talk •
    RE: Can I download a Tex in Asset Browser and add into select RS node mat?

    @ferdinand Maybe the broblem in not the code but the Cinema Application, Some friends also told me when they load Aseets(especially at a large Asset data like 20G in disk) , It always take a long time or even not load unless restart C4D.

    You are right, I should call WaitForDatabaseLoading() function for safe. That's my stupid , I didn't notice the loading failed in state bar:anguished:

    I do check the Python examples in GitHub , but I think maybe it is a dcc of my config problem, some friends also said assets broswer is a little slower . (perhaps due to china a internet far away from maxon server) .hope it will be fix in uncoming C4D

    posted in Cinema 4D SDK •
    RE: I have developed an open-source user interface framework based on UserArea.

    @JACK0319 Great work !

    I have been using ualib for some plugins and worked very well for whatever a beginner or experienced programmer , It's definitely worth trying it :+1:

    0cf6ade8-8bae-4cd8-96f0-ff3f143c1306-image.png

    posted in General Talk •

    Latest posts made by Dunhou

    RE: c4d 2024 "MENURESOURCE_SEPERATOR"

    Hi @chuanzhen
    This symbol rename to c4d.MENURESOURCE_SEPARATOR( fix the spelling ), you can add a version condition to your plugin or just use the int 2.

    Cheers~
    DunHou

    posted in Cinema 4D SDK •
    RE: How to find and delete a node in a NodeGraph?

    Hi@kbar, I didn't know C++, but I think the method should be the same as python. I have two options for this task:

    • all maxon sdk stuffs, I modified the github example here

    • use my renderEngine library (custom wrapper for node gragh us maxon sdk)
      Hoping this helps.

    Cheers~
    DunHou


    maxon sdk

    import c4d
    import maxon
    
    doc: c4d.documents.BaseDocument # The active document.
    
    def main():
    
        # For each #material in the currently active document get its #nodeMaterial reference.
        material: c4d.BaseMaterial
        for material in doc.GetMaterials():
            nodeMaterial: c4d.NodeMaterial = material.GetNodeMaterialReference()
        
            # To test if a material has a graph for a specific space, we must use the method #HasSpace. 
            # To support 3rd party render engines, you must ask them for their node space ID.
            for nid in ("net.maxon.nodespace.standard",                 # Standard Renderer
                        "com.redshift3d.redshift4c4d.class.nodespace"): # Redshift Renderer
                if not nodeMaterial.HasSpace(nid):
                    continue
                
                # This material has a graph for the space #nid, we retrieve it.
                graph: maxon.GraphModelInterface = nodeMaterial.GetGraph(nid)
                if graph.IsNullValue():
                    raise RuntimeError("Found malformed empty graph associated with node space.")
                
                result: list[maxon.GraphNode] = []
                asset_id = "com.redshift3d.redshift4c4d.nodes.core.material"
                maxon.GraphModelHelper.FindNodesByAssetId(graph, asset_id, True, result)
                
                # start remove
                with graph.BeginTransaction() as transaction:
                    for i in result:
                        i.Remove()
                    transaction.Commit()
                
        c4d.EventAdd()
    
    if __name__ == "__main__":
        main()
    

    renderEngine

    import c4d,maxon
    from renderEngine.redshift import redshift_helper as rs
    doc: c4d.documents.BaseDocument # The active document.
    
    def ModifyMaterial(material: rs.MaterialHelper):
        if material is None:
            return
        # transfer it to a instance of rs.MaterialHelper                
        if isinstance(material, c4d.BaseMaterial):
            material = rs.MaterialHelper(material)
            # modification has to be done within a transaction
            with rs.RSMaterialTransaction(material) as transaction:
    
                # return a list of material with giving node id
                RsMat = material.helper.GetNodes("com.redshift3d.redshift4c4d.nodes.core.material")
                for mat in RsMat:
                    # remove it
                    material.helper.RemoveShader(mat)
                           
    if __name__ == "__main__":
        ModifyMaterial(doc.GetActiveMaterial())
    
    posted in Cinema 4D SDK •
    RE: Running Automatic UV for all objects

    @BineeMan here is my unwrap script, but I didn't find how to change to cubic or angle mode, there seems not a symbol in the .h file.

    import c4d
    
    MCOMMAND_AUTOMATICUV = 1053624
    
    def unwrap(node: c4d.BaseObject):
        doc = node.GetDocument()
        if isinstance(node, c4d.PolygonObject) and node.GetTag(c4d.Tuvw) is not None:
            pass
        elif isinstance(node, c4d.PolygonObject) and node.GetTag(c4d.Tuvw) is None:
            doc.AddUndo(c4d.UNDOTYPE_CHANGE, node)
            settings = c4d.BaseContainer()
            settings[c4d.MDATA_AUTOMATICUV_TAGINDEX] = 0
            settings[c4d.MDATA_AUTOMATICUV_FORCESEAMS] = False
            settings[c4d.MDATA_AUTOMATICUV_OVERLAPMIRRORED] = False
            settings[c4d.MDATA_AUTOMATICUV_OVERLAPIDENTICAL] = False
            settings[c4d.MDATA_AUTOMATICUV_SPACING] = 0.01
            settings[c4d.MDATA_AUTOMATICUV_USENORMALS] = True
            settings[c4d.MDATA_AUTOMATICUV_SPACINGASPECT] = 1.0
            c4d.utils.SendModelingCommand(command = MCOMMAND_AUTOMATICUV,
                                        list=[node],
                                        mode=c4d.MODELINGCOMMANDMODE_POLYGONSELECTION,
                                        bc=settings,
                                        doc=doc)
    
    def do_it():
        doc = c4d.documents.GetActiveDocument()
        for node in doc.GetActiveObjects(0):
            unwrap(node)
        c4d.EventAdd()
    
    if __name__ == '__main__':
        do_it()
    
    posted in Cinema 4D SDK •
    RE: Can I use both MouseDown() and DoubleClick() in treeview?

    Hi @ferdinand ,

    @ferdinand said in Can I use both MouseDown() and DoubleClick() in treeview?:

    In general, you should keep in mind that the concept of a double click is only represented very weakly in Cinema 4D, with TreeViewFunctions being one of the very few cases which uses that term. In the backbone of the API, the GUI message stream, the concept of a double click does not exist. Things are actions (BFM_ACTION_...) and inputs (BFM_INPUT_...) and each mouse click counts as an input and/or action. It is up to specific gadgets to bundle up multiple clicks into a double click.

    That helps foe better unstand how it worked, thanks!

    And this kind solution is a much more mature solution than what I used a simple one in my Octane Light Manager, I try to stop the set check event duplicate many times, I will keep more condition as your suggestion.

    e0be12a8-f277-400d-9d7a-14065e55ffee-image.png

    Thanks again for your detailed explain for all the answer.

    Cheers~
    DunHou

    posted in Cinema 4D SDK •
    RE: Free plugin : Octane Light Manager

    Redshift Manager Here, and Octane also had a huge update, please use my plugin manager version to check new furtures.

    49845e69-c2ef-4d79-a429-4c1433f5a773-image.png

    posted in General Talk •
    Can I use both MouseDown() and DoubleClick() in treeview?

    Hi community ,

    I want to get both MouseDown() and DoubleClick() in treeview , for example :

    • when I select a item, trigger a change function to update some data.

    • when I doubleclick a item, I want to trigger another function like refresh treeview for some funcs.

    But by so far , when I use them both , the trigger will be :

    • MouseDown() => DoubleClick() => MouseDown()

    It will call MouseDown twice, how call I aviod this ?

        def MouseDown(self, root, userdata, obj, col, mouseinfo, rightButton):
            print("selection changed")
    
            return False
        
        def DoubleClick(self, root, userdata, obj, col, mouseinfo):           
            
            print("double click")
            return Ture
    
    
    posted in Cinema 4D SDK •
    Are there any official personnel from Megascans here ?

    Hi community,

    I notice that megascans plugin of Cinema 4D is stop update for long times, and it doesn’t support new node materials, all we can do is import as a xpresso material and convert , will you update this plugin recently?

    Or do you allow me to modify this plugin to import the new node materials in Cinema 4D? Actually, I have almost done it , also support Arnold and Redshift node materials, but I wonder if I can share it as a free community plugin,

    Or if you want to , you can merge my code in the offical plugins, I'd like to share my codes for your easy update and modify.

    If someone from megascans of know how to connect with them, please let me know:blush:

    Cheers~
    DunHou


    57be426a90e41046f581f3cad62d4104d055bf11_2_621x500.png
    Snipaste_2023-09-03_10-42-57.png

    posted in General Talk •
    RE: Redshift Standard Material base Properties

    Hi @simonator420 ,

    You should get the base color port( a maxon.GraphNode ), and connect with a Texture node ( also a maxon.GraphNode ), the texture path is also a port in Texture node, just set it's value is what you need,
    I have a little example here which used my api helper renderEngine, I think it is easy to use and less code for general task. but it should be pointed out that use Maxon python sdk is more customized.

    Cheers~
    DunHou

    import c4d,maxon
    from importlib import reload
    from renderEngine.redshift import redshift_helper as rs
    reload(rs)
    try:
        from redshift_id import *
    except:
        from renderEngine.redshift.redshift_id import *
    from renderEngine import node_helper
    reload(node_helper)
    
    def AddandModify(name):
        redshiftMaterial =  rs.MaterialHelper.CreateStandardSurface(name)
    
        # modification has to be done within a transaction
        with rs.RSMaterialTransaction(redshiftMaterial) as transaction:
    
            # Find brdf node (in this case : standard surface)
            standard_surface = redshiftMaterial.helper.GetRootBRDF()
    
            # Change a shader name
            redshiftMaterial.helper.SetName(standard_surface,'My BRDF Shader')
    
            # TexPath
            tex_helper = node_helper.TextureHelper()
            url: maxon.Url = tex_helper.GetAssetStr(maxon.Id("file_5b6a5fe03176444c"))
            tar = redshiftMaterial.helper.GetPort(standard_surface,'com.redshift3d.redshift4c4d.nodes.core.standardmaterial.base_color')
    
            # Add a texture to base color
            redshiftMaterial.AddTexture(shadername = 'My texture', filepath = url, raw = True, target_port = tar)
            
        redshiftMaterial.InsertMaterial()
        redshiftMaterial.SetActive()
        c4d.EventAdd()
        
        return redshiftMaterial.material
    
    if __name__ == '__main__':
        AddandModify("Example")
    
    posted in Cinema 4D SDK •
    RE: Handling Treeview File Drag and Drop Events

    Hi @ferdinand ,

    The SetFloatValue() function in python document missing a parameter finalValue, it will raise an error , people can easily mess it up.

    Hope the next update can fix it:+1:

    70d73b1b-7ec2-4268-a6bf-ab177c0fa783-image.png

    Cheers~
    DunHou

    posted in Cinema 4D SDK •
    RE: A Free custom api helper for Octane/Redshift/Arnold

    Hi community!

    Th renderEngine library has been updated to the 1.0.4 version, there are some re-write functions and may not incompatible with older versions,see the main changes as follows:

    • rename all node & material functions to Capitalize style.
    • remove transaction in node_helper, use it in the final scripts.
    • organize the functions in node_helper with comments ( node\port\wire\util )
    • add some functions to check node or port info, like if it is connected , see the README.
    • add a InserShader function to create a shader into a wire.
    • re-write RemoveConnection in node_helper and support one argument(port) to remove connection.
    • see the Version & Updates

    Cheers~
    DunHou

    posted in General Talk •