[Closed] Merge in Xref Objects?
How can I merge all my Xref objects in my scene into my file using maxscript…
I don’t think there is a straight function call for merging xrefs, but here is a quick function that merges in the associated Max file:
fn mergeXRef xRefObj = (
try (
mergeMAXFile xRefObj.filename #(xRefObj.objectName) #select #deleteOldDups #useMergedMtlDups #alwaysReparent quiet: true
newNode = $
delete xRefObj
xRefObj = newNode
return true
)
catch(
return false
)
)
success = mergeXRef $
i am trying to do the same thing… merge all xref entries to the current scene…
can someone explain the code above?
or tell me how i can merge all xref objects comming from a file i know the path for ? for example “C:\Program Files\Autodesk\3ds Max 2009\Scripts\Startup\1.max”
Check the interface:objXrefMgr in the maxscript help:
Interface: objXRefMgr [left]<bool>objXRefMgr.MergeRecordIntoScene <Interface>record
[/left]
[left]record Validated by Validator function
[/left]
[left]Merges the specified record into the scene. Returns true on success, false on failure. See IXrefRecord MixinInterface for details on the record argument.
-Eric
[/left]
i am new to maxscripting and some of the instructions in max’s maxscript help are a bit above my head …
so, i still can get it to work…
say its xrefs from this “C:\Program Files\Autodesk\3ds Max 2009\Scripts\Startup\1.max” file that i want to be merged how do i get objXRefMgr.MergeRecordIntoScene to do that for me?
ok i finally used the following code to completely merge the xrefed objects in scene
objs = getCurrentSelection()
for i in objs do
(
objXRefMgr.MergeXRefItemsIntoScene i
objXRefMgr.MergeXRefItemsIntoScene i.material
objXRefMgr.MergeXRefItemsIntoScene i.controller
)
Opps, forgot to say thanks for this! I managed to get what i wanted by not merging and instead editing the baseobject of the xref, saved a load of pipeline hassle!