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?
 
checking that an object exists

checking that an object exists

2005-04-07       - By Bernard Lebel

 Back
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

On top of my head, since you got the object's fullname, I'd use the
model name as the source of a findchild() or findchildren() call. If
there is no model name in the full name then use the active scene
root.

Perhaps also a direct look up in the .children() property of objects
could work, but then you have to find out with object to look up.

In the case of objects outside the scene root scope, like partitions,
passes, layers and such (that you don't normally get via a findchild()
or findchildren() call, you may try enumelements() on the application
object (although I have not tested that suggestion).


Btw, besides the Linux limitation with the try/catch statement in
JScript, what's so wrong with exception catching? You are testing the
existence of an object, not running commands or calling methods.


PS: if by "object" you mean programming object and not just scene
object (ie parameters and properties), you can test that easily:

if( !oObject.properties( "aproperty" ) ) {
logmessage( "no" );
}

or the more elegant Pythonic way:
if not oObject.properties( 'aproperty' ): print 'no'


Cheers
Bernard



On Apr 7, 2005 2:32 PM, Brad Friedman <xsibrad@(protected)> wrote:
> Hi,
>
> I got an interesting question from someone, that I wanted to check out
> with you all.
>
> Given an object's full name, he wants to check if it exists.
>
> So there are two ways to do it.
>
> Via command: GetValue()
>
> Via object model: Dictionary.GetObject()
>
> now here's the question:
>
> Both of these solutions throw an exception if the given object does not
> exist.  While you can catch the exception, I'd think this is a poor way
> to go about solving the problem.  Exceptions should not be used for flow
> control.  They're inherently slow (or so I've been taught time and time
> again).  Is there a better fast way to check if an object exists from
> its full name that doesn't involve depending on exceptions?  I can come
> up with some ways of doing it that will be inherently slow...  but none
> that are fast.
>
> -brad
> ---
> Unsubscribe? Mail Majordomo@(protected) with the following text in body:
> unsubscribe xsi
>
---
Unsubscribe? Mail Majordomo@(protected) with the following text in body:
unsubscribe xsi