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

    Create script/plugin for quick layout switch?

    PYTHON Development
    0
    4
    1.1k
    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.
    • H
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            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

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