  | | | Testing for presence of property | Testing for presence of property 2004-03-22 - By Rafe Sacks
Back The error returned is an object with a few properties. one of them is .message I think so you can log the actual error, but the code won't quit You can also put the error object variable and put nothing in the catch block. This will try the code and do nothing if an error occurs. Additionally, it might be important to know every line in a try block is run. It doesn't jump to catch() when it encounters an error, it will complete the try block.
In this example, you could do...
Try { // Get selected object var oSel = Selection(0);
// Create enumator and populate with shaders of selection var e = new Enumerator( oSel.shaders );
} catch(ee) { LogMessage( ee.message, siError ); }
-Rafe
kim aldis wrote:
>Try { > // Get selected object > var oSel = Selection(0); > > // Create enumator and populate with shaders of selection var > e = new Enumerator( oSel.shaders ); > >} catch(ee) { > logmessage( "oops" ); >} > > > > > >>-- --Original Message-- -- >>From: owner-xsi@(protected) >>[mailto:owner-xsi@(protected)] On Behalf Of Bernard Lebel >>Sent: 20 March 2004 12:30 >>To: XSI@(protected) >>Subject: [Script] Testing for presence of property >> >>Hello, >> >>Let say I want to check if a camera has any shader attached. >>If it has some, using the "shaders" property will work fine. >> >>But if there are no shaders, an 2000-unspecified failure will >>be thrown and the script will abort. >>Is there any way I can check if the shaders property is >>present on the object? >> >>Example of script that fails: >> >>// -- ------ Start here -- ---- ----- >> >>// Get selected object >>var oSel = Selection(0); >> >>// Create enumator and populate with shaders of selection var >>e = new Enumerator( oSel.shaders ); >> >>// -- ------ End here -- ---- ----- >> >> >>Another example: >> >> >>// -- ------ Start here -- ---- ----- >> >>// Get selected object >>var oSel = Selection(0); >> >>// Test if there are shaders attached to selection if( >>!oSel.shaders ) { >> logmessage( "No shader attached to selection." ); } >> >>// -- ------ End here -- ---- ----- >> >> >>Thanks >>Bernard >>--- >>Unsubscribe? Mail Majordomo@(protected) with the following >>text in body: >>unsubscribe xsi >> >> >> >> >> > > > >--- >Unsubscribe? Mail Majordomo@(protected) with the following text in body: >unsubscribe xsi > >
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> <font color="#000066">The error returned is an object with a few properties. one of them is .message I think so you can log the actual error, but the code won't quit<br> You can also put the error object variable and put nothing in the catch block. This will try the code and do nothing if an error occurs. Additionally, it might be important to know every line in a try block is run. It doesn't jump to catch() when it encounters an error, it will complete the try block.<br> <br> In this example, you could do...</font><br> <blockquote> <pre wrap=""><tt>Try { // Get selected object var oSel = Selection(0);
// Create enumator and populate with shaders of selection var e = new Enumerator( oSel.shaders );
} catch(ee) { LogMessage( ee.message, siError ); }</tt>
</pre> </blockquote> <font color="#000066">-Rafe</font><br> <br> kim aldis wrote:<br> <blockquote cite="mid200403201251.i2KCptTJ016193@(protected)" type="cite"> <pre wrap="">Try { // Get selected object var oSel = Selection(0);
// Create enumator and populate with shaders of selection var e = new Enumerator( oSel.shaders );
} catch(ee) { logmessage( "oops" ); }
</pre> <blockquote type="cite"> <pre wrap="">-- --Original Message-- -- From: <a class="moz-txt-link-abbreviated" href="mailto:owner-xsi@(protected)" >owner-xsi@(protected)</a> [<a class="moz-txt-link-freetext" href="mailto:owner-xsi@(protected)">mailto :owner-xsi@(protected)</a>] On Behalf Of Bernard Lebel Sent: 20 March 2004 12:30 To: <a class="moz-txt-link-abbreviated" href="mailto:XSI@(protected)">XSI @(protected)</a> Subject: [Script] Testing for presence of property
Hello,
Let say I want to check if a camera has any shader attached. If it has some, using the "shaders" property will work fine.
But if there are no shaders, an 2000-unspecified failure will be thrown and the script will abort. Is there any way I can check if the shaders property is present on the object?
Example of script that fails:
// -- ------ Start here -- ---- -----
// Get selected object var oSel = Selection(0);
// Create enumator and populate with shaders of selection var e = new Enumerator( oSel.shaders );
// -- ------ End here -- ---- -----
Another example:
// -- ------ Start here -- ---- -----
// Get selected object var oSel = Selection(0);
// Test if there are shaders attached to selection if( !oSel.shaders ) { logmessage( "No shader attached to selection." ); }
// -- ------ End here -- ---- -----
Thanks Bernard --- Unsubscribe? Mail <a class="moz-txt-link-abbreviated" href="mailto:Majordomo @(protected)">Majordomo@(protected)</a> with the following text in body: unsubscribe xsi
</pre> </blockquote> <pre wrap=""><!---->
--- Unsubscribe? Mail <a class="moz-txt-link-abbreviated" href="mailto:Majordomo @(protected)">Majordomo@(protected)</a> with the following text in body: unsubscribe xsi </pre> </blockquote> <br> </body> </html>
|
|
 |