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

    LoadFile(Filename file) does not work for layouts.

    Cinema 4D SDK
    c++ r20 windows
    2
    8
    2.5k
    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.
    • O
      Ogers
      last edited by

      Hello,
      I am trying to load a layout (.l4d file extension) using LoadFile() function but when I do this the Cinema4D will open with the loaded layout active, and then stop working. when I try to load other files like .c4d it loads them correctly.
      Am I doing something wrong here or is there another way to do this?
      Thank you.

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        hello,

        From where are you trying to switch the layout ?

        I've tested on the script manager and in the command line and it's working just as expected.
        If you want Cinema4D to launch with a particular layout you can also use the -layout argument.

        I'm waiting your feedback to have a chance to reproduce your issue.
        I'm assuming you are using the version R20.059.

        Cheers
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 2
        • O
          Ogers
          last edited by

          Hello @m_magalhaes
          I am putting the code under C4DPL_BUILDMENU.

          case C4DPL_BUILDMENU:     
          {
             Filename file = Filename("C:/Program Files/MAXON/Cinema 4D R20 
             Education/library/layout/myLayout.l4d");
             LoadFile(file);
             break;
          }
          

          I am using R20.028 but I don't think this changes anything. Maybe I am just putting the code on the wrong place.
          Thank you

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by Manuel

            Several things here,

            your path on windows should use backslash (\) and not slash (/)
            and you should have two.

            "C:\\Program Files\\MAXON\\Cinema 4D R20 Education\\library\\layout\\myLayout.l4d"
            

            A better way to do this is to use operator so your path will be compatible with all OS.

            // Create a filename to point to "Application directory/library/layout/Animate.l4d"
            const Filename file = GeGetStartupPath() + Filename("library") + Filename("layout") + Filename("Animate.l4d");
            // load the layout.
            Bool result = LoadFile(file);
            // check the result.
            if (!result)
            	DiagnosticOutput("can't load the layout");
            		
            

            I've tested this code in PluginMessage() using C4DPL_COMMANDLINEARGS and C4DPL_PROGRAM_STARTED

            Cheers
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            O 1 Reply Last reply Reply Quote 3
            • O
              Ogers @Manuel
              last edited by

              I tried the code that you have tested but I am still having the same problem. As I have mentioned in the beginning the layout does load but then Cinema4D stops working (Not Responding)
              Capture.PNG

              1 Reply Last reply Reply Quote 0
              • ManuelM
                Manuel
                last edited by Manuel

                @m_magalhaes said in LoadFile(Filename file) does not work for layouts.:

                C4DPL_COMMANDLINEARGS and C4DPL_PROGRAM_STARTED

                That's why i mention those PluginMessage ids.Sorry, I forgot to say If you use that code in C4DPL_BUILDMENU Cinema4D will stop working (or throw an exception if you are in debug mode for an "Acces Violation Reading Location")

                Are you still in C4DPL_BUILDMENU ?

                Cheers
                Manuel

                MAXON SDK Specialist

                MAXON Registered Developer

                O 1 Reply Last reply Reply Quote 1
                • O
                  Ogers @Manuel
                  last edited by

                  Yes I tried with the mentioned PluginMessage ids but I tried only on C4DPL_PROGRAM_STARTED and it stopped working so I thought the other will not work as well.
                  I tried C4DPL_COMMANDLINEARGS now and this one only seems to work for me.
                  Thank you 🙂

                  1 Reply Last reply Reply Quote 0
                  • ManuelM
                    Manuel
                    last edited by

                    Again sorry, I've tested with the Studio version.

                    Using C4DPL_PROGRAM_STARTED case I can confirm this "bug" with a Educational version and a Demo version.
                    Not with the Studio version.

                    Maybe something with that extra "popup" windows on those both versions.

                    Cheers
                    Manuel.

                    MAXON SDK Specialist

                    MAXON Registered Developer

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