Shared .coh file via include (via path?)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/05/2009 at 15:14, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   11 
    Platform:    Mac  ;  
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    I posted this at the end of another Include thread, but it may not have belonged there and I received no reply, so here goes with a more specific topic:
    I'd like to "include" a common function library(ies) into a variety of plugins I'm working on- each in its own directory, but I can't specify a path (or can't figure out how to from the SDK.)
       Mikael mentions in the related thread that "C4D searches all directories in the working directory for includes", but as soon as I move my common library out of any given folder either into the Plugins or into another folder withing Plugins, that plugin fails to load with
    COFFEE ERROR!
    (125) Error in 'include'
    File: TheFileFromWhichIremovedTheFolder.cof
    Line: ...

    Creating aliases for the include file doesn't work (makes sense), so do I really need to keep a copy of this common library (still a work in progress) and replace every copy in each plugin's folder everytime I do a minor update during development? Please let me know if there is some way to specify a path for the include or if I'm doing something else wrong. I don't suppose I could just read the file as a concatinated string and use that as my own "include()" function...

    Here is the directory structure I want:

    .../Applications/MAXON/CINEMA4DR11/plugins
    from above plugins/:
    .../plugins/
        myGenericFunctions.coh
        PluginTypeAFolder
            PluginTypeAsharedFunctions.coh
            Plugin1AFolder
                Plugin1menu.cof
                Plugin1script.coh
                Plugini1specificFunction.coh
            Plugin2AFolder
                Plugin2menu.cof
                Plugin2script.coh
                Plugini2specificFunction.coh
        PluginTypeBFolder
            PluginTypeBsharedFunctions.coh
            Plugin1BFolder
                Plugin1menu.cof
                Plugin1script.coh
                Plugini1specificFunction.coh
            Plugin2BFolder
                Plugin2menu.cof
                Plugin2script.coh
                Plugini2specificFunction.coh
            Plugin3BFolder
                Plugin3menu.cof
                Plugin3script.coh
                Plugini3specificFunction.coh

    How do I structure and include to access        PluginTypeAsharedFunctions.coh from Plugin1Ascript.coh
    or
    myGenericFunctions.coh from PluginAscript.coh

    Thanks,
    Graham



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/05/2009 at 16:23, xxxxxxxx wrote:

    You can't redirect COFFEE include paths as far as I know. When Mikael says 'all directories in working directory', he if of course meaning the plugin folder of the registered plugin being considered (i.e.: /plugins/PluginTypeBFolder/Plugin1BFolder). Have you tried using ../ in the include reference, say:

    include "../PluginTypeBsharedFunctions.coh"

    Maybe this will look at the parent folder?

    An include() method (which would need a different name as include is already a keyword) would need to be more than a file reader - it would need to be a COFFEE interpreter or it would need to read the file and concatenate the text into the current .cof file and reload the COFFEE plugin. Sounds like a bad idea to me.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/05/2009 at 18:18, xxxxxxxx wrote:

    Two variations might be:
    1 Add your functions in a document in:
    CINEMA 4D Rxx / resource/ modules/coffee
    as "myfunctions.cof"

    (Check the original "convenience.cof" doc there how it is written)
    Now all your functions are read "system wide" by coffee.
    They are not included in a compile and need a restart of
    Cinema if edited.

    2 Use Symbolic Links.
    In Terminal:

    > <code>
    > cd "yourtargetdirectory" <- drag and drop from Finder and Enter
    > YOURDISC: yourtargetdirectory user$ ln -s "yoursourcedirectory"<- DragNDrop from Finder and Enter.
    > </code>

    or dload the freeware SymbolicLinker from:

    http://seiryu.home.comcast.net/~seiryu/symboliclinker.html

    Once you have a symbolic link you can copy it to anywhere you need.
    This way they should be included in a compile (not tested myself).

    I use symbolic links in my NET renders from my plugins folder
    to have the NET in sync with any plugins installed/edited.

    Cheers
    Lennart



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/05/2009 at 17:03, xxxxxxxx wrote:

    Thanks for the responses guys. I tried Roberts relative parent path suggestion which returns an error. I tried Lennarts suggestion which aliases the directory... I had already tried aliasing the file, but neither has worked. I also tried an absolute path suggestion by Matthias on the original thread: Have you tried absolute paths, something like include "c:\myincludes\myheader.h" ?, but it seems to have failed as well. Perhaps I'm doing something wrong, but I tried to paste in a path that I pulled from a terminal window. I tried to point it both to my original plugin directory, and to a copy I placed in the root Maxon directory, in case the spaces in the Cinema 4D folder path were problematic... both failed. I tried to get the path with GeGetRootFilename, but it also failed. I could do Lennart's idea of putting them in the resource folder during development, but then I'll still have to copy few dozen files accurately back into multiple roots when I want to compile. Here is my best effort so far

    > \>      var vRoot = GeGetRootFilename(); \>      println("GeGetRootFilename = ", vRoot); \>      println("GeGetRootFilename->GetName() = ", vRoot->GetFullString() ); \>      println("GeGetRootFilename->GetName() = ", vRoot->RemoveLast() ); \>      println("GeGetRootFilename->GetName() = ", vRoot->RemoveLast() ); \>      println("GeGetRootFilename->GetName() = ", vRoot->AddLast("includeTestOut.coh") ); \>      var vRootString = vRoot->GetFullString(); \>      var vRootStringQuoted = stradd("\u0022", vRootString, "\u0022"); \>      println("Quoted = ", vRootStringQuoted); \> //     include "/Users/myDisk/Desktop/C4DlocalVersions/MAXON/includeTestOut.coh" \>      include vRootStringQuoted; // this line and a dozen iterations of the previous line failed \>



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/05/2009 at 17:04, xxxxxxxx wrote:

    I wonder if a res level pointer like a webloc file might work... then I'd only have to figure out how to create one of these dangerous looking filetypes.
    G



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/05/2009 at 17:56, xxxxxxxx wrote:

    The symbolic link -should- work, it works in all other cases I've tried.
    You possible do the linking wrong (I did it all wrong before I "got" it).
    It sounds as if you tried to link to an already existing file (the "copy"
    you mention).
    The symbolic link process -creates- a file that is a carbon copy
    of the original.

    I'll see if I can try what you are trying to do
    (in a couple of days hopefully).

    Cheers
    Lennart



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/05/2009 at 03:45, xxxxxxxx wrote:

    Just did a quick test with a simple function in a "mytest.h" file
    stored on the desktop. I made a symbolic link of it in a pluginsfolder.
    The plugin then had a:
    include "mytest.h" in it and it reads it as well as compile it.

    A quick attempt to use a path to the desktop did not work
    (returns a "include error" on startup).

    Cheers
    Lennart



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/05/2009 at 13:58, xxxxxxxx wrote:

    Thanks for running the test. I tried it on an individual file and it works! I still can't get an entire folder to work, but I can live with that for now.

    Curiously, I can put an included x.coh file in a folder and place that in the root pluginA folder and it will be found from include "x.coh", i.e., it searches all subfolders. I can remove that subfolder and break the include. I can create a soft link to the folder as Lennart suggests above, and it will still be broken, but if I create a soft link to the x.coh file, the include works.

    Linking folders would be most ideal, but Lennart's linking with files directly will still save me hours of frustration.
    Thanks again,
    Graham



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/05/2009 at 14:15, xxxxxxxx wrote:

    There are no problems doing symbolic links of folders,
    it's done the same way as linking files.
    (I use that for my plugins folder (to my NET machines).

    Cheers
    Lennart


Log in to reply