View Full Version : move selected objects to a new file and xref them back into current file
abyjoe 08-11-2007, 07:44 PM when i finish a scene i want to save (move) certain objects into a different file and xref them back into the same file they were in... i want to retain their layers and materials as it is in the new file...
tried doing it and found that saving nodes into a different file is a very easy thing but after trying i am unable to do xref objects... dont want to xref the whole scene but only the layers user selects from the rollout... once they are xref'd i want to apply their existing material in the main file
is it possible?
|
|
Gravey
08-12-2007, 03:50 PM
As you have already said, saving objects is easy with the saveNodes function.
xrefing is also easy using: xrefs.addNewXRefFile <filename_string>
once they are xref'd i want to apply their existing material in the main file
i'm not quite sure what you mean by this however you can access an object in an xref file by using the following code
(xrefs.getXRefFile <index>).tree.children
returns an array of objects in the xref scene.
If this is not what you are looking for, let me know
abyjoe
08-12-2007, 04:58 PM
xrefs.addNewXRefFile <filename_string> xrefs all the obects in the scene... i want to get a list of all layers and objects in the xreffile and then select which layer i want to xref instead of the entire scene... i think first i need to get the xrefscene and use xrefs.getXRefFileCount to get a list of objects and then xref selected objects
looking into the help provides some starting point but i cant fetch the layers and the objects of the file... xrefs.getXRefFileCount will get the objects but i think i am not using it in the right way... will keep tryin
Gravey
08-13-2007, 03:25 AM
You cannot directly access an xref by layer or select which parts of the scene you want to xref so i'd say your best option would be to run the saveNodes function on each layer, so have 1 max file to xref for each layer. Then you can just use either the Enabled checkbox in the UI or the .disabled property via maxscript. Once a scene has been xrefed in, you can still use the layer manager as normal to hide / unhide etc layers including the ones from the xref file.
Here's a better breakdown of the info i provided earlier about accessing objects in an xref scene:
--returns the root node of the 1st xref scene in the list
root = (xrefs.getXRefFile 1).tree
--returns an array of objects that do not have parents
chi = for c in root.children collect c
--puts all objects in the xref scene into the array 'chi'
for c in chi do join chi c.children
now you have an array chi that holds all objects in the xref scene and can be accessed as normal to get, and even set, any of their properties such as .material etc
Again I'm not sure this is quite what you are after but I hope it helps
EDIT: Also note, xrefs.getXRefFileCount() does not return objects but the amount of xref files in the current scene
abyjoe
08-13-2007, 09:22 AM
thanks gravey i will look into ur code and try find a workaround...
CGTalk Moderation
08-13-2007, 09:22 AM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.