{"id":258,"date":"2009-06-23T16:11:35","date_gmt":"2009-06-23T14:11:35","guid":{"rendered":"http:\/\/www.svenneve.com\/?p=258"},"modified":"2009-07-15T01:07:24","modified_gmt":"2009-07-14T23:07:24","slug":"maya-progressbar-and-interrupting-a-script-loop","status":"publish","type":"post","link":"http:\/\/www.svenneve.com\/?p=258","title":{"rendered":"Maya progressBar and interrupting a script loop"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"alignleft size-full wp-image-259\" title=\"maya2009_120\" src=\"http:\/\/www.svenneve.com\/wp-content\/2009\/06\/maya2009_120.jpg\" alt=\"maya2009_120\" width=\"80\" height=\"80\" \/>This seems to be a function that is forgotten by many MEL programmers but can save you a lot of headaches.<\/p>\n<p>It is one of those things you might want to implement anywhere in a script you know will do some heavy looping that could take a lot of processing time.<\/p>\n<p>Just add this to your script early on and you are able to interrupt your script by pressing ESC, and a as a bonus you can implement a progress bar for some visual feedback.<\/p>\n<pre lang=\"perl\">global string $gMainProgressBar;\r\nint $maxPBar = 10000;\r\nprogressBar -e -bp -ii 1 -max $maxPBar $gMainProgressBar;\r\n\r\nfor($i=0; $i &lt; $maxPBar; $i++)\r\n{\r\n\u00a0\u00a0\u00a0 if(`progressBar -q -ic $gMainProgressBar`)\r\n\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 break;\r\n\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0 \/\/ here goes you code\r\n\r\n\u00a0\u00a0\u00a0 progressBar -e -s 1 $gMainProgressBar; \/\/ increases the progress bar\r\n}\r\n\r\nprogressBar -e -endProgress $gMainProgressBar; \/\/ call this when you stop the script or when the script is done<\/pre>\n<p>Offcourse, the counter isn&#8217;t really necesary, just adding this script without increasing the progressBar alone is enough to prevent you having to force quit Maya and losing your script when your script decides to take hours to finish.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This seems to be a function that is forgotten by many MEL programmers but can save you a lot of headaches. It is one of those things you might want to implement anywhere in a script you know will do some heavy looping that could take a lot of processing time. Just add this to&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19,18],"tags":[23,94,34,45,16],"_links":{"self":[{"href":"http:\/\/www.svenneve.com\/index.php?rest_route=\/wp\/v2\/posts\/258"}],"collection":[{"href":"http:\/\/www.svenneve.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.svenneve.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.svenneve.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.svenneve.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=258"}],"version-history":[{"count":11,"href":"http:\/\/www.svenneve.com\/index.php?rest_route=\/wp\/v2\/posts\/258\/revisions"}],"predecessor-version":[{"id":289,"href":"http:\/\/www.svenneve.com\/index.php?rest_route=\/wp\/v2\/posts\/258\/revisions\/289"}],"wp:attachment":[{"href":"http:\/\/www.svenneve.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.svenneve.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=258"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.svenneve.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}