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
    • Register
    • Login

    Question about organizing and utilizing custom python plugin libraries

    Cinema 4D SDK
    python
    2
    2
    278
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      BretBays
      last edited by

      That title might be a bit confusing. Allow me to try and explain.

      I have some ideas for a few different commandData plugins. The plugins pertain to extracting Joint Weight Data from certain deformers. For example extracting a skinned ffd deformer into joint weights. Extracting the effects of a delta mush deformer into joint weights, extracting a spline deformer to joint weights, etc.

      My thought is to make X number of different commandData plugins for each instance, however all of these plugins use a lot of shared functions that I have written to do sort of generalized steps of each of these(Get the weight tag from an object, Creating weight maps from something, etc). So my question is how do I organize this in such a way so that I can have my shared libraries separate that each command data plugin could access without each plugin needing all the duplicate functions in there? I hope that makes some sense.

      It's kind of like being able to do:

      import myLib
      myLib.myFunction()
      

      But I am not sure how to manage that across multiple plugins that will be source protected, and how to go about distributing that.

      I hope this make some sort of sense.

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @BretBays
        last edited by ferdinand

        Hey @BretBays,

        Thank you for reaching out to us. You might want to have a look at the Python Libraries Manual. Since Cinema 4D 2024.0 there is also mxutils.LocalImportPath which automates injecting module paths and reloading such imported modules (I probably should update the Python libraries manual).

        The "flaw" of all these approaches is that while you still encrypt your plugins pyp file, the imported module(s) py file(s) will not and cannot be encrypted. You can either ship your common functions unencrypted or develop your plugin as a multi module solution (so that you do not have to replicate your code across plugins) and then package up the plugin into a singular file. There are some Python tools like pysconcat and pymerger which can help you with that. But you should be aware that these can fail when you have complex dependencies. You could also serve the py-cache of your modules, but that will not really stop anyone who wants to read your code.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • First post
          Last post