Notifications
Clear all
[Closed] Is there a way to stop script
May 27, 2021 5:32 pm
Is there a way to stop script if something went wrong
for example:
myObj = $
if ($ == undefined) then EXIT
rest of code
i tried, but get
Exit: not inside a loop
5 Replies
May 27, 2021 5:32 pm
myObj = selection[1]
if isValidNode myObj then
(
-- code here
)
else
(
messagebox "Error"
)
May 27, 2021 5:32 pm
I gave a bad example
i need the script to stop on every first error
and didn’t execute the rest of the code
new example^
if selection.count!=0 then (bla-bla-bla)
else (messagebox "Error" and exit without continuing execution the script)
if isKindOf i helper!=undefined then (delete Helpers)
else (messagebox "Error" and exit without continuing execution the script)
backgroundColor=color 255 255 255;
environmentMap=undefined;
lot of code
lot of code
lot of code
lot of code
lot of code
lot of code
rollout blablabla
lot of code
lot of code
May 27, 2021 5:32 pm
(
if selection.count != 0 then
(
if isKindOf selection[1] helper != undefined then
(
delete Helpers
backgroundColor=color 255 255 255;
environmentMap=undefined;
--lot of code
--lot of code
--lot of code
--lot of code
--lot of code
--lot of code
rollout blablabla
--lot of code
--lot of code
)
else
(
messagebox "Error" --and exit without continuing execution the script
)
)
else
(
messagebox "Error" -- and exit without continuing execution the script
)
)
Or like this:
(
continueScriptExecution = true
if selection.count != 0 then
(
bla-bla-bla
)
else
(
continueScriptExecution = false
messagebox "Error 1" title:""
)
if continueScriptExecution then
(
if isKindOf i helper!=undefined then
(
delete Helpers
)
else
(
continueScriptExecution = false
messagebox "Error 2"
)
)
if continueScriptExecution then
(
backgroundColor=color 255 255 255;
environmentMap=undefined;
lot of code
lot of code
lot of code
lot of code
lot of code
lot of code
rollout blablabla
lot of code
lot of code
)
)
May 27, 2021 5:32 pm
how do you use this code? if it’s a handler or a function you can use return()
May 27, 2021 5:32 pm
else
(
continueScriptExecution = false
messagebox "Error 1" title:""
)
it would be great, but it doesn’t work