Hi @i_mazlov ,
Thank you for confirming my solution.
Best regards,
Tomasz
Posts made by Futurium
-
RE: List of object visible by a camera within Safe Frames
-
RE: List of object visible by a camera within Safe Frames
Hi @mogh,
Thank you for your suggestion. Currently, I've developed a method where I replace a spherical camera view with a standard camera, capture what's visible, and rotate until I've covered the entire area. This approach meets my goals, although I'm still assessing its efficiency. Your idea of rendering the image and selecting from it sounds like another option and might be a good alternative. -
RE: List of object visible by a camera within Safe Frames
Hi @i_mazlov ,
I'm writing to follow up on my previous message about the issue with 360 cameras in my code as I haven't heard back. Could you please provide any updates or further guidance?
Best regards,
Tomasz -
Troubleshooting Safe Frame Calculations Across Different Takes in Cinema 4D
Hi,
I want to calculate the safe frame value for all takes, where each take has a different camera and possibly different render settings. If I manually change a take and run my code, it returns the same safe frame for all other takes as for the currently selected one, which is incorrect in my case. It seems the values used for safe frame calculations are not being updated when I iterate through takes via code. What am I missing? I've attached a simple test scene to test the code.
Best regards,
Tomaszimport c4d def grab_children_of_main_take(take_data): children = [] mainTake = take_data.GetMainTake() take = mainTake.GetDown() while take is not None: children.append(take) take = take.GetNext() return children def get_safe_frame_for_the_current_per_take(doc): bd = doc.GetRenderBaseDraw() safeframe = bd.GetSafeFrame() print(safeframe) def main(): c4d.CallCommand(13957) # Clear Console doc = c4d.documents.GetActiveDocument() take_data = doc.GetTakeData() if take_data is None: raise RuntimeError("Failed to retrieve the take data.") children_of_main_take = grab_children_of_main_take(take_data) print("Returned : " + str(len(children_of_main_take)) + " children of main take") for child_take in children_of_main_take: take_data.SetCurrentTake(child_take) doc.ExecutePasses(bt=None, animation=True, expressions=True, caches=True, flags=c4d.BUILDFLAGS_NONE) current_camera = child_take.GetCamera(take_data) print("\n--------------------------------------------------") print(f"Checking take {child_take.GetName()} with camera {current_camera.GetName()}") get_safe_frame_for_the_current_per_take(doc) if __name__ == '__main__': c4d.CallCommand(13957) # Clear Console main()
-
RE: Speed up rendering by transforming takes into frames
Hello @ferdinand
Thank you for your guidance. I'll follow your suggestion and reach out to the support team for assistance with my query.
Best regards,
Tomasz -
Speed up rendering by transforming takes into frames
Hi,
One solution we offer our customers requires several thousand takes for each set of renders. Each take only needs 30 seconds for rendering, but the preparation phase, which involves processing geometry with Redshift, is much longer. On average, we use one camera for every 500 takes, and the only changes between takes are material swapping and toggling some geometry's visibility. I've developed a Python script that logs changes to takes and creates an animation frame for each, significantly speeding up the rendering process when rendering as an animation compared to individual takes. Is there a way to achieve this increased rendering speed with takes without converting them into animation frames? Do you have any other suggestions for enhancing render speed?Best regards,
Tomasz -
RE: List of object visible by a camera within Safe Frames
Hi Ilia,
Thank you for guiding me in the right direction. I've revised my code following your advice, and it's working well with standard cameras. However, it's having difficulty with 360 cameras. The code successfully identifies larger objects but struggles to detect smaller ones, even after I increased the accuracy (step=1, radius=1). Do you have any suggestions?
Best regards,
Tomasz -
List of object visible by a camera within Safe Frames
Hi,
I'm looking for a Python solution that can return lists of all objects visible by a camera, including both standard and Redshift Spherical cameras, and within Safe Frames. I want to include all objects, even those partially visible. I've tried using ViewportSelect (code and test scene attached) and GeCollider, but I'm not getting the results I expected, and the code runs slowly. Could you provide some suggestions and a code snippet as a starting point?
Also - for testing purposes - for the attached scene and cameras, I expect a list of specific objects (below), not all objects currently returned by my script.
Expected results:
EnSuite_Flooring_24_Reset
Bed2_Flooring_14_Reset
Landing_Flooring_30_Reset
Bed4_Flooring_18_Reset
Bed4_Flooring_18_Reset
Upstairs1_Flooring_26_Reset
ColliderBest regards,
Tomaszimport c4d doc = c4d.documents.GetActiveDocument() bd = doc.GetActiveBaseDraw() frame = bd.GetFrame() def get_flooring_objects(): flooring_objects = [] doc = c4d.documents.GetActiveDocument() helper_node = doc.SearchObject("Helpers") helper_categories = helper_node.GetChildren() for helper_cat in helper_categories: if helper_cat.GetName() == "_Flooring": flooring_objects = helper_cat.GetChildren() return flooring_objects left = frame["cl"] right = frame["cr"] top = frame["ct"] bottom = frame["cb"] # Calculates the width and height of the screen width = right - left + 1 height = bottom - top + 1 print ("width : {}, height : {}".format(width, height)) # Creates a new ViewportSelect vpSelect = c4d.utils.ViewportSelect() # Initialise the ViewportSelect with a list of object ops = get_flooring_objects() vpSelect.Init(width, height, bd, ops, c4d.Mpolyedgepoint, True, c4d.VIEWPORTSELECTFLAGS_IGNORE_HIDDEN_SEL) our_list = [] c4d.CallCommand(13957) # Clear Console for w in range(width): for h in range(height): elements = vpSelect.PickObject(bd, doc, w,h, 1, c4d.VIEWPORT_PICK_FLAGS_OGL_IGNORE_Z) our_list.extend(elements) name_list = [] for el in our_list: name_list.append(el.GetName()) unique_list = sorted(set(name_list)) for name in unique_list: print ("Unique name: {}".format(name))
Scene for testing : https://we.tl/t-FLqG7LPcNu
-
RE: Boundary Edges to Spline in Python
Dear Ilia,
I greatly appreciate your assistance; it was precisely what I needed. Thank you for your guidance and I wish you a wonderful day.
Best regards,
Tomasz -
Boundary Edges to Spline in Python
Hi,
I am looking for assistance in automating a specific process in Cinema 4D using Python. My current manual method involves navigating to the Mode in the Attributes Panel, selecting Modelling and Mesh checking, and then opting for Check Mesh. Following this, I choose Boundary Edges and subsequently use the 'Edge to Spline' feature, which effectively transforms these edges into a spline.
This manual method serves its purpose well; however, my goal is to streamline this process through automation. I would greatly appreciate any guidance or suggestions on how to achieve this via a Python script. Automating this task would significantly enhance efficiency in my workflow.
Thank you for your time.
Best regards,
Tomasz
-
RE: Loading materials/meshes from Asset Browser (Cinema 4D R25) from Python
That's exactly what I was looking for. Thank you, Ferdinand
-
RE: Loading materials/meshes from Asset Browser (Cinema 4D R25) from Python
Hello Ferdinand,
I'm writing to revisit the issue previously discussed. Is there now Python support for this particular issue? Currently, I have a set of template materials in the Asset Browser. I have been loading them manually as required, which is manageable but not the most efficient method. It would be great if I could grab them directly from a script, preferably by their names. If name-based referencing isn't feasible, could I use their asset IDs instead?If this functionality is already in place, would you be able to share some code snippets? It would be greatly appreciated. Just for your reference, I'm currently using R26.107.
Best regards,
Tomasz -
RE: Grabbing camera position/rotation from Takes
Thank you, Ferdinand.
It looks like the only part I missed in my code was that extra line
doc.ExecutePasses(bt=None, animation=True, expressions=True, caches=True, flags=c4d.BUILDFLAGS_NONE)
After updating the code on my side - everything seems to be working fine.
Thank you again.
Best regards,
Tomasz -
Grabbing camera position/rotation from Takes
Hi,
I spent some time yesterday trying to develop a Python script, which travels through takes, grabbing camera position (which is changed every time by aligning to spline tag), creating a null object and copying camera Matrix to null. The part I'm struggling with is grabbing the camera position. I either got the original camera position, before it's been modified by aligning to spline property or value 0.
Below is my code and also attached scene, which I've been using for tests.
Am I missing something obvious?import c4d from c4d import documents list_of_takes = [] parent_name = "360_cams" def GetCategory(doc): takeData = doc.GetTakeData() if takeData is None: return mainTake = takeData.GetMainTake() take = mainTake.GetDown() while take is not None: list_of_takes.append((take)) take = take.GetNext() def CreateParentObject4360CamExport(doc): cam_export_parent = doc.SearchObject(parent_name) if cam_export_parent is not None: cam_export_parent.Remove() c4d.CallCommand(5140) # Null cam_export_parent = doc.SearchObject("Null"); c4d.CallCommand(1019940) # Reset PSR if cam_export_parent != None: cam_export_parent.SetName(parent_name) return cam_export_parent def CreateCopyOfTheCamera(currentCam,currentTake, doc,take_data): c4d.CallCommand(5103) # Camera camTemp = doc.SearchObject("Camera") c4d.CallCommand(1019940) # Reset PSR if camTemp != None: camTemp.SetName(currentTake.GetName()) print("current cam : "+ currentCam.GetName() + " and position " + str(currentCam.GetMg())) camTemp.SetMg(currentCam.GetMg()) c4d.EventAdd() return camTemp # Main function def main(): doc = documents.GetActiveDocument() takeData = doc.GetTakeData() if takeData is None: raise RuntimeError("No take data in the document.") cam_export_parent = CreateParentObject4360CamExport(doc) main_take = takeData.GetMainTake() GetCategory(doc) for child_take in list_of_takes: takeLoaded = takeData.SetCurrentTake(child_take) if takeLoaded == True: currentCam = child_take.GetCamera(takeData) cam2NullClone = CreateCopyOfTheCamera(currentCam,child_take,doc,takeData) cam2NullClone.InsertUnder(cam_export_parent) c4d.EventAdd() # Execute main() if __name__=='__main__': c4d.CallCommand(13957) # Clear Console main()
-
RE: Exporting data from Takes to a file
Hi Manual,
This is exactly what I needed. Thank you very much.
Best regards,
Tomasz -
RE: Exporting data from Takes to a file
Hi Manuel,
I've tested your solution and it works like a charm Thank you.
As a next step, I wanted to grab node transforms from takes. I tried with c4d.DescID(c4d.ID_BASEOBJECT_REL_POSITION), but I'm not able to get any data. Below is your code with added two extra lines to get the node position. I also attached a screenshot with details from one of the takes.Can you please help with the problem?
import c4d from c4d import gui # as Takes are BaseList2D, we can use GetNext, GetPred, GetUp, GetDown def GetNextTake(op): if op == None: return None if op.GetDown(): return op.GetDown() while not op.GetNext() and op.GetUp(): op = op.GetUp() return op.GetNext() def main(): takeData = doc.GetTakeData() visibilityDescID = c4d.DescID ( c4d.ID_BASEOBJECT_VISIBILITY_EDITOR) nodePositionAbs = c4d.DescID ( c4d.ID_BASEOBJECT_REL_POSITION) currentTake = takeData.GetMainTake() while currentTake: overrides = currentTake.GetOverrides() for override in overrides: descIDs = override.GetAllOverrideDescID() if visibilityDescID in descIDs: print ("take name", currentTake.GetName(), "node found", override.GetName(), "original object", override.GetSceneNode().GetName(), "value", override[visibilityDescID]) if nodePositionAbs in descIDs: print ("take name", currentTake.GetName(), "node found", override.GetName(), "original object", override.GetSceneNode().GetName(), "position", override[nodePositionAbs]) currentTake = GetNextTake(currentTake) # Execute main() if __name__=='__main__': main()
-
RE: Exporting data from Takes to a file
Hi Manuel,
Thank you. I'll test it and come back to you if I have any questions.
Best regards,
Tomasz -
RE: Exporting data from Takes to a file
Hi Manuel,
What I really need is a code snippet to travel thru all takes, list all nodes per take with visibility changed, as per the screenshot below.
https://i.imgur.com/qedKv2K.png
I'd like to also know if there is a way to find what else has been changed per object (like coordinates)
I already got a code to rebuild takes, from a text file, when the updated mesh is imported and replacing the current mesh on the scene, so that's the only part which I need to make the solution work
Best regards,
Tomasz -
Exporting data from Takes to a file
Hi,
I'm looking for a way to export info about objects, disabled for rendering, from take system, and use it later. I got a scene with hundreds of different viewpoints, each in separate take. If there are objects obstructing camera view, for that viewpoint, they I hide them for each take. That works great, and I'm big fan of Take System. The issue starts as soon as I want to bring updated mesh into my scene. As soon as the old mesh is deleted, and new mesh imported to the scene - all my references to previously hidden objects are gone (even the new mesh got identical hierarchy and names). As I understand Take Systems uses pointer to the scene node, rather than name of the object, which of course make sense.
To avoid hours of extra work every time when I bring updated mesh to c4d, to go thru all viewpoint and re-hide previously hidden objects, I'm looking for a solution to save info about hidden objects for each take, and then with the new mesh, just re-generate it in Python.
I checked all take examples on GitHub, as well as this forum, but was unable to find anything helpful for the task.Can you please help me with this problem?
Best regards,
Tomasz