Re: Scripting - catching an error for a none existent item

Date : Thu, 24 May 2007 09:14:15 -0400
To : XSI(at)Softimage.COM
From : "Bernard Lebel" <3dbernard(at)gmail.com>
Subject : Re: Scripting - catching an error for a none existent item
I have not tested it but sometimes when you assign a value to a
variable by calling a member attribute it returns null, so you only to
test null.

Example:
var oPar = oObject.parameters( "<parameter name>" );
if( oPar == null )
	logmessage( "Parameter " + "<parameter name"> + " not found.", siError )


In this case, perhaps doing something similar with the Material attribute might work: var oPartMat = oPartition.material if( oPartMat == null ) logmessage( "Partition has no material" );



Cheers
Bernard




On 5/24/07, squid <squid(at)3d-palace.com> wrote:
test for 'Nothing' as a return ?

Adam Seeley wrote:
> Hi,
>
> Another basic scripty question (in VB).
>
> I'm looping through the Partitions in a Pass and printing out the Material names.
> This is fine if there is a Material, but falls over if none exists.
> How do I check to see if it exists at all before I hit an error?
>
> E.g.
>               for each oPartition in oPartitionList
>
>                       logmessage oPartition.name
>                       if oPartition.Material <> false then logmessage "MATERIAL : " & oPartition.Material.Name
>
>               next
>
> Will give
>
> 'INFO : Background_Objects_Partition
> 'INFO : MATERIAL : Scene_Material
> 'INFO : Background_Lights_Partition
> 'ERROR : Object variable not set - [line 27]
>
>
> Thanks again,
>
> Adam.
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.467 / Virus Database: 269.7.6 - Release Date: 20/05/2007 00:00
>
>
> ---
> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> unsubscribe xsi
>
>
>
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.