Create script/plugin for quick layout switch?



  • On 29/06/2018 at 00:01, xxxxxxxx wrote:

    Hi! I've tried to copy data from the script log to create a "simple" Python script that makes it quick and easy to switch between UI layouts using keyboard shortcuts (for example to switch from 'Modeling' to 'UV Edit' using any of the Function keys). But I can't find out a way to make it work... and I can't find anything useable in the 'Customize Commands' window either.

    Is there already a plugin for this or can anyone help create this script? I believe it would be very useful, it would help speed up basic workflow.

    Thanks!

    / Frederik



  • On 29/06/2018 at 05:38, xxxxxxxx wrote:

    Hi tennet,

    It's possible by loading directly the layout file. Then you can assign a key to this script.
    Here a quick example

    import c4d
    import os
      
    def main() :
        libPath = c4d.storage.GeGetC4DPath(c4d.C4D_PATH_LIBRARY)
        layoutPath = os.path.join(libPath, "layout")
        animPath = os.path.join(layoutPath, "Animate.l4d")
        c4d.documents.LoadFile(animPath)
      
    if __name__=='__main__':
        main()
    

    If you have any questions, feel free to ask :)
    Cheers,
    Maxime



  • On 30/06/2018 at 02:23, xxxxxxxx wrote:

    Thanks for your quick reply and example! I'm not good at Python scripting, but I tried to copy your example and just changed "Animate.l4d" to my layout name.. and assigned a shortcut for this script, but my layout isn't loaded.. What am I doing wrong? :)

    My script looks like this now:

    --

    import c4d
    import os

    def main() :
        libPath = c4d.storage.GeGetC4DPath(c4d.C4D_PATH_LIBRARY)
        layoutPath = os.path.join(libPath, "layout")
        animPath = os.path.join(layoutPath, "TENNET-modeling.l4d")
        c4d.documents.LoadFile(animPath)

    if __name__=='__main__':
        main()

    --

    Cheers,
    Frederik



  • On 30/06/2018 at 02:46, xxxxxxxx wrote:

    Hi again,

    I just figured it out. I needed to add the first line 'c4d.CallCommand(56000, 112) # Switch Layout' before your code above.. now it seems to work. :)

    Question — Why are the 'CallCommands' different when switching between different layouts (the numbers between the brackets are different). I noticed I couldn't use the same CallCommand when switching from 'UV Edit layout' to my 'Modeling layout' and vice verse?

    Thanks!
    Frederik


Log in to reply