Setting the active document with COFFEE ?



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

    On 06/05/2008 at 14:23, xxxxxxxx wrote:

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

    ---------
    Hi,

    I would like to use COFFEE to load a scene 'docX' and merge it with the currently open scene. So I load the scene 'docX' with 'LoadDocument', clone the objects and insert them to the other scene and delete 'docX' with 'KillDocument'. This all works fine and has indeed already been discussed in several threads here.

    Now the only niggle: Let's say I have two documents open,   'docA' and 'docB'. 'docA' is my currently active document. I now run my script, 'docX' gets loaded, everything is copied into 'docA' and 'docX' is deleted. Now for some reasons 'docB' is the active document, instead of 'docA'! Of course this is confusing for the user and I would like to avoid that.

    So my question: Is there a way to set the active document with COFFEE? I've seen that in the C++ SDK there's a 'SetActiveDocument()' function, but I cannot find something similar in the COFFEE documents.

    Thanks for your help.



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

    On 06/05/2008 at 15:47, xxxxxxxx wrote:

    When there is more than one document, and you load and close the donor document, Cinema 4D is probably defaulting the active document to the 'next' in the list from one being closed. You would think that it would go back to the last active document - but it probably isn't keeping track in that way.

    Unfortunately, COFFEE doesn't have an option to load a document but not insert it into the document list like C++.

    So, you'll need to keep a reference to the active document. I think that you might be able to use the BaseList2D::SetBit(BIT_ADOC) to make the document active since BaseDocument is derived from BaseList2D:

    activedoc->SetBit(BIT_ADOC);



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

    On 07/05/2008 at 01:17, xxxxxxxx wrote:

    Robert, thanks for the tip. Unfortunately this doesn't seem to work. For some reason the bit isn't really set, i.e. if I write:

    doc->SetBit( BIT_ADOC );
    println( doc->GetAllBits() );

    the 'ActiveDocument' bit still isn't set. Even if I put an EventAdd() somewhere or delete the bit of other documents, it doesn't have any effect.

    However, there is a 'Next Document' command available from the Command Manager. So this seems to work:

    while( GetActiveDocument() != doc )
    CallCommand( 13857 );

    Of course, I have to make sure that 'doc' is really in the document list, otherwise I enter an infinite loop...



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

    On 07/05/2008 at 07:30, xxxxxxxx wrote:

    That's sad to hear. What's the use of a BIT_ADOC (explicitly - Active Document) if it can't be set? I realize that how bits are set changed in R10 but not before that.

    At least you found a workaround that works.



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

    On 14/05/2008 at 05:30, xxxxxxxx wrote:

    I am afraid there is no direct way to make a document the active one in COFFEE.

    cheers,
    Matthias


Log in to reply