Navigation

    • Register
    • Login
    • Search
    1. Home
    2. bonsak
    3. Posts
    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups

    Posts made by bonsak

    RE: Child render setting does not inhertit from parent

    Hi @ferdinand
    Maybe I'm just confused as to what is supposed to be expected behavior. The "Clone active renderdata" comment is a typo from a previous version 🙂 Sorry about that.
    What i figured out (in my second version of the script) was that if i create a default renderdata instance as a child of a parent render setting directly (doc.InsertRenderData(raw, default)), it does not snap to all the values of the parent, But if i make a default renderdata instance in the root of the render settings, and then make it a child of the parent after wards, all its values will snap to the parent. That puzzled me, but as i now have a version that works like i want it to, we dont have to investigate this any further.
    Thank you very much for your time.

    Regards
    Bonsak

    posted in Cinema 4D SDK •
    RE: Child render setting does not inhertit from parent

    Hi @ferdinand
    Thanks for looking into this.
    Sorry for not supplying enough info.
    This is in c4d version 24.037, Windows 10 and RS version 3.0.53
    I did actually tag the post initially 🙂

    I did some more digging and found out that if the renderdata i'm copying has non default values, the child will not get these values after the script has executed. Try this:

    • In your "My Render Settings" change the render resolution
    • Make a depth AOV in the RS AOV manager
    • Run the script
      = The resolution of the child is 1280x720 an there is no AOV in the childs RS AOV manager, but the parent has the same res as the original and a depth AOV in the manager (at least on my machine)

    But i figured out how to solve this by first inserting the child in the root of the Render Settings and then making it a child of the Redshift Deafult:

    import c4d
    import redshift
    from c4d import gui
    
    def MakeRsDefault(renderdata):
        default = renderdata.GetClone() # Clone active renderdata
        default.SetName("Redshift Default") # Set name
    
        # Set output format
        default[c4d.RDATA_FORMAT] = 1016606
        default[c4d.RDATA_FORMATDEPTH] = 2 # 32 bits
        default[c4d.RDATA_NAMEFORMAT] = 6 # name.000.ext
        doc.InsertRenderData(default) # insert new render setting
    
        # Set ACES 1.0
        defaultvprs = redshift.FindAddVideoPost(default, redshift.VPrsrenderer)
        defaultvprs[c4d.REDSHIFT_RENDERER_COLOR_MANAGEMENT_OCIO_VIEW] = 'ACES 1.0 SDR-video'
        defaultvprs[c4d.REDSHIFT_RENDERER_COLOR_MANAGEMENT_COMPENSATE_VIEW_TRANSFORM] = 1
    
        return default
    
    def MakeRsRaw(renderdata, parent):
        raw = c4d.documents.RenderData() # Clone active renderdata
        raw.SetName("Redshift Raw") # Set name
    
        # Set output format
        raw[c4d.RDATA_FORMAT] = 1016606
        raw[c4d.RDATA_FORMATDEPTH] = 2 # 32 bits
        raw[c4d.RDATA_NAMEFORMAT] = 6 # name.000.ext
        doc.InsertRenderData(raw) # insert "redshift raw"
    
        # Set Raw
        rawvprs = redshift.FindAddVideoPost(raw, redshift.VPrsrenderer)
        raw[c4d.RDATA_RENDERENGINE] = redshift.VPrsrenderer # Set Redshift as render
        rawvprs[c4d.REDSHIFT_RENDERER_COLOR_MANAGEMENT_OCIO_VIEW] = 'Raw'
        rawvprs[c4d.REDSHIFT_RENDERER_COLOR_MANAGEMENT_COMPENSATE_VIEW_TRANSFORM] = 0
        doc.InsertRenderData(raw, parent) # Make "redshift raw" a child of redshift default
    
        return raw
    
    def main():
        active = doc.GetActiveRenderData() # Get active renderdata
    
        # Check if Redshift is installed
        vprs = redshift.FindAddVideoPost(active, redshift.VPrsrenderer)
        if vprs is None:
            return
        # Check if Redshift is active render
        if active[c4d.RDATA_RENDERENGINE] == 1036219:
            parent = MakeRsDefault(active)
            child = MakeRsRaw(active, parent)
        else:
            gui.MessageDialog('Only works with Redshift Rendersettings')
            return
    
    
        # Set project settings for linear workflow
        doc[c4d.DOCUMENT_LINEARWORKFLOW] = 1
        doc[c4d.DOCUMENT_COLORPROFILE] = 0
    
        doc.SetActiveRenderData(parent) # set new setting as the active render setting
        parent.SetBit(c4d.BIT_ACTIVERENDERDATA)
        c4d.EventAdd()
    
    # Execute main()
    if __name__=='__main__':
        main()
    

    Regards
    Bonsak

    posted in Cinema 4D SDK •
    Child render setting does not inhertit from parent

    Hi
    I'm making a script that:
    1 Copies (clones) the active render setting
    2 Inserts a new one based on the clone
    3 Then makes a new RS rendersetting
    4 Inserts the new RS render setting as a child of the clone in step 2

    But when the child is inserted, it's settings are not inherited from the parent. The "Inherit Parent Behavior" is active on the child but when i right click on a parameter in the child render setting the "Inherit Parent Setting" is grayed out.

    import c4d
    import redshift
    from c4d import gui
    
    def main():
        active = doc.GetActiveRenderData() # Get active renderdata
    
        default = active.GetClone() # Clone active renderdata
        default.SetName("Redshift Default") # Set name
        redshift.FindAddVideoPost(default, redshift.VPrsrenderer)
        default[c4d.RDATA_RENDERENGINE] = redshift.VPrsrenderer # Set Redshift as render
        doc.InsertRenderData(default) # insert new render setting
    
        raw = c4d.documents.RenderData() # Make new renderdata
        raw.SetName("Redshift Raw") # Set name
        redshift.FindAddVideoPost(raw, redshift.VPrsrenderer)
        raw[c4d.RDATA_RENDERENGINE] = redshift.VPrsrenderer # Set Redshift as render
        doc.InsertRenderData(raw, default) # insert "redshift raw" as a child of redshift default
    
        doc.SetActiveRenderData(default) #set new setting as the active render setting
        c4d.EventAdd()
    
    # Execute main()
    if __name__=='__main__':
        main()
    

    12eb8526-2832-4b02-b809-094af86dc559-image.png
    24ed2070-7b56-429d-8664-e3d73c55782d-image.png

    I was expecting that the child would default to inheriting settings from its parent.
    Any help appreciated

    Regards
    Bonsak

    posted in Cinema 4D SDK •
    RE: How can i set custom Databases paths in prefs with python?

    Ok. I figured it out. The ID was wrong. It was supposed to be 465001634

    -b

    posted in Cinema 4D SDK •
    RE: How can i set custom Databases paths in prefs with python?

    Hi
    I managed to delete my original plugin 🙂 So now im recreating it. But when i run this plugin now with the findplugin argument, it returns None. As stated higher up in the thread im trying to set custom database paths in prefs on startup.

    import c4d
    import os, sys
    
    
    def PluginMessage(id, data):	
    	if id == c4d.C4DPL_PROGRAM_STARTED:
    		# try: 
    		# Get plugin object
    		plugin = c4d.plugins.FindPlugin(1040566)
    
    		# Print plugin object
    		print('Plugin ', plugin)
    		plugin.GetDescription(c4d.DESCFLAGS_DESC_0)
    		dbPaths = plugin[c4d.PREF_DATABASE_PATHS]
    		print('Existing DB paths {}').format(dbPaths)
    

    Any help appreciated.

    Regards
    Bonsak

    posted in Cinema 4D SDK •
    RE: How can i set custom Databases paths in prefs with python?

    Thanks! Works like a charm!

    -b

    posted in Cinema 4D SDK •
    RE: How can i set custom Databases paths in prefs with python?

    So im trying to get this to work inside our startup plugin. I can set new database paths but i cant read the existing ones. So im constantly overwriting the paths field.

    import c4d
    import os, sys
    
    def PluginMessage(id, data):	
    	if id == c4d.C4DPL_PROGRAM_STARTED:
    		try: 
    			# Get plugin object
    			plugin = c4d.plugins.FindPlugin(1040566)
    			# Print plugin object
    			print('Plugin {}').format(plugin)
    
    			# Get existing paths
    			dbPaths = plugin[c4d.PREF_DATABASE_PATHS]
    			# Print existing paths
    			print('Existing DB paths {}').format(dbPaths)
    
    			# Set new paths
    			dbPaths = dbPaths + "\n" + "S:/_3D_Central/Maxon/Racecar-Assets-Redshift" 
    			plugin[c4d.PREF_DATABASE_PATHS] = dbPaths
    
    			# Print new paths
    			print('New DB paths {}').format(dbPaths)
    
    		except KeyError: 
    			sys.exit(1)
    

    print('Existing DB paths {}').format(dbPaths) doesnt print anyting even though there are entries in the Databases field.
    Am i doing something wrong?

    Regards
    Bonsak

    posted in Cinema 4D SDK •
    RE: How can i set custom Databases paths in prefs with python?

    Thanks! Ill try that.

    Regards
    Bonsak

    posted in Cinema 4D SDK •
    How can i set custom Databases paths in prefs with python?

    Hi
    I have a python startup plugin that sets texture paths in Prefs>File Assets! with SetGlobalTexturePaths(...) for all workstations and render slaves. Is there a similar method for setting custom paths for node material Asset Databases (below the File Assets field) ?
    c5385534-5590-4fa6-a08b-fd3c08bbfab2-image.png

    Any help appreciated.

    -b

    posted in Cinema 4D SDK •
    RE: Setting texture paths with plugin on startup

    Omg! I had an old version of the plugin defined in the Plugins list in prefs that set the paths to [].
    Blush Deluxe!
    Sorry for wasting your time. Works perfectly fine.

    Regards
    Bonsak

    posted in Cinema 4D SDK •
    RE: Setting texture paths with plugin on startup

    I just tried the plugin on some other machines in the studio and it doesnt show newly set paths in prefs there either.

    Regards
    Bonsak

    posted in Cinema 4D SDK •
    RE: Setting texture paths with plugin on startup

    Good for you 🙂
    If i implement the script you linked to in my plugin like this:

    import c4d
    from c4d import storage
    
    import os
    
    
    def PluginMessage(id, data):
    	if id == c4d.C4DPL_PROGRAM_STARTED:
    
    		desktopPath = storage.GeGetC4DPath(c4d.C4D_PATH_DESKTOP)
    		homePath = storage.GeGetC4DPath(c4d.C4D_PATH_HOME)
    
    		# Gets global texture paths
    		paths = c4d.GetGlobalTexturePaths()
    
    		# Checks if the paths already exist in the global paths
    		desktopPathFound = False
    		homePathFound = False
    
    		for path, enabled in paths:
    			if os.path.normpath(path) == os.path.normpath(desktopPath):
    				desktopPathFound = True
    
    			if os.path.normpath(path) == os.path.normpath(homePathFound):
    				homePathFound = True
    
    		# If paths are not found then add them to the global paths
    		if not desktopPathFound:
    			paths.append([desktopPath, True])
    
    		if not homePathFound:
    			paths.append([homePath, True])
    
    		paths.append(['S:/_3D_Central/Maxon/tex', True])
    
    		# Sets global texture paths
    		c4d.SetGlobalTexturePaths(paths)
    
    		# Prints global texture paths
    		print(c4d.GetGlobalTexturePaths())
    

    it does print that all three paths are set but none of them are visible in the prefs.
    I need to do this from a plugin as it will be used to set renderslaves texture env on the fly from job to job.

    Regards
    Bonsak

    posted in Cinema 4D SDK •
    RE: Setting texture paths with plugin on startup

    I did some more testing and the variable is actually not getting set from the plugin. It only works when i run the script version manually after startup.

    The strange thing is that when the plugin is executed it prints the result of c4d.GetGlobalTexturePaths(), and that does return the path, but when i run c4d.GetGlobalTexturePaths() in the python console after startup and the plugin is finished running, it returns an empty list "[]". And the list is empty in prefs.
    Why is that?

    Regards
    Bonsak

    posted in Cinema 4D SDK •
    RE: Setting texture paths with plugin on startup

    Thats weird.
    Im on R20.030 RB257898 with win 10.0.17134 and nvidia 391.35

    The problem is that even thought the variable is defined...

    c4d.GetGlobalTexturePaths()
    [['S:\\_3D_Central\\Maxon\\tex\\GSG_EMC_Redshift', True]]
    

    ...it does not work. C4d will only find textures in that directory if the paths is actaully visible in the list in prefs.

    Regards
    Bonsak

    posted in Cinema 4D SDK •
    Setting texture paths with plugin on startup

    Hi
    Im making a tiny plugin that will grab an environment variable from the os and set it as a texture path in the preferences Files -> Paths -> File Assets -> Paths
    The plugin prints that the path has been set but the path is not listed in prefs.

    import c4d
    import os
    
    def PluginMessage(id, data):
    	if id == c4d.C4DPL_PROGRAM_STARTED:
    		# path = os.environ['RC_TEXTURE_PATHS']
    		path = "S:/_3D_Central/Maxon/tex"
    		print 'The path to be set {}'.format(path)
    		print 'Existing paths {}'.format(c4d.GetGlobalTexturePaths())	
    		c4d.SetGlobalTexturePaths([[path, True]])
    		print 'New paths {}'.format(c4d.GetGlobalTexturePaths())
    		c4d.EventAdd()
    

    When i run the code in a script in the editor, it works and the paths shows in the list in prefs

    import c4d
    import os
    
    def main():
        #path = os.environ['RC_TEXTURE_PATHS']
        path = "S:/_3D_Central/Maxon/tex"
        print 'The path to be set {}'.format(path)
        print 'Existing paths {}'.format(c4d.GetGlobalTexturePaths())
        c4d.SetGlobalTexturePaths([[path, True]])
        print 'New paths {}'.format(c4d.GetGlobalTexturePaths())
    
    if __name__=='__main__':
        main()
    ``` Any help appreciated
    
    Regards
    Bonsak
    posted in Cinema 4D SDK •
    RE: Get userdata Button state on object in Python tag

    Ah! So event_data['msg_data']['id'] is the id of the userdata.
    Didnt read your code comments 🙂
    Thanks alot!

    Regards
    Bonsak

    posted in Cinema 4D SDK •
    RE: Get userdata Button state on object in Python tag

    R20 20.0.30
    0_1542379593819_userdata-button.c4d

    posted in Cinema 4D SDK •
    RE: Get userdata Button state on object in Python tag

    Thanks!
    I couldnt get it to work without modifying it like this:

    def message(msg_type, data):
        if msg_type == c4d.MSG_NOTIFY_EVENT:
            event_data = data['event_data']
            if event_data['msg_id'] == c4d.MSG_DESCRIPTION_COMMAND:
                #print event_data['msg_id']
                if event_data['msg_data']['id'][1].id == 18:
                    print "Button Pressed"
                #desc_id = event_data['msg_data']['id']
                #if desc_id[1].id == 17: # The ID of the User Data
                #    print "Button Pressed"
    
    def main():
        obj = op.GetObject()
        
        # Check if we already listen for message
        if not obj.FindEventNotification(doc, op, c4d.NOTIFY_EVENT_MESSAGE):
            obj.AddEventNotification(op, c4d.NOTIFY_EVENT_MESSAGE, 0, c4d.BaseContainer())
    

    Regards
    Bonsak
    EDIT m_adam: Fixed your code snippet

    posted in Cinema 4D SDK •
    Get userdata Button state on object in Python tag

    Hi
    I have a userdata button on a null and a python tag on that null. In the tag i try to get the state of the button on the object:

    import c4d
    #Welcome to the world of Python
    
    def message(id, data) :
      if id == 17:
          print "UserData-ID: ", data["descid"][1].id
    

    This only works if the userdata button is on the tag. How can i get the state of the userdata botton on the object from inside the python tag?

    Regards
    Bonsak

    posted in Cinema 4D SDK •
    RE: Set Tracers "trace link" (inExclude) field from python tag

    Awesome! Thanks.

    Regards
    Bonsak

    posted in Cinema 4D SDK •