PDA

View Full Version : Merge document.. How please


indeep
03-23-2010, 03:20 PM
How to merge a document into current one, i guess using:
MergeDocument() ......? why there is no examples in the sdk documentation or somewhere to use this kind of commands :(

Lets say i just want to merge the complete file: "C:\test.c4d" into current document. Whats the simplest code to just do that?

Until maxon makes a sdk for "normal people" I depend on you C4D scripting gods :P

Thanks

tcastudios
03-23-2010, 03:49 PM
Have you tried Alloc a Xref object and fill the linkfield with your string
and then CurrentStateTo ?
(Not tried myself but it might be a "dirty" way:) )

Otherwise, by code , you need to open your file, select all
objects in it, Clone them and paste them and finally doc->Kill().

Cheers
Lennart

indeep
03-23-2010, 04:03 PM
Well, thats a vvverrrryyy dirrty way! :P I guess that shall work, i hope is not so dirty to do it inside a plugin in a hidden way ? or shall i keep searching for the "real coding" solution?

Thanks Lennart, i like dirty tips ;) :P

tcastudios
03-23-2010, 09:30 PM
It actually shouldn't be to "dirty" as it actually works :)

Did you even try?
This is my quick test (Note the use of "SetFullString([string])" and instead
use "AddLast([string])" and "RemoveLast([string])" of the Filename object.
It is fully described in the 9.5 COFFEE SDK.

Cheers
Lennart


// Merge_Document_Via_XRef example tcastudios 2010
//
// *NOTE* For platform independent use, don't use "SetFullString([string])"!
// Instead use the AddLast([string]) and RemoveLast([string]) functions
// of the Filename object to travel thru the directories of the harddrive.
//

var xref = AllocObject(200000118); // Make a xref object
var mscene = new(Filename); // Create a Filename
mscene->SetFullString("/Users/lennart/Desktop/morph.c4d"); // Load the string. See *NOTE* above
xref#SCENEINSTANCE_FILENAME = mscene; // Set the Filename
doc->InsertObject(xref,NULL,NULL); // Insert the xref object
doc->SetActiveObject(xref); // Make it the active object in the scene
DrawViews(DA_STATICBREAK); // Update the scene
CallButton(xref,SCENEINSTANCE_ANIMATE); // Take Animation of xref

var bc = new(BaseContainer);
SendModelingCommand(MCOMMAND_MAKEEDITABLE,doc,xref,bc,MODIFY_ALL);

indeep
03-23-2010, 10:59 PM
Thanks lennart, when someday i finish my script i'll send you some beers ;)

CGTalk Moderation
03-23-2010, 10:59 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.