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. pyxelrigger
    3. Topics
    • Profile
    • Following 2
    • Followers 0
    • Topics 16
    • Posts 29
    • Best 0
    • Controversial 0
    • Groups 0

    Topics created by pyxelrigger

    • pyxelriggerP

      logic problem to obtain the entire hierarchy of the object

      Cinema 4D SDK
      • python windows 2024 • • pyxelrigger
      2
      0
      Votes
      2
      Posts
      382
      Views

      i_mazlovI

      Hi @pyxelrigger ,

      Unfortunately your question is out of the scope of support on this forum, namely:

      We cannot provide support on learning C++, Python, or one of their popular third-party libraries.

      With that's said, I'm kind of missing the main idea behind your question, in other words what are you trying to achieve?

      Is it just another (e.g. simply more convenient) data structure for the hierarchy? If so, then you're free to create whatever data structure fits your need the best. For example, check a very fast draft code snippet below.

      Is it that you want to track changes of the hierarchy? If so, then you might need to come up with some more complex setup, e.g. involving using the c4d.EVMSG_CHANGE message. Please, refer to a great Ferdinand's answer here: Best way to detect an object has been deleted?

      Please also consider visiting our How to ask Questions section of the support procedures for your future postings.

      Cheers,
      Ilia

      A super draft example of nested lists hierarchy representation:

      import c4d doc: c4d.documents.BaseDocument class HierarchyObject: def __init__(self, op): self.op = op self.children = [] child = self.op.GetDown() if op else doc.GetFirstObject() # recursion entry point while child: self.addChild(HierarchyObject(child)) # recursion child = child.GetNext() def addChild(self, child): self.children.append(child) def toString(self, indentation: int = 0): indentStr: str = '\t' * indentation name: str = self.op.GetName() if self.op else '___root___' s: str = f'{indentStr}<{name}' if self.children: s += ':' for child in self.children: s += f'\n{child.toString(indentation + 1)}' s += f'\n{indentStr}' s += '>' return s def __str__(self): return self.toString() if __name__=='__main__': root: HierarchyObject = HierarchyObject(None) print(root)
    • pyxelriggerP

      Drag Object in GeDialog.AddEditText

      Cinema 4D SDK
      • windows 2024 python • • pyxelrigger
      4
      0
      Votes
      4
      Posts
      526
      Views

      ferdinandF

      Hey @pyxelrigger,

      sure you can use the string custom GUI. You could also use a base link or a filename field which be the more natural solutions for this. But you asked for AddEditText and that is what I answered.

      Cheers,
      Ferdinand

    • pyxelriggerP

      FBX does not export

      Cinema 4D SDK
      • windows 2024 python • • pyxelrigger
      2
      0
      Votes
      2
      Posts
      340
      Views

      ferdinandF

      Hey @pyxelrigger,

      Thank you for reaching out to us. It is always difficult for me in these cases to find the right words. Generally speaking, what you ask us to do here, is out of scope of support: Either debug your code or finish the script for you.

      What I see here is primarily a user who is overwhelmed by his or her own code. Especially when you are less experienced: Just break up things into manageable pieces where you know what they do and you can confirm that they do what you mean them to do. And when I run into troubles, the first thing I would also remove is all UI fluff. You could for example define your paths just at the top of the script. Finally, NEVER do this c4dpath = '{}\{}'.format(c4dfilesfolder, file), this is just bound to go wrong. Use os.path.join instead.

      You will have to debug your script yourself.

      Cheers,
      Ferdinand

      Result:

      Exported /Users/f_hoppe/Desktop/test/Untitled 2.fbx Exported /Users/f_hoppe/Desktop/test/Untitled 1.fbx

      Code (mostly AI generated):

      import c4d import os def SetFbxExportSettings() -> None: """Set the FBX export settings. """ plugin: c4d.plugins.BasePlugin = c4d.plugins.FindPlugin(c4d.FORMAT_FBX_EXPORT, c4d.PLUGINTYPE_SCENESAVER) data: dict = {} plugin.Message(c4d.MSG_RETRIEVEPRIVATEDATA, data) settings = data.get("imexporter", None) if settings is None: raise ValueError("Could not retrieve the FBX export settings.") settings[c4d.FBXEXPORT_FBX_VERSION] = False settings[c4d.FBXEXPORT_ASCII] = False settings[c4d.FBXEXPORT_CAMERAS] = False settings[c4d.FBXEXPORT_LIGHTS] = False settings[c4d.FBXEXPORT_SPLINES] = False settings[c4d.FBXEXPORT_INSTANCES] = False settings[c4d.FBXEXPORT_SELECTION_ONLY] = True settings[c4d.FBXEXPORT_GLOBAL_MATRIX] = False settings[c4d.FBXEXPORT_SDS] = c4d.FBXEXPORT_SDS_GENERATOR settings[c4d.FBXEXPORT_TRIANGULATE] = False settings[c4d.FBXEXPORT_SAVE_NORMALS] = True settings[c4d.FBXEXPORT_SAVE_VERTEX_COLORS] = False settings[c4d.FBXEXPORT_SAVE_VERTEX_MAPS_AS_COLORS] = False settings[c4d.FBXEXPORT_UP_AXIS] = c4d.FBXEXPORT_UP_AXIS_Y settings[c4d.FBXEXPORT_TRACKS] = True settings[c4d.FBXEXPORT_BAKE_ALL_FRAMES] = False settings[c4d.FBXEXPORT_PLA_TO_VERTEXCACHE] = False settings[c4d.FBXEXPORT_BOUND_JOINTS_ONLY] = False settings[c4d.FBXEXPORT_TAKE_MODE] = c4d.FBXEXPORT_TAKE_TAKES settings[c4d.FBXEXPORT_MATERIALS] = True settings[c4d.FBXEXPORT_EMBED_TEXTURES] = False settings[c4d.FBXEXPORT_SUBSTANCES] = True settings[c4d.FBXEXPORT_BAKE_MATERIALS] = True settings[c4d.FBXEXPORT_BAKEDTEXTURE_WIDTH] = 1024 settings[c4d.FBXEXPORT_BAKEDTEXTURE_HEIGHT] = 1024 def GetInputDocumentPaths() -> list[str]: """Opens a directory dialog to select a folder and returns a list of Cinema 4D documents that are in the selected folder or its subfolders. """ path: str = c4d.storage.LoadDialog( c4d.FILESELECTTYPE_ANYTHING, "Animations", c4d.FILESELECT_DIRECTORY) if not os.path.isdir(path): raise ValueError("The given path is not a directory.") files: list[str] = [] for root, _, filenames in os.walk(path): for filename in filenames: if filename.endswith('.c4d'): files.append(os.path.join(root, filename)) return files def main() -> None: """Main function. """ # Set the settings and get the inputs. SetFbxExportSettings() filePaths: list[str] = GetInputDocumentPaths() # Export the documents in the list to FBX. for path in filePaths: # Load the document. doc: c4d.documents.BaseDocument = c4d.documents.LoadDocument(path, c4d.SCENEFILTER_OBJECTS) if not doc: raise ValueError(f"Could not load the document at {path}.") # Get the first object in the document and set it as the selection so that it is exported. obj: c4d.BaseObject = doc.GetFirstObject() if not obj: raise ValueError(f"The document at {path} does not contain any objects.") doc.SetSelection(obj, c4d.SELECTION_NEW) # Export the document to FBX and close it. fbxPath: str = path.replace('.c4d', '.fbx') c4d.documents.SaveDocument(doc, fbxPath, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, c4d.FORMAT_FBX_EXPORT) c4d.documents.KillDocument(doc) print(f"Exported {fbxPath}") if __name__ == '__main__': main()
    • pyxelriggerP

      Plugin in the top bar with Python

      Cinema 4D SDK
      • 2024 python windows • • pyxelrigger
      2
      0
      Votes
      2
      Posts
      359
      Views

      ferdinandF

      Hey @pyxelrigger,

      Thank you for reaching out to us. You will have to overwrite PluginMessage in your plugin to do that. You might want to have a look at this thread.

      Cheers,
      Ferdinand

    • pyxelriggerP

      Get alls ID User Data of Object

      Cinema 4D SDK
      • 2024 python windows • • pyxelrigger
      2
      0
      Votes
      2
      Posts
      323
      Views

      ferdinandF

      Hey @pyxelrigger,

      Thank you for reaching out to us. BaseList2D.GetUserDataContainer should do the trick.

      Cheers,
      Ferdinand

    • pyxelriggerP

      is it possible for me to create a script, outside of c4d

      Cinema 4D SDK
      • python 2024 windows • • pyxelrigger
      2
      0
      Votes
      2
      Posts
      346
      Views

      M

      Hi @pyxelrigger there is no real way to execute a script outside of Cinema 4D without Cinema 4D. The only option is to execute c4dpy which is a complete Cinema 4D instance run as a python interpreter. For more information about it, please read c4dpy manual. Note that you have the same limitation as a standalone Cinema 4D so you can't execute multiple c4dpy instance at the same time or they need to be in different folders.

      Except that note that tkinter does not come by default with Cinema 4D, so you will need to install manually and don't really officially support, so it may or may not works, but from our personal experience in the SDK team, it should work.

      Cheers,
      Maxime.

    • pyxelriggerP

      when I use .GetMg() after the script is finished it seems to return the right results

      Cinema 4D SDK
      • python 2024 windows • • pyxelrigger
      3
      0
      Votes
      3
      Posts
      467
      Views

      pyxelriggerP

      Thanks, buddy! It worked. To be honest, I never really understood what Message(c4d.MSG_UPDATE) was all about, and now ExecutePasses is new to me

    • pyxelriggerP

      Is it possible somehow with python to change the path that for example the Open Project window will open?

      Cinema 4D SDK
      • • • pyxelrigger
      2
      0
      Votes
      2
      Posts
      332
      Views

      M

      Hi @pyxelrigger sadly since S26 this is not anymore possible, previously it was saved within the world container like so

      wc = c4d.GetWorldContainerInstance() wc[c4d.WPREF_FILEPATH_ALL] = r"C:\Users\m_adam\Documents\MAXON\Build\2023.000_381745"

      This is still used by c4d.storage.LoadDialog and c4d.storage.SaveDialog functions, but internally we don't use anymore these functions.

      I've open a ticket internally as this is a regression.

      Cheers,
      Maxine.

    • pyxelriggerP

      is it possible for me to have a plugin that modifies some function of cinema 4d?

      Cinema 4D SDK
      • • • pyxelrigger
      11
      0
      Votes
      11
      Posts
      1.4k
      Views

      ferdinandF

      Hello @pyxelrigger,

      without any further activity before Wednesday, the 16.03.2022, we will consider this topic as solved and remove the "unsolved" state from this topic.

      Thank you for your understanding,
      Ferdinand

    • pyxelriggerP

      Get height and width (cm) of a camera focus area

      Cinema 4D SDK
      • python sdk r21 • • pyxelrigger
      5
      0
      Votes
      5
      Posts
      1.1k
      Views

      pyxelriggerP

      Hmm thank you!! It's not as difficult as I imagined I just had to make a change in the formula for some case, I used:

      x = focaldistance*math.tan(h/2)*1

      96f1960e87e92c0bd8b3f677b453172d.gif

    • pyxelriggerP

      why the line break doesn't happen when I use self.GetString() in self.AddMultiLineEditText()

      Cinema 4D SDK
      • • • pyxelrigger
      4
      0
      Votes
      4
      Posts
      607
      Views

      M

      Hi @pyxelrigger, with the latest update of Cinema 4D (R24 SP1), fixed the issue with the Python Console, and it is now able to properly handle pairs of carriage return and new line characters.

      Cheers,
      Maxime.

    • pyxelriggerP

      Save width and height of Dialog

      Cinema 4D SDK
      • • • pyxelrigger
      2
      0
      Votes
      2
      Posts
      362
      Views

      r_giganteR

      Hi @pyxelrigger thanks for reaching out us.

      With regard to your question, I'm a bit confused cause you mentioned having your layout opened every time with a default width and height (regardless of the values stored in the layout) whilst, on the contrary, you pasted a method belonging to GeDialog::Open().

      Question: is a dialog or a layout to open every time with a default width and height?

      Cheers, R

    • pyxelriggerP

      get initial position in python tag

      Cinema 4D SDK
      • r19 r20 r21 classic api python • • pyxelrigger
      5
      0
      Votes
      5
      Posts
      770
      Views

      ManuelM

      hi,

      without further feedback i'll set this thread as solved tomorrow.

      Cheer,
      Manuel

    • pyxelriggerP

      Update button

      Cinema 4D SDK
      • python r20 r19 r21 • • pyxelrigger
      4
      0
      Votes
      4
      Posts
      943
      Views

      pyxelriggerP

      Thanks! seems to work well!

      the problem is that apparently it only runs on the tag, if I set the option as a UserData of my object, it doesn't work

    • pyxelriggerP

      how can i get the id of each target? note: I will add more with c4d.CallButton ()

      Cinema 4D SDK
      • python r21 classic api • • pyxelrigger
      3
      0
      Votes
      3
      Posts
      495
      Views

      M

      While the method provided by Zipit Is fine, it is not 100% reliable.

      here how to achieve, unfortunately, the ELEMENT_Count value is hardcoded and no way for you to retrieve it.

      constraintTag = doc.GetActiveTag() targetCount = constraintTag[c4d.ID_CA_CONSTRAINT_TAG_PARENT_TARGET_COUNT] for i in range(targetCount): CONSTRAINT_ELEMENT = 10 # This is hardcoded targetId = c4d.ID_CA_CONSTRAINT_TAG_PARENT_TARGET_COUNT + i * CONSTRAINT_ELEMENT + 1 print(constraintTag[targetId])

      Cheers,
      Maxime.

    • pyxelriggerP

      how is it possible to check if the object is being "opened"? with python

      Cinema 4D SDK
      • python r20 r19 r21 • • pyxelrigger
      11
      0
      Votes
      11
      Posts
      1.5k
      Views

      r_giganteR

      Well @pyxelrigger thanks for clarifying the final scope.

      Since, as already stated, folding or unfolding a scene entry doesn't generate any valuable message to be intercepted, the sole - brute force - hack you might try to implement in Python would be to implement a MessageData plugin which constantly checks for the folded/unfolded state of the entries in the scene and eventually delete the unfolded one.

      This approach carries strong performances penalties to the whole Cinema 4D UI because you need to constantly traverse the scene and depending on the scene size this could strongly affect Cinema performances.

      If there are no further question please mark the thread as solved.

      Best, R