ScriptSpot

Forum topic · General Scripting

Remove xref, save file, then ADD xref back

By tomastnt · 2014-03-04

Description

Hi dear,
I would like to use this script from: http://www.scriptspot.com/forums/3ds-max/scripts-wanted/disable-xref-sce…, but I need REMOVE xref, save to separate file and then again ADD xref back and save to previous file. Now it is only DISABLING xref. practicaly I would like to create a copy max file where is no xref and name of that file is every time same. I have modified this script, but it is only disabling xref and I don't know how to rewrite it for removing xref. Here is it. Any help will be much much appreciated! I am very easy to write mascript, so be patiant please Thanks Tomas.

(
if maxFileName != "" then
( -- if the scene saved
local enabledXRefIndex = #()
for i = 1 to xrefs.getXRefFileCount() where ((xrefs.getXRefFile i).disabled == false) do
(
(xrefs.getXRefFile i).disabled = true -- disable the xref
append enabledXRefIndex i -- store the index of the active xref scenes
)

filename = (maxFilePath + maxFileName)

noxreffilename = "File_No_Xref.max" as string
--noxref = (maxFilePath + noxreffilename)
saveMaxFile (maxFilePath + noxreffilename)
for i in enabledXRefIndex do (xrefs.getXRefFile i).disabled = false
saveMaxFile filename

) else checkForSave()
)

Comments (5)

.

miauu · 2014-03-06

Try this:


(
	if maxFileName != "" then
	(
		local currentXRefScenesIndexArr = #()
		for i = xrefs.getXRefFileCount() to 1 by -1 do
		(
			append currentXRefScenesIndexArr (xrefs.getXRefFile i).filename
			delete (xrefs.getXRefFile i)
		)
		saveMaxFile (maxFilePath + "Interier_No_Xref") useNewFile:false quite:true
		-- reload the deleted xref scenes
		for i in currentXRefScenesIndexArr do
		(
			xrefID = xrefs.addNewXRefFile i
			xrefID.autoupdate = true
			xrefID.hidden = false
			xrefID.boxDisp = true
			xrefID.disabled = false
		)
	)
	else checkForSave()
)

tomastnt · 2014-03-06

nope, it is not working. Don't know why. It gets me crazy. It worked yesterday on same scene, now it is not working. Thanks for help.

(
if maxFileName != "" then
(
local currentXRefScenesIndexArr = #()
for i = xrefs.getXRefFileCount() to 1 by -1 do
(
append currentXRefScenesIndexArr (xrefs.getXRefFile i).filename
delete (xrefs.getXRefFile i)
)
saveMaxFile (maxFilePath + "Interier_No_Xref") useNewFile:false quite:true
-- reload the deleted xref scenes
for i in currentXRefScenesIndexArr do
(
xrefs.addNewXRefFile i
(xrefs.getXRefFile i).autoupdate = true
(xrefs.getXRefFile i).hidden = false
(xrefs.getXRefFile i).boxDisp = true
)
for i in currentXRefScenesIndexArr do (xrefs.getXRefFile i).disabled = false

)
else checkForSave()
)

tomastnt · 2014-03-06

Hi,
loks like I have got it, I have just add:
(xrefs.getXRefFile i).autoupdate = true
and works.Thanks.

tomastnt · 2014-03-05

thanks, works great. Coud you pleas also store the information of Autoupdate and ignoreLights? The other stuff i will add similar to this features. Again thank you. Tomas

.

miauu · 2014-03-04

Try this:
The name of the new file will be "File_No_Xref.max" and will be saved in the same directory where the original file is.


(
	if maxFileName != "" then
	(
		local currentXRefScenesIndexArr = #()
		for i = xrefs.getXRefFileCount() to 1 by -1 do 
		(
			append currentXRefScenesIndexArr (xrefs.getXRefFile i).filename
			delete (xrefs.getXRefFile i)
		)
		saveMaxFile (maxFilePath + "File_No_Xref.max") useNewFile:false quite:true
		-- reload the deleted xref scenes
		for i in currentXRefScenesIndexArr do xrefs.addNewXRefFile i		
	) 
	else checkForSave()	
)