ok. I know not your department, but thats nuts.
Thanks!
ok. I know not your department, but thats nuts.
Thanks!
@Dunhou @i_mazlov, thanks so much both. This really helped.
Where is the Redshift Python documentation, I tried the normal Redshift online help https://help.maxon.net/r3d/cinema/en-us/#search-python and the python plugin help.
I am looking for a way to read out the multipass names of my redshift rendersettings, such as 'Z' or 'depth'
in the code below the script successfully gives me the path at the very last print statement. I am looking for the other MP filenames
filepath 2: C:\Users\thoma\Dropbox\trauminc\projects\832-control_net\work\CG\c4d\balls\render\balls-v010\balls-v010.png, 1023671
defined in the render settings. such as balls-v010_depth0034
def render(self, url):
print(f"are we rendering? {self.rendering}")
if self.rendering:
return
self.rendering = True
doc = c4d.documents.GetActiveDocument()
docClone = doc.GetClone()
rd = doc.GetActiveRenderData()
print(f"render data: {rd}")
print(f"multipass {rd.GetFirstMultipass()}")
bmPreview = c4d.bitmaps.BaseBitmap()
bmPreview.Init(int(rd[c4d.RDATA_XRES]), int(rd[c4d.RDATA_YRES]))
print("starting to render")
result = c4d.documents.RenderDocument(
docClone, rd.GetData(), bmPreview, c4d.RENDERFLAGS_EXTERNAL, th=None
)
if result == c4d.RENDERRESULT_OK:
filepath = rd[c4d.RDATA_PATH]
print(f"filepath: {filepath}")
if "$" in filepath:
filepath = self.resolve_and_normalize_path(filepath, doc, rd)
file_format = rd[c4d.RDATA_FORMAT]
print(f"file_format: {file_format}")
filepath += self.get_extension_for_format(file_format)
print(f"filepath 2: {filepath}, {file_format}")
bmPreview.Save(filepath, file_format)
self.send_image_to_server(filepath, URL)
self.rendering = False
def resolve_and_normalize_path( self, tokenized_path, doc, rd):
# Define the rpData dictionary to resolve tokens
rpData = {
"_doc": doc,
"_rData": rd,
"_rBc": rd.GetData(),
# "_frame": 2, # Replace this with the actual frame number if available
# Add any other needed data here
}
# Convert the tokens to their actual values
filepath = c4d.modules.tokensystem.StringConvertTokens(tokenized_path, rpData)
# Check if the filepath is absolute
if not os.path.isabs(filepath):
# If not, make it absolute
base_path = doc.GetDocumentPath()
filepath = os.path.join(base_path, filepath)
# Normalize the file path to use the standard slashes for your OS
filepath = os.path.normpath(filepath)
return filepath
When I render via my plugin in RS, it renders one additional image with different colour settings. file: balls-v010.png
in this image:
I have looked at https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/a12cca185a7a07fb20aa34520799b66007839e1e/scripts/05_modules/token_system/tokensystem_render_r17.py#L9 and its super helpful but doesn't help me with the AOVs
@i_mazlov thanks so much!
some super useful insights here. I think I will have eventually to move to C++
Hey!
I am working on a python plugin that sends renders to a webserver. It works well right now through a "render and send image" button in a dialog window the plugin creates.
I would love to send images when the viewport camera is moved or something changes in the scene with a visual impact, with a little timeout.
basically the same as the redshift IPR, it updates only when something relevant to the scene changes.
ChatGPT helped me find one way to do this by listening to messages.
class SceneChangeListener(c4d.plugins.MessageData):
BASE_URL = "http://127.0.0.1:8000/inputs" # Base part of the URL
def __init__(self, plugin):
self.last_render_time = 0
self.plugin = plugin
def CoreMessage(self, id, bc):
# print(f"core message received: {id}")
if id == c4d.EVMSG_CHANGE:
print(f"my message received:{id}")
current_time = time.time()
if current_time - self.last_render_time >= 0.6: # 300ms delay
print(f"CoreMessage render triggered:{id}")
self.last_render_time = current_time
self.plugin.render(url=self.BASE_URL)
# Trigger your render function here
return True
this works but it gets triggered a lot for anything.
Next step is filtering a bit by messages. Ideally only when something that changes the main view, or I listen to only the messages I want to respond to, such as material manager, timeline, camera moves.
I played around with a few more messages I found here:
https://developers.maxon.net/docs/py/2024_2_0/consts/MSG_C4DATOM_PLUGINS.html. None of the few I tried were really that useful.
I guess these dont exist? Happy to try another approach.
@Dunhou is it possible to get in touch for you for freelance development? I couldn't find any email or socials.
Hi @ferdinand, your links really helped me a lot, and I managed to write a script that starts a render and sends the rendered image to a web service.
Can the SDK grab the live preview image from the redshift IPR? I assume not looking at the documentation: https://developers.maxon.net/docs/py/2023_2/search.html?q=redshift&check_keywords=yes&area=default
would love to see that being added. the HUD is amazing for internal tooling
slightly worrying that I hit this bug right away after my first 30 minutes to scripting in c4d.
this looks amazing. Can't wait to see arnold / RS