Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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. lasselauch
    3. Posts
    • Profile
    • Following 2
    • Followers 2
    • Topics 25
    • Posts 101
    • Best 14
    • Controversial 0
    • Groups 0

    Posts made by lasselauch

    • RE: Plugin module import freezes on startup

      Hi Ferdinand,
      I was essentially just forwarding this message from the developer of the licence framework. Sorry for not being clearer in the first place.
      I showed him your answer, and here is his response. Please let me know if I can be of any further assistance.

      Hi Ferdinand! I totally understand you so I'll write my findings in this mail instead. I'm not after help with my code, I just want to report the bug I found.

      The pyz file is part of python and allows you to package modules in a zip file for easier distribution, it has nothing to do with obfuscation in our case, it's just easier for the end user to copy one file instead of multiple folders and files.

      My finding with the 10mb file freeze comes from my trial and error. If I compile our licensing framework to work with Python 3.7-3.9 the resulting size is below 10mb, same if I compile for 3.9-3.11, same for 3.10-3.13 or what ever combo I do that ends up in less than 10mb pyz file the C4D plugin will read it but if I compile any combo where the pyz file ends up being more than 10mb the freeze happens.
      Let's say I compile for C4D 2026 it will work if I compile for 3.9-3.11 and it will work for 3.11-3.13 but it won't work for 3.9-3.13, exactly after 10mb. That ends me up thinking something is going on on C4D side.

      Lasselauch sadly seemt o have packaged the project a bit weird, thus Demo_Script.py is pointing wrongly. With "it doesn't happen when running a script" I mean when you run a script from Extensions -> User Scripts.
      Here is another zip with all different file combos for you to try out with yourself: https://www.swisstransfer.com/d/1f1d457f-89fe-4fef-80fd-2185c0ebe34c
      As you can see, using 3.9-3.13 freezes C4D but 3.9-3.11 and 3.11-3.13 does not. The internal code is exactly the same except that they package different PyArmor frameworks. I have double-checked the code and there is no execution-difference between the different pyz files.

      And the whole thing about obfuscation, honestly I'm just a dev that aescripts hired to add their licensing system to python and they want to protect the code so in that area I'm just doing what I'm told.

      //Jacob Danell

      posted in Cinema 4D SDK
      lasselauchL
      lasselauch
    • Plugin module import freezes on startup

      Hi Maxon/Cinema4D devs!

      I'm currently working with aescripts on developing their licensing system for python and for C4D. The license script is packaged in a pyz file for easy of distribution and the plugin script simply imports the pyz file to get access to the licensing system.

      One problem we're facing is that for C4D plugins C4D gets stuck on startup when showing Initializing Plugins 100%. After a lot of trial and error I found out that this happens ONLY when the pyz file is bigger than ~10mb.

      This doesn't happen if you run a script that imports the pyz. Only for plugins that gets loaded on startup.

      Here's a link to a demo repo for you to try it out and hopefully can figure out what's causing this:

      https://www.dropbox.com/scl/fo/87yyir1y6g6qrbi4mv6yr/AEwz6XxVyFuecXqlwVWxsus?rlkey=4yt2c6abiw1hdys5hgujjsre3&st=ymbhaxr5&dl=0

      Any ideas on why that is and how to best prevent the freeze are welcome!

      Thanks & Cheers,
      Lasse

      posted in Cinema 4D SDK python macos windows 2026 2025
      lasselauchL
      lasselauch
    • RE: Importing pythonapi from ctypes freezes C4D

      Hi Ferdinand, thanks for the reply and I totally understand the out of scope of support part!
      Thanks!


      Regarding the freeze, my system specs are:
      15", Apple M2 2023
      macOS 13.5.2 (22G91)
      C4D 2024.4.0
      Just trying to import ctypes freezes C4D instantly.


      Regarding the SpecialEventAdd() case:
      I essentially want to act after a threaded operation is finished. So the last line of my threaded function calls:
      c4d.SpecialEventAdd(ids.PLUGIN_ID_EXPORT)

      To distinguish between different types of export I thought I could use the p1 (x) e.g.: c4d.SpecialEventAdd(ids.PLUGIN_ID_EXPORT, x)

      However when using this inside my dialog, I'm not sure how to receive the different p1 or p2 integers inside the CoreMessage():

      def CoreMessage(self, id, msg):
          if id == ids.PLUGIN_ID_EXPORT:
              logger.info("PLUGIN_ID_EXPORT Message")
              if msg == x:
                  logger.info("Finished thread Message")
                  do_some_logic_here()
                  return True
          return False
      

      So what I'm asking is: I think different int are sufficient enough for my case, but I'm not sure how to receive those correctly within the CoreMessage or Message of a commanddata plugin.

      Thanks again,
      Lasse

      posted in Cinema 4D SDK
      lasselauchL
      lasselauch
    • RE: Importing pythonapi from ctypes freezes C4D

      Hi @m_adam,
      yes, that is correct. However, I experience a freeze everytime I do:
      from ctypes import pythonapi
      which I need either way.

      posted in Cinema 4D SDK
      lasselauchL
      lasselauch
    • Importing pythonapi from ctypes freezes C4D

      Hi there,
      I've just noticed something slightly odd.. While doing the following:

      from ctypes import pythonapi, c_void_p, py_object
      

      either in a script or plugin, Cinema4D freezes instantly.

      I came across this issue, because I wanted to implement a way to react to my SpecialEventAdd() messages. I stumbled upon this example:

      https://github.com/Rokoko/rokoko-studio-live-cinema4d/blob/ba4bd7a3c7eb814b13296a7ef564b0024efb0c4d/rokoko_utils.py#L37

      Is this still the way to go in 2024 to receive the SpecialEventAdd() p1 or p2 messages? And why is this instantly freezing C4D on my MacBook Air M2? 🙂

      Cheers,
      Lasse

      posted in Cinema 4D SDK s24 macos python
      lasselauchL
      lasselauch
    • RE: How to find the CallCommand id for Redshift 'Convert and Replace with Nodes'

      AFK currently, but I think you can open the "Script Log..." from the Extensions Menu to check the ID's right!?

      posted in Cinema 4D SDK
      lasselauchL
      lasselauch
    • RE: Detect Menu/Manager while hovering...

      Thanks, for the clarification. @ferdinand

      posted in Cinema 4D SDK
      lasselauchL
      lasselauch
    • Detect Menu/Manager while hovering...

      With "Customize Commands..." we are able to "restrict" certain commands to certain "managers" or "menus". I'm wondering if it's possible to detect these managers within a cmd-data-plugin while the mouse is hovering over a certain area.

      Imagine a popup filled with different content based on the currently hovered manager i.e. object-manager, material-manager, take-manager...!

      customize-cmds.png

      Is there a way to detect the underlying context of the mouse via python..?

      Cheers,
      Lasse

      posted in Cinema 4D SDK python maxon api classic api
      lasselauchL
      lasselauch
    • RE: Arranging Objects by order of Object Manager

      I could make a recursive iteration to go through all of the document's objects but that would slow it down significantly...

      Yeah, but that's basically the way to go... Not sure if the following yields faster results:

      def get_next_element(op):
          if not op:
              return
          if op.GetDown():
              return op.GetDown()
          while (not op.GetNext()) and op.GetUp():
              op = op.GetUp()
          return op.GetNext()
      
      def main():
          obj = doc.GetFirstObject()
              
          while obj:
              # act on obj
              print(obj.GetName())
      
              obj = get_next_element(obj)
      

      Always wondered what approach would yield faster results...

      Feel free to do some testing, would love to hear your results. 🙂

      posted in Cinema 4D SDK
      lasselauchL
      lasselauch
    • RE: Arranging Objects by order of Object Manager

      My guess is that iterating over with enumerate BaseDocument.GetObjects(self) would be efficient enough..?

      For example:

      all_objs = doc.GetObjects()
      for i, obj in enumerate(all_objs):
          # Distance can be whatever float or integer
          your_dist = i * 27
          pos = c4d.Vector(your_dist, 0, 0) 
          obj.SetAbsPos(pos)
      
      posted in Cinema 4D SDK
      lasselauchL
      lasselauch
    • Japanese Language Interface – Problems

      Hi there,

      I'm currently having a japanese customer for my AEC4D-PRO plugin that complains, that the plugin isn't behaving correctly in R23. In older C4D-Versions the plugin seems to behave correctly.

      At first, I thought the problem lies within string encoding. However at further testing, it works for the customer if he changes his "Interface Language" to English. So it's not the typical string encoding when transferring Objects between the two programs.

      I'm actually a bit lost, how this language setup is intertwined with the plugin itself. Sadly, I don't have the time to test the Japanese Language myself, so I thought if anyone has experienced these kind of issues before he or she might jump in and help.

      If you want to test it yourself, feel free to download the 14-day trial here:
      https://aescripts.com/aec4d/

      Thanks so much.

      Cheers,
      Lasse

      posted in Cinema 4D SDK r23
      lasselauchL
      lasselauch
    • RE: Detect closing of Document

      I guess I found a workaround... I cannot show the whole code involved but something along those lines:

      I have a Treeview that stores an absolute path abs_path of different documents... Now, I just check if one of these filepaths is in my open documents paths via: get_all_docs_paths()

      def get_all_docs_paths():
      
          all_docs_paths = []
      
          first = c4d.documents.GetFirstDocument()
          while first:
              folder = first.GetDocumentPath()
              abs_path = os.path.join(folder, first.GetDocumentName())
              all_docs_paths.append(abs_path)
              first = first.GetNext()
          
          return all_docs_paths
      

      If yes, the document is open, if not it is closed.

      Cheers,
      Lasse

      posted in Cinema 4D SDK
      lasselauchL
      lasselauch
    • RE: Detect closing of Document

      Thanks, @mp5gosu ...!

      @zipit said in Detect closing of Document:

      The easiest way would be to use some kind of plugin node for that. I currently do not see a way to do this in a GeDialog, but I might be wrong. We will discuss that tomorrow in the SDK Team, to see if the others know a clever way to do that. Just wanted to make sure that you do not run down a rabbit hole with no exit 😉

      Hehe, yeah that's exactly what I thought when looking at MSG_DOCUMENTINFO . Thanks for the quick answer, Ferdinand. Looking forward to your thoughts and ideas...

      Cheers,
      Lasse

      posted in Cinema 4D SDK
      lasselauchL
      lasselauch
    • Detect closing of Document

      I basically want to react in my GeDialog if my active document has been closed.
      I'm currently looking at MSG_DOCUMENTINFO but there's no flag for a closed document... one other idea would be to listen to a CallCommand for example via c4d.MSG_DESCRIPTION_COMMAND?

      What would be the best way to approach this..?

      Thanks,
      Lasse

      posted in Cinema 4D SDK
      lasselauchL
      lasselauch
    • RE: Drag and Drop "Command" from Treeview

      @mp5gosu Damn. That's really not the answer I wanted to hear, Robert! 😸

      posted in Cinema 4D SDK
      lasselauchL
      lasselauch
    • Drag and Drop "Command" from Treeview

      Hey everyone,

      I'm currently developing a treeview-plugin for all my scripts/presets etc.. I was wondering if it is possible to drag and drop items of said treeview directly to my layout.

      I'm currently thinking along those lines:

      In my declared ListItem (obj) I have a property of Instance which can hold the reference to the CommandPlugin for each script.

          @property
          def Instance(self):
              # of course this just a placeholder (but a valid one...)
              return c4d.plugins.FindPlugin(600000174)
      

      In the GenerateDragArray I will create an Array with my said Instance/Reference, also I've tried setting different flags for GetDragType to c4d.DRAGTYPE_COMMAND etc....

          def GenerateDragArray(self, root, userdata, obj):
              if obj.IsSelected:
                  return [obj.Instance]
              return None
      
          def GetDragType(self, root, userdata, obj):
              return c4d.DRAGTYPE_COMMAND
      
          def SetDragObject(self, root, userdata, obj):
              return obj.Instance
      

      Drag and Drop "Command" from Treeview

      ...but, sadly it's NOT working as I would expect... 🙂

      Is this possible with python in general, or a limitation? What am I missing?

      Thanks,
      Lasse

      posted in Cinema 4D SDK
      lasselauchL
      lasselauch
    • RE: developers.maxon.net – Offline?

      Had one aswell....

      explorer_2020-11-23_12-19-58.png

      a rather old one... 🙄 ...haha.

      posted in General Talk
      lasselauchL
      lasselauch
    • RE: developers.maxon.net – Offline?

      👷 yep, back online... here in hamburg. 😁

      posted in General Talk
      lasselauchL
      lasselauch
    • developers.maxon.net – Offline?

      Hi there,

      https://developers.maxon.net/ appears to be offline? Is this just a short outage..?

      firefox_2020-11-23_10-37-30.png

      Cheers,
      Lasse

      posted in General Talk
      lasselauchL
      lasselauch
    • RE: Rename object by filename

      @zipit said in Rename object by filename:

      PS: @lasselauch I know that you meant this in a light-hearted manner, but "let-me-google-that-for-you" can be misconstrued. People have different information needs and things that seem trivial or obvious to you, are not for them. Programming can be a confusing topic and we would like this to be a welcoming place for everyone and subsequently stay away from all "RTFM"-notions.

      Yep, definitely meant in a light-hearted manner!!! 🙂
      You're totally right.. that's why I provided the correct answer.

      Cheers,
      Lasse

      posted in Cinema 4D SDK
      lasselauchL
      lasselauch