[Closed] Stop startup script
Hello.
I have a lot of 3ds max scenes with symmetry modifier and for some reason I need to check if this scene contains this modifier on any object. I want to check for these objects automaticaly when scene open. I create script that works great here is the script
function PerformDelayedTasks sender evt=
(
-- don't repeat this timer event
sender.enabled = true
-- for sanity and cleanup
dotnet.RemoveEventHandler sender "Elapsed" PerformDelayedTasks
-- put all your tasks below
MySelection=#()
for obj in objects do (for mod in obj.modifiers do (if classof mod == symmetry do (append Myselection obj)))
Select MySelection
)
delayTimer= dotnetobject "Windows.Forms.Timer"
delayTimer.Interval=2000
dotnet.AddEventHandler delayTimer "Tick" PerformDelayedTasks
delayTimer.enabled = true
But I need to message me if there is symmetry on the scene and select these objects and END the script else check for them all the time. So i try this
function PerformDelayedTasks sender evt=
(
-- don't repeat this timer event
sender.enabled = true
-- for sanity and cleanup
dotnet.RemoveEventHandler sender "Elapsed" PerformDelayedTasks
-- put all your tasks below
MySelection=#()
for obj in objects do (for mod in obj.modifiers do (if classof mod == symmetry do (append Myselection obj)))
Select MySelection
If selection.count > 0 then
(
messageBox "Test." title:"Warining!"
exit
)
else
(
return()
)
delayTimer= dotnetobject "Windows.Forms.Timer"
delayTimer.Interval=2000
dotnet.AddEventHandler delayTimer "Tick" PerformDelayedTasks
delayTimer.enabled = true
But I have error –Compile error: Unexpected end-of-script 3ds max What im doing wrong?
3DS max 2022/2023
you’re likely to have some syntax error here
post your code between [code] … [/code] tags
upd
you have no closing paren for this one
function PerformDelayedTasks sender evt=
( <---
...
This also does not work. Anyway…on second thought, I found that this script couldn’t run like this. I have another idea but I can’t figure out how to run scenes with .bat. I have hundreds of scenes and I’m going to create a registry entry that will add an “open with .bat” option to my context menu I understand how to run a script from command line is described here → https://knowledge.autodesk.com/support/3ds-max/getting-started/caas/CloudHelp/cloudhelp/2022/ENU/3DSMax-Basics/files/GUID-BCB04DEC-7967-4091-B980-638CFDFE47EC-htm.html
However, I don’t know how I can run my scene for example named XYZ.max without having to name it in the batch file. Why? Because I have hundreds of scenes and I am not able to rename every time in a batch file. Now for test I drop my scene icon (XYZ.max) onto a batch file that contains such a line
3dsmax -U MAXScript myScript.ms
waiting for the scene to open and run the script, but an empty scene opens not my XYZ.max
when you checked the file , what you would do?
if you just need to know which file contain symmetry modifier,you can use some file search app , such as FileLocator
if you want to do something with stmmetry , to load the file , you should text filename as last parameter,such as
3dsmax -U MAXScript myScript.ms xyz.max
to get filename automatically , you need shell syntax , to get all files under a path , such as
forfiles /p d:\d /s /m *.max /c "cmd /c d:\a.bat @path"
this will search all max file under d:/d path , then the a.bat
"D:\WorkTool\3ds Max 2021\3dsmax.exe" -u MAXScript "D:\Work\maxscript\script.ms" %1
Thanks! This works for me great. Anyway I try this and works better (because I dont need open from command line)
fn check_smt =
(
MySelection=#()
for obj in objects do (for mod in obj.modifiers do (if classof mod == symmetry do (append Myselection obj)))
Select MySelection "% --> post opened
" (maxfilepath + maxfilename)
)
callbacks.removescripts id:#my_postload
callbacks.addscript #filePostOpenProcess "check_smt()" id:#my_postload
Your example will help me in future.