[Closed] Max opened with file or not?
Hi,
I would like to make a startup script that only does something if max was opened without a specific maxfile and opens therefore an “untitled” file.
Here some parts of my code
(
if ( getFilenameFile maxFileName == "" ) do (
--Units
units.DisplayType = #Metric
units.MetricType = #Meters
format "Display Unit Scale: % %
" units.DisplayType units.MetricType
)
)
The part where I set the units works fine (is executed for empty file and not for a specific one) but the format line is always executed even if the units remain the one of the specific opened scene. And strangely the output of format is printed as #metric even if the units weren't changed for the opened specific max file.
I think this might have something to do with when a startup script is executed in regard to when a specific file is loaded?!
...hmm, is it understandable what I mean? I guess I could just take out the "format" line but I would like to understand whats going on!
Is there a better way to check whether Max was opend with or without a scene?
Thanks,
Lena
hi lena,
maxFileName will return “” without the adding getfilenamefile but thats not it.
because you want it to only do something with a particular file, i would set the script to explictly look for/not look for that file and doing what you want, rather than looking for a blank string. a bit like –
(
-- you could use the == depending on how you want it to go, but using the notequal method
-- would mean stuff gets done in the brackets
if ( getFilenameFile maxFileName != "dowahdiddydiddydumdiddydo.max" ) do
(
--stuffage!
)
)
edit –
sorry lena, i should really learn to read posts properly before answering! I’m not sure why it reurns the same format thing each time. is it that the other time the files are set to generic units or is the metrictype actually different on the two files?
are you quite sure it only runs if 3ds Max starts without a file?
Here’s the events I get when using a script placed in Scripts\startup, and starting 3ds Max with a 3ds Max scene file on the command line:
51630660 - startup - undefined - maxFileName: ""
51630980 - selectionSetChanged - undefined - maxFileName: "testfile.max"
51630980 - mtlRefAdded - Material #1:Standard - maxFileName: "testfile.max"
51630980 - mtlRefDeleted - Material #1:Standard - maxFileName: "testfile.max"
51630980 - mtlRefDeleted - Material #1:Standard - maxFileName: "testfile.max"
51631551 - preRendererChange - undefined - maxFileName: "testfile.max"
51631551 - postRendererChange - undefined - maxFileName: "testfile.max"
51631571 - mtlRefAdded - Material #1:Standard - maxFileName: "testfile.max"
51631571 - mtlRefAdded - Material #1:Standard - maxFileName: "testfile.max"
51631571 - mtlRefAdded - Material #2:Standard - maxFileName: "testfile.max"
51631571 - mtlRefAdded - Material #2:Standard - maxFileName: "testfile.max"
51631571 - mtlRefAdded - Material #3:Standard - maxFileName: "testfile.max"
51631571 - mtlRefAdded - Material #3:Standard - maxFileName: "testfile.max"
51631581 - mtlRefAdded - Material #4:Standard - maxFileName: "testfile.max"
51631581 - mtlRefAdded - Material #4:Standard - maxFileName: "testfile.max"
51631581 - mtlRefAdded - Material #5:Standard - maxFileName: "testfile.max"
51631581 - mtlRefAdded - Material #5:Standard - maxFileName: "testfile.max"
51631581 - mtlRefAdded - Material #6:Standard - maxFileName: "testfile.max"
51631581 - mtlRefAdded - Material #6:Standard - maxFileName: "testfile.max"
51631581 - mtlRefAdded - Material #7:Standard - maxFileName: "testfile.max"
51631581 - mtlRefAdded - Material #7:Standard - maxFileName: "testfile.max"
51631581 - mtlRefAdded - Material #8:Standard - maxFileName: "testfile.max"
51631581 - mtlRefAdded - Material #8:Standard - maxFileName: "testfile.max"
51631581 - mtlRefAdded - Material #9:Standard - maxFileName: "testfile.max"
51631581 - mtlRefAdded - Material #9:Standard - maxFileName: "testfile.max"
51631591 - mtlRefAdded - Material #10:Standard - maxFileName: "testfile.max"
51631591 - mtlRefAdded - Material #10:Standard - maxFileName: "testfile.max"
51631591 - mtlRefAdded - Material #11:Standard - maxFileName: "testfile.max"
51631591 - mtlRefAdded - Material #11:Standard - maxFileName: "testfile.max"
51631591 - mtlRefAdded - Material #12:Standard - maxFileName: "testfile.max"
51631591 - mtlRefAdded - Material #12:Standard - maxFileName: "testfile.max"
51631591 - mtlRefAdded - Material #13:Standard - maxFileName: "testfile.max"
51631591 - mtlRefAdded - Material #13:Standard - maxFileName: "testfile.max"
51631601 - mtlRefAdded - Material #14:Standard - maxFileName: "testfile.max"
51631601 - mtlRefAdded - Material #14:Standard - maxFileName: "testfile.max"
51631601 - mtlRefAdded - Material #15:Standard - maxFileName: "testfile.max"
51631601 - mtlRefAdded - Material #15:Standard - maxFileName: "testfile.max"
51631601 - mtlRefAdded - Material #16:Standard - maxFileName: "testfile.max"
51631601 - mtlRefAdded - Material #16:Standard - maxFileName: "testfile.max"
51631601 - mtlRefAdded - Material #17:Standard - maxFileName: "testfile.max"
51631601 - mtlRefAdded - Material #17:Standard - maxFileName: "testfile.max"
51631601 - mtlRefAdded - Material #18:Standard - maxFileName: "testfile.max"
51631601 - mtlRefAdded - Material #18:Standard - maxFileName: "testfile.max"
51631601 - mtlRefAdded - Material #19:Standard - maxFileName: "testfile.max"
51631601 - mtlRefAdded - Material #19:Standard - maxFileName: "testfile.max"
51631611 - mtlRefAdded - Material #20:Standard - maxFileName: "testfile.max"
51631611 - mtlRefAdded - Material #20:Standard - maxFileName: "testfile.max"
51631611 - mtlRefAdded - Material #21:Standard - maxFileName: "testfile.max"
51631611 - mtlRefAdded - Material #21:Standard - maxFileName: "testfile.max"
51631611 - mtlRefAdded - Material #22:Standard - maxFileName: "testfile.max"
51631611 - mtlRefAdded - Material #22:Standard - maxFileName: "testfile.max"
51631631 - mtlRefAdded - Material #23:Standard - maxFileName: "testfile.max"
51631631 - mtlRefAdded - Material #23:Standard - maxFileName: "testfile.max"
51631631 - mtlRefAdded - Material #24:Standard - maxFileName: "testfile.max"
51631631 - mtlRefAdded - Material #24:Standard - maxFileName: "testfile.max"
51631631 - mtlRefAdded - Material #1:Standard - maxFileName: "testfile.max"
51631741 - timeunitsChange - undefined - maxFileName: "testfile.max"
51631741 - timeunitsChange - undefined - maxFileName: "testfile.max"
51631741 - animationRangeChange - undefined - maxFileName: "testfile.max"
51631751 - animationRangeChange - undefined - maxFileName: "testfile.max"
51631751 - viewportChange - undefined - maxFileName: "testfile.max"
51631751 - viewportChange - undefined - maxFileName: "testfile.max"
51631751 - viewportChange - undefined - maxFileName: "testfile.max"
51631751 - viewportChange - undefined - maxFileName: "testfile.max"
51631751 - viewportChange - undefined - maxFileName: "testfile.max"
51631751 - viewportChange - undefined - maxFileName: "testfile.max"
51631751 - viewportChange - undefined - maxFileName: "testfile.max"
51631751 - unitsChange - undefined - maxFileName: "testfile.max"
51631761 - viewportChange - undefined - maxFileName: "testfile.max"
51631761 - viewportChange - undefined - maxFileName: "testfile.max"
51631761 - viewportChange - undefined - maxFileName: "testfile.max"
51631761 - viewportChange - undefined - maxFileName: "testfile.max"
51631771 - viewportChange - undefined - maxFileName: "testfile.max"
51631771 - viewportChange - undefined - maxFileName: "testfile.max"
51631781 - viewportChange - undefined - maxFileName: "testfile.max"
51631781 - viewportChange - undefined - maxFileName: "testfile.max"
51631791 - viewportChange - undefined - maxFileName: "testfile.max"
51631791 - preRendererChange - undefined - maxFileName: "testfile.max"
51631791 - postRendererChange - undefined - maxFileName: "testfile.max"
51631801 - mainWindowEnabled - false - maxFileName: "testfile.max"
51633404 - mainWindowEnabled - true - maxFileName: "testfile.max"
51633414 - filePostOpen - 0 - maxFileName: "testfile.max"
51633424 - filePostOpenProcess - undefined - maxFileName: "testfile.max"
51633474 - mtlRefAdded - Material #24:Standard - maxFileName: "testfile.max"
51633454 - mtlRefDeleted - Material #24:Standard - maxFileName: "testfile.max"
51633474 - mtlRefAdded - Material #23:Standard - maxFileName: "testfile.max"
51633474 - mtlRefDeleted - Material #23:Standard - maxFileName: "testfile.max"
51633484 - mtlRefAdded - Material #22:Standard - maxFileName: "testfile.max"
51633484 - mtlRefDeleted - Material #22:Standard - maxFileName: "testfile.max"
51633484 - mtlRefAdded - Material #21:Standard - maxFileName: "testfile.max"
51633484 - mtlRefDeleted - Material #21:Standard - maxFileName: "testfile.max"
51633484 - mtlRefAdded - Material #20:Standard - maxFileName: "testfile.max"
51633484 - mtlRefDeleted - Material #20:Standard - maxFileName: "testfile.max"
51633484 - mtlRefAdded - Material #19:Standard - maxFileName: "testfile.max"
51633484 - mtlRefDeleted - Material #19:Standard - maxFileName: "testfile.max"
51633494 - mtlRefAdded - Material #18:Standard - maxFileName: "testfile.max"
51633494 - mtlRefDeleted - Material #18:Standard - maxFileName: "testfile.max"
51633494 - mtlRefAdded - Material #17:Standard - maxFileName: "testfile.max"
51633494 - mtlRefDeleted - Material #17:Standard - maxFileName: "testfile.max"
51633494 - mtlRefAdded - Material #16:Standard - maxFileName: "testfile.max"
51633494 - mtlRefDeleted - Material #16:Standard - maxFileName: "testfile.max"
51633504 - mtlRefAdded - Material #15:Standard - maxFileName: "testfile.max"
51633504 - mtlRefDeleted - Material #15:Standard - maxFileName: "testfile.max"
51633504 - mtlRefAdded - Material #14:Standard - maxFileName: "testfile.max"
51633504 - mtlRefDeleted - Material #14:Standard - maxFileName: "testfile.max"
51633504 - mtlRefAdded - Material #13:Standard - maxFileName: "testfile.max"
51633504 - mtlRefDeleted - Material #13:Standard - maxFileName: "testfile.max"
51633504 - mtlRefAdded - Material #12:Standard - maxFileName: "testfile.max"
51633504 - mtlRefDeleted - Material #12:Standard - maxFileName: "testfile.max"
51633504 - mtlRefAdded - Material #11:Standard - maxFileName: "testfile.max"
51633504 - mtlRefDeleted - Material #11:Standard - maxFileName: "testfile.max"
51633514 - mtlRefAdded - Material #10:Standard - maxFileName: "testfile.max"
51633514 - mtlRefDeleted - Material #10:Standard - maxFileName: "testfile.max"
51633514 - mtlRefAdded - Material #9:Standard - maxFileName: "testfile.max"
51633514 - mtlRefDeleted - Material #9:Standard - maxFileName: "testfile.max"
51633514 - mtlRefAdded - Material #8:Standard - maxFileName: "testfile.max"
51633514 - mtlRefDeleted - Material #8:Standard - maxFileName: "testfile.max"
51633514 - mtlRefAdded - Material #7:Standard - maxFileName: "testfile.max"
51633514 - mtlRefDeleted - Material #7:Standard - maxFileName: "testfile.max"
51633524 - mtlRefAdded - Material #6:Standard - maxFileName: "testfile.max"
51633524 - mtlRefDeleted - Material #6:Standard - maxFileName: "testfile.max"
51633524 - mtlRefAdded - Material #5:Standard - maxFileName: "testfile.max"
51633524 - mtlRefDeleted - Material #5:Standard - maxFileName: "testfile.max"
51633534 - mtlRefAdded - Material #4:Standard - maxFileName: "testfile.max"
51633534 - mtlRefDeleted - Material #4:Standard - maxFileName: "testfile.max"
51633534 - mtlRefAdded - Material #3:Standard - maxFileName: "testfile.max"
51633534 - mtlRefDeleted - Material #3:Standard - maxFileName: "testfile.max"
51633534 - mtlRefAdded - Material #2:Standard - maxFileName: "testfile.max"
51633534 - mtlRefDeleted - Material #2:Standard - maxFileName: "testfile.max"
51633534 - mtlRefAdded - Material #1:Standard - maxFileName: "testfile.max"
51633534 - mtlRefDeleted - Material #1:Standard - maxFileName: "testfile.max"
51633634 - viewportChange - undefined - maxFileName: "testfile.max"
51633634 - viewportChange - undefined - maxFileName: "testfile.max"
51633644 - viewportChange - undefined - maxFileName: "testfile.max"
51633654 - viewportChange - undefined - maxFileName: "testfile.max"
What’s interesting is that there’s never a filePreOpen event… which there is if I open the file manually. But the important bit is that, on startup, maxFileName is empty regardless of whether a file is specified on the command line, or not… as far as I can tell. The aforementioned lack of a filePreOpen might help in figuring out whether a file was opened on the command line… though it seems odd to me that filePreOpen is missing in the first place
Well, I am not quite sure of anything with this…
The thing I perceive is that when I open Max without a file the units are set as scripted. If I open a specific file the “format” part of the script is actually printed in the Listener, with the values the script would set. BUT the actuall values in the scene remain the same as they were before in the just opened scene and are not changed. That behavior is actually what I want (without the wrong output to the Listener, of course) but it all seems very strange to me…