Mailing List
Home
Forum Home
Softimage
Carrara
trueSpace
Dir3d-l
Maya - a powerful 3D animation and visual effects software
Macromedia Flash Development
Subjects
Cameras
scaleDown command
black out solved
Aircraft Tutorial
Mathematical XYZ ?
Its done This vs That
Its done first week
recommendations for screen video captures?
3DExplorer "Oddity "
New Director
ProTeam renewals
Fuel 's new websites (X post)
Blue peter create a make toy
targeting groups question
XPost: Shockwave 3D game ( sort of )
RES: RES: RES: Fish Modeling
Emitting particles from object intersection
Fuel 's new websites (X post)
Texturing
Big Break Contest Videos
New Plugins
Models and Texture on my updated site
Error Installing Patch tS6 6
Plasma?
Looking for Inspiration
Weird EMail Q
It 's done first week ?
Cherry not cranberry
New game
Camera Animation Problem
Particle plugins?
 
Testing for presence of property

Testing for presence of property

2004-03-22       - By Rafe Sacks

 Back
Reply:     1     2     3     4     5     6     7  

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>
&nbsp;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>