LoadFile(Filename file) does not work for layouts.



  • 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.



  • 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



  • 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



  • 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



  • 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



  • @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



  • 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 :)



  • 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.