Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. nullobject
    N
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 3
    • Best 0
    • Controversial 0
    • Groups 0

    nullobject

    @nullobject

    0
    Reputation
    3
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    nullobject Unfollow Follow

    Latest posts made by nullobject

    • RE: How can I update custom tokens when rendering with the Takes System?

      Amazing, thank you @ferdinand!

      I figured GetActiveDocument() was the issue, so I was attempting to use takeData.GetCurrentTake() instead in the GetResolutionTakes callback but it still was exactly the same issue where the active take does not change. I didn't know about the callback data argument that already contains the correct document state in data[0], so thank you for letting me know to use that instead and pointing me to further details in the RegisterToken Documentation.

      Replacing:

      • doc = c4d.documents.GetActiveDocument() with doc = data[0]
      • renderData = doc.GetRenderData(takeData) with renderData = data[1]

      to get the following code below worked perfectly:

      def GetCameraName(data):
      	doc = data[0]
      	bd = doc.GetRenderBaseDraw()
      	sceneCam = bd.GetSceneCamera(doc)
      	camName = sceneCam.GetName()
      	return camName.upper()
      
      
      def GetResolutionActive(data):
      	renderData = data[1]
      	renderResX = round(renderData[c4d.RDATA_XRES])
      	if renderResX >= 1920:
      		return "highRes"
      	else:
      		return "lowRes"
      

      Thank you again very much for the help! Really appreciate it.

      posted in Cinema 4D SDK
      N
      nullobject
    • RE: How can I update custom tokens when rendering with the Takes System?

      Hi @ferdinand,

      Thank you for taking the time to installing to take a look and reply. Sorry that I didn't provide the proper amount of information in the original post.

      I'm using Cinema 4D R23.110 on Windows 10.

      Were you rendering one take at a time or multiple takes at the same time with "Render Marked Takes to PV"?

      However, I haven't been able to figure out how to get the custom tokens to update correctly when rendering with the Takes System—whether it's multiple takes or even just one take that has different settings than the currently active take in the viewport.

      I should have specified when I mentioned rendering multiple takes with the Takes System, I meant rendering using the "Render All Takes to PV" and/or "Render Marked Takes to PV" buttons rather than rendering multiple takes by manually activating one take at a time. Apologies if that wasn't clear originally.

      —

      Screen Recording:

      To make it even more clear, here's a screen recording of what happens when I activate each individual take at a time and render each one individually (getting the correct filenames) vs. rendering all marked takes at the same time (getting incorrect filenames):
      https://drive.google.com/file/d/1rRGYZ_-yEjxo29TBiiJXLjq9vt1HPXRU/view

      If there's any issues playing the video, you should be able to download the video from the link with the download button in the top-right.

      —

      Filenames Comparison:
      For easier comparison, here is a screenshot of the two list of filenames side-by-side below:

      Tokens_Not_Updating_With_Multiple_Takes-Screenshots-v001.jpg

      Notice that on the left, when rendering one take at a time, the tokens update correctly. The camera name changes and the low/high resolution token changes to match the correct camera and resolution for each take.

      On the right, when rendering with multiple takes all at once, the tokens do not update correctly. The camera name and low/high resolution tokens are exactly the same for every single file—which is the token names for the document's active take (the 2000px take) and not updating accordingly with each take.

      Correct names (rendering one take at a time):

      customtokens_takestest-400px-CAM400PX-activeDocLowRes-takeLowRes.jpg
      customtokens_takestest-1024px-CAM1024PX-activeDocLowRes-takeLowRes.jpg
      customtokens_takestest-1920px-CAM1920PX-activeDocHighRes-takeHighRes.jpg
      customtokens_takestest-2000px-CAM2000PX-activeDocHighRes-takeHighRes.jpg
      customtokens_takestest-Main-CAMMAIN-activeDocLowRes-takeLowRes.jpg

      Incorrect names (rendering multiple/all takes at the same time with "Render All/Marked Takes to PV"):

      customtokens_takestest-400px-CAM2000PX-activeDocHighRes-takeHighRes.jpg
      customtokens_takestest-1024px-CAM2000PX-activeDocHighRes-takeHighRes.jpg
      customtokens_takestest-1920px-CAM2000PX-activeDocHighRes-takeHighRes.jpg
      customtokens_takestest-2000px-CAM2000PX-activeDocHighRes-takeHighRes.jpg
      customtokens_takestest-Main-CAM2000PX-activeDocHighRes-takeHighRes.jpg

      Hope that all makes sense.

      Let me know if you did in fact render multiple takes at the same time with "Render All/Marked Takes to PV" and it worked for you.

      —

      RE: Octane

      I had to deactivate Octane as the render engine though, since I do not have Octane here.
      [...]
      The only thing I could think of, is that Octane might not implement the integration of the Take System correctly with their rendering interface.

      That is strange since the render settings in the file I've provided only use "Standard Renderer" and doesn't contain any Octane. I do have Octane installed so it may have accidentally got its way into the file somehow, but I've only I've only been testing with "Standard Renderer." The video recording above was using the C4D file downloaded from my original post in this thread and the renderer is already set to "Standard" when I opened the re-downloaded the file. In any case, I'm not using or concerned with Octane renderer in particular with this issue as long as it works with the Standard renderer.

      —

      Thanks again for any help.

      posted in Cinema 4D SDK
      N
      nullobject
    • How can I update custom tokens when rendering with the Takes System?

      Hello,

      I'm working on creating custom tokens and they work perfectly when I'm just rendering straight to Picture Viewer with what's actively set up in my viewport.

      However, I haven't been able to figure out how to get the custom tokens to update correctly when rendering with the Takes System—whether it's multiple takes or even just one take that has different settings than the currently active take in the viewport.

      Basically, my code as currently written is only able to grab the currently active settings in the document the moment I hit render, rather than applying the selected Take first and updating the custom token with the Take's settings and re-updating with each Take if there's multiple takes.

      Any guidance here would be greatly appreciated. Thank you!

      —

      I've attached a C4D example file set up with multiple takes with different cameras and width x height output sizes to test the tokens, if you need it to understand what I'm talking about with these custom tokens when rendering straight to Picture Viewer vs. rendering multiple takes at the same time.

      C4D Example File:
      customTokens_takesTest.c4d

      Python Script:
      customTokens_takesTest.pyp

      Full script below as well if you don't want to download the Python script file:

      import c4d
      import maxon
      
      def GetCameraName(data):
      	"""
      	A token that looks for the active camera name and reformats the name
      	to be all uppercase for the filename.
      
      	Works with single render when just rendering straight to viewport with
      	current active settings, but does not work when rendering with
      	Takes that have different settings than the currently active settings.
      	"""
      	doc = c4d.documents.GetActiveDocument()
      	bd = doc.GetRenderBaseDraw()
      	sceneCam = bd.GetSceneCamera(doc)
      	camName = sceneCam.GetName()
      	return camName.upper()
      
      
      def GetResolutionActive(data):
      	"""
      	A token that looks for the active rendering setting's output width
      	and determines whether the filename should be "highRes"or "lowRes"
      	based on the width.
      
      	Works with single render when just rendering straight to viewport
      	with current active settings, but does not work when rendering with
      	Takes that have different settings than the currently active settings.
      	"""
      	doc = c4d.documents.GetActiveDocument()
      	renderData = doc.GetActiveRenderData()
      	renderResX = round(renderData[c4d.RDATA_XRES])
      	if renderResX >= 1920:
      		return "activeDocHighRes"
      	else:
      		return "activeDocLowRes"
      
      
      def GetResolutionTakes(data):
      	"""
      	An alternate version of the GetResolutionActive(data) above with an
      	attempt to use Take Data, but seems I might not be writing this correctly?
      	Still doesn't update correctly when rendering with Takes.
      	"""
      	doc = c4d.documents.GetActiveDocument()
      
      	takeData = doc.GetTakeData()
      	if takeData is None:
      		return
      
      	take = takeData.GetCurrentTake()
      	if take is None:
      		return
      
      	renderData = take.GetRenderData(takeData)
      	renderResX = round(renderData[c4d.RDATA_XRES])
      
      	c4d.EventAdd()
      
      	if renderResX >= 1920:
      		return "takeHighRes"
      	else:
      		return "takeLowRes"
      
      #----------------------------------------------------------------------------------------------------------------------------------------
      # Register Tokens
      #----------------------------------------------------------------------------------------------------------------------------------------
      if __name__=="__main__":
      	for registeredToken in c4d.modules.tokensystem.GetAllTokenEntries():
      		if registeredToken.get("_token") in ["camUppercase", "lowHighResActive", "lowHighResTakes"]:
      			exit()
      
      	# Filename Parsed Tokens
      	c4d.plugins.RegisterToken("camUppercase","[TEST] Uppercase Cam Name", "CAMNAME", GetCameraName)
      	c4d.plugins.RegisterToken("lowHighResActive","[TEST] Low/High Resolution [Active Doc]", "lowRes / highRes", GetResolutionActive)
      	c4d.plugins.RegisterToken("lowHighResTakes","[TEST] Low/High Resolution [Current Take]", "lowRes / highRes", GetResolutionTakes)
      
      posted in Cinema 4D SDK python
      N
      nullobject