External class refresh



  • On 26/10/2016 at 02:38, xxxxxxxx wrote:

    Hi I'm currently building a plugin structured as that:

    plugin.pyp
    ../class/MaClass.py

    I included succefully into my project and everthing is working nice. 
    The only annoying things is I need to close / re-open C4d for the change made in MaClass.py have an effect.
    Moreover I saw on the start it generate some pyc file. I tried to recreate them with py_compile but that affect nothing...
    So my ask is there a way for have something dynamic as a pyp file is? :)

    Thanks in advance.

    Another thing out of context:
    https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d.storage/index.html#c4d.storage.LoadDialog
    title is not described into Parametter but listed in the call.



  • On 27/10/2016 at 01:28, xxxxxxxx wrote:

    Hello,

    the "Reload" function currently only reloads the pyp files. *.py files are not re-evaluated (only on startup). So currently I don't see a way to reload *.py files at runtime.

    Thanks for reporting the issue in the documentation. For further bug reports (also on the documentation) please use the Bug Reports subforum.

    best wishes,
    Sebastian



  • On 27/10/2016 at 10:06, xxxxxxxx wrote:

    Please take a look at this post: Best Practice for Imports

    If you use the  localimport  class, your external Python modules will automatically reload.
    The newest minified version can be found here: https://gist.github.com/NiklasRosenstein/f5690d8f36bbdc8e5556

    Example:

    # localimport-v1.5_b64_lw=99
    exec("""import base64 as b, zlib as z; s={}; blob=b"\neJydGctu20bwrq8gkAPJmKXjBr0IZVCkSIGiRQ5B0UMFgqDIpbw1RRK7q9SykX/vzOyTItU4vVjL3ZnZeT/W/DiNQkXNOJ2zQz/\nus1Fm08PhpHifybPMlKgbtq+bh+yJTx3v2abpaymjfmzqnhNyMu7/Zo1Kt5uoquqTuh9FVRXxR/4AkNGnUbJBKsaH6Efh1gMd/n\nQ41rzPm/H4Lkbkz0xIPg6IfZf/gFvT+e1DAXzk9ogP3bh7U74r3sKpVIIPh0qdJyaLBL6ylHcaKWK9ZMm+lkwDZekmahkcAgWuq\niqRrO+yqVb38EewQVUtF8XHcWBZO1bscJDFH+JEH5O6pzUKGAH9YVSRx8HNqBP1kRGf1YEp+kru0ryrUKV1LxEGMOOqQhVWVRyB\nOgi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Rf7yBd/SxSpNicBJGD0IPnNSVh06Wahr0G2TeOvE6DOtWGLEDwj68OrD8\nk7/WxjyM3VBnjlrKcARVXmCUQf30CCC8ZQehB9+fMKQBWGUKSRQpH9ZUEWCicUuFt718XwsIXpIQzLr0040XH5nvW/5p7l4LN5F\nf0sGBTPNtqfo+l8hBjoOBNRcq/UJLe3twcQ9bTHf6bc9rxTY9fderB0s/kXDFzgoQ=="
    exec(z.decompress(b.b64decode(blob)), s)
    localimport=s["localimport"]; del blob, b, z, s;""")
      
    with localimport('.') as importer:
      importer.disable(['MaClass'])
      import MaClass
    

    Of course you are free to use the original uncompress or unminified source as well.

    Regards,
    Niklasl



  • On 28/10/2016 at 10:27, xxxxxxxx wrote:

    Thans you niklas is working fine :)
    A little suggestion it would be nice to be able to indent the code.I oftenly do if bool(1) : like that I can show  / hide some portion of my code in sublime ;) Not best practise but I like it ^^

    Since you didn't finnish all the lines when you indent the code it interpret it as indent into your code and not into the string.

    But it's just a detail who can be mannualy fixed ! Anyway thanks you :)

    EDIT : another things if in the subfile I use a module (for exemple c4d) and I imported c4d in the main file. If in the subfile I didn't import c4d it don't show any error but it's not working ;)


Log in to reply