[Closed] Maxscript algorithm for solving
Hi there. I’m completely new user in max script and I’m searching for a help here.
Can anyone give me some suggestion or algorithm of this problem:
I have an excel file with different articles on vertical column A and different object in my max scene in row1.
I putted “x” to objects that I need to stay in max file for each article and delete all others.
Hello Martin,
Without a good idea of the excel file layout (I’m not sure what an article is in this case), it would be best to parse the excel file as CSV data. If you can provide the data as CSV, it should be easy to write something to do this.
Hi there, thanks for the answer.
I have some solution and I want to paste it here. It can be usefull for someone.
inputArray = #() dataArray = #() settingsArray = #() – 1 = swtich name, 2 = xref name, 3 = matte (true/false), 4 = visible (true/false), 5 = dynamic matte (true/false), 6 = only loaded (true/false), 7 = rename xref (true/false), 8 = replace (string), 9 = with (string) objArray = #() – 2d array containing (object name, matte, visible) ———————————————————————————————————————— – FUNCTIONS – ———————————————————————————————————————— get_settings_from_file fn get_settings_from_file = ( try ( settingsFile = openFile “C:/Users/Martin.Yankov/Desktop/Script/settings-test5.txt” mode:“rt” ) catch ( MessageBox (getCurrentException()) ) – Read lines from settings.txt deselect objects if settingsFile != undefined then ( i = 0 while not eof settingsFile do ( i = i + 1 inputData = (readDelimitedString settingsFile “;”) append inputArray inputData –print inputData print inputArray[i] if inputArray[2] == “1” then (selectmore $Steeloven) if inputArray[3] == “1” then ( selectmore $Whiteoven ) if inputArray[4] == “1” then ( selectmore $WhiteRoundhandle ) if inputArray[5] == “1” then ( selectmore $SteelRoundhandle ) if inputArray[6] == “1” then ( selectmore $WhiteHandleRectangle ) if inputArray[7] == “1” then ( selectmore $SteelHadleRectangle ) if inputArray[8] == “1” then ( selectmore $Whiteknobs2 ) if inputArray[9] == “1” then ( selectmore $Steelknobs2 ) if inputArray[10] == “1” then ( selectmore $Whiteknobs4 ) if inputArray[11] == “1” then ( selectmore $Steelknobs4 ) tempDummy = Dummy size:10 tempDummy.name = inputArray[i] sceneName = maxFilePath + inputArray[i] exportfile sceneName #noPrompt selectedOnly:true ) ) close settingsFile ) – Set settings get_settings_from_file()
Hi there, thanks for the answer.
I have some solution and I want to paste it here. It can be usefull for someone.
inputArray = #()
dataArray = #()
settingsArray = #() – 1 = swtich name, 2 = xref name, 3 = matte (true/false), 4 = visible (true/false), 5 = dynamic matte (true/false), 6 = only loaded (true/false), 7 = rename xref (true/false), 8 = replace (string), 9 = with (string)
objArray = #() – 2d array containing (object name, matte, visible)get_settings_from_file
fn get_settings_from_file =
(
try (
settingsFile = openFile “C:/Users/Martin.Yankov/Desktop/Script/settings-test5.txt” mode:“rt”
)
catch (
MessageBox (getCurrentException())
)– Read lines from settings.txt
deselect objects
if settingsFile != undefined then
(
i = 0
while not eof settingsFile do
(
i = i + 1
inputData = (readDelimitedString settingsFile “;”)
append inputArray inputData
–print inputData
print inputArray[i]
if inputArray[2] == “1” then (selectmore $Steeloven)
if inputArray[3] == “1” then ( selectmore $Whiteoven )
if inputArray[4] == “1” then ( selectmore $WhiteRoundhandle )
if inputArray[5] == “1” then ( selectmore $SteelRoundhandle )
if inputArray[6] == “1” then ( selectmore $WhiteHandleRectangle )
if inputArray[7] == “1” then ( selectmore $SteelHadleRectangle )
if inputArray[8] == “1” then ( selectmore $Whiteknobs2 )
if inputArray[9] == “1” then ( selectmore $Steelknobs2 )
if inputArray[10] == “1” then ( selectmore $Whiteknobs4 )
if inputArray[11] == “1” then ( selectmore $Steelknobs4 )tempDummy = Dummy size:10 tempDummy.name = inputArray[i] sceneName = maxFilePath + inputArray[i] exportfile sceneName #noPrompt selectedOnly:true )
)
close settingsFile
)– Set settings
get_settings_from_file()
Hi there… I had some solution, but I have stucked again. How to say to my index of array inputArray[i] on position 12, 23, 33, 34, 45 and etc. to select again $Steeloven for example.
I need something that give me last number of the position. Code like this in C#:
inputArray[i] % 10 == 1
inputArray = #()
dataArray = #()
settingsArray = #() – 1 = swtich name, 2 = xref name, 3 = matte (true/false), 4 = visible (true/false), 5 = dynamic matte (true/false), 6 = only loaded (true/false), 7 = rename xref (true/false), 8 = replace (string), 9 = with (string)
objArray = #() – 2d array containing (object name, matte, visible)– FUNCTIONS –
get_settings_from_file
fn get_settings_from_file =
(
try (
settingsFile = openFile “C:/Users/Martin.Yankov/Desktop/Script/settings-test5.txt” mode:“rt”
)
catch (
MessageBox (getCurrentException())
)– Read lines from settings.txt
deselect objects
if settingsFile != undefined then
(
i = 0
while not eof settingsFile do
(
i = i + 1
inputData = (readDelimitedString settingsFile “;”)
append inputArray inputData
–print inputData
print inputArray[i]
if inputArray[2] == “1” then (selectmore $Steeloven)
if inputArray[3] == “1” then ( selectmore $Whiteoven )
if inputArray[4] == “1” then ( selectmore $WhiteRoundhandle )
if inputArray[5] == “1” then ( selectmore $SteelRoundhandle )
if inputArray[6] == “1” then ( selectmore $WhiteHandleRectangle )
if inputArray[7] == “1” then ( selectmore $SteelHadleRectangle )
if inputArray[8] == “1” then ( selectmore $Whiteknobs2 )
if inputArray[9] == “1” then ( selectmore $Steelknobs2 )
if inputArray[10] == “1” then ( selectmore $Whiteknobs4 )
if inputArray[11] == “1” then ( selectmore $Steelknobs4 )tempDummy = Dummy size:10
tempDummy.name = inputArray[i]
sceneName = maxFilePath + inputArray[i]
exportfile sceneName #noPrompt selectedOnly:true
)
)
close settingsFile
)
– Set settings
get_settings_from_file()