Hey All,
I am trying to form an "xref scene based architectural workflow" but there s one faulty design that spoils it and the only way to solve it goes through two simple commands but i can not find it, and i am 0 at scripting either, incase someone decides to help with it.
i need to have the script disable all xref scenes , d some commands and enable them back.
(
--this line should disable every xref scene loaded into to the current scene
if maxFileName != "" then ( -- if the scene saved
max saveplus -- incremental file save
TheFile = maxFilePath + (trimRight (getFilenameFile maxFileName) "1234567890") + ".max" --remove trailing numbers
if doesFileExist TheFile do deleteFile TheFile
copyFile (maxFilePath + maxFileName) TheFile
) else checkForSave()
--this line should enable every xref scene loaded into to the current scene
)
so this saves a file but it will be removing all xref scenes before saving, and re-enable them forr the artist to go on.
btw, the middle code is written by Anubis ;) thanks to him.
thanks for any input.
By
Comments (16)
Comment policy
No disable xref, but REMOVE
Hi dear,
I would like to use this script, but I need REMOVE xref, save to separate file and then again ADD xref back and save to previous file. practicaly I would like to create a copy max file where is no sxref 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! 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()
)
The only book that I know, but don't have it:
http://books.google.bg/books?id=ibbul9uZlb8C&pg=PA229&lpg=PA229&dq=maxsc…
Video tutorials:
This: http://www.scriptspot.com/3ds-max/tutorials/maxscript-101-free-online-tr… - this I have it is free.
And this:
https://www.cg-academy.net/es_catalog/index.php?cPath=27&osCsid=saf9stmd… - this tuts I don't have.
:)
definitely will look into them
the first book seems really my cup of tea, and the book in the first link you gave looks really a complete release, just that it does not have real pages to flip maybe that s why said that u dont have it.
btw, about this code you gave,i found out that it gets cumbersome on heavy scenes, and i have to ask another thing.
instead of re-enabling all xref scenes
it just has to re-enable that is disabled by the script only:
so if there were 5 scenes loaded to that scene and 7 more that was disabled already
then
it should disable the 5 active ones
and re-enable those 5 disabled ones at the end.
think it is doable?
best regards
( do some actions= ( if
thats it! it s fabulous!
i am so happy now...:)thanks alot again.
a macro version for easier use. to those like me...
http://dl.dropbox.com/u/35816487/__XR_adv_incre_save.mcr
all credit goes to miauu!
cheers!
Don't forget Anubis.
and absolutely
anubis:)
okay one little problem ...
the sequence which the xref scens are enabled are wrong... it saves a file then disables the sref scenes.
"
(
if maxFileName != "" then
( -- if the scene saved
max saveplus -- incremental file save
TheFile = maxFilePath + (trimRight (getFilenameFile maxFileName) "1234567890") + ".max" --remove trailing numbers
if doesFileExist TheFile do deleteFile TheFile
-- disable only the active xref
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
)
--
copyFile (maxFilePath + maxFileName) TheFile
-- re-enable the disabled xref scenes
for i in enabledXRefIndex do (xrefs.getXRefFile i).disabled = false
) else checkForSave()
)
"
the saved files should not have any enabled xref scenes...that causes alot of problems...
it is very close but it s not there yet :)
i think i got it :p
(
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
)
max saveplus -- incremental file save
TheFile = maxFilePath + (trimRight (getFilenameFile maxFileName) "1234567890") + ".max" --remove trailing numbers
if doesFileExist TheFile do deleteFile TheFile
-- disable only the active xref
--
copyFile (maxFilePath + maxFileName) TheFile
-- re-enable the disabled xref scenes
for i in enabledXRefIndex do (xrefs.getXRefFile i).disabled = false
) else checkForSave()
)
i tired to change the order of commands and it looks like solved
Yep, my mistake.
As you can see, maxscript it is not so difficult. :)
yes i was surprised this time...
but now i believe it s done and very helpful already :)
Glad you like it. :)
do some actions= ( if
testing right now.....
thanks already :)
okay great!
you made it seem like a piece of cake! but reality is different yes? i am still amazed at how simple, thing can be solved by scripting...
I have one more question, was there a way that i could possibly find the solution in some book or cd? like some book?
thanks again miauu, you are priceless too :)