comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » How to find if an object contains another
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: How to find if an object contains another [message #22740 is a reply to message #22146] Sun, 03 December 2000 00:00 Go to previous messageGo to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Dave Greenwood (greenwoodde@ornl.gov) writes:

> How do I determine if an object "contains" another one?
>
> For example, I can create a model object and add a surface object or
> a plot object. Given that model object, how would I find out whether
> or not a surface object has been added?
>
> The best I've come up with is something like:
>
> xx = model->get(/all,isa='idlgrsurface')
> s = size(xx)
> if s[1] eq 11 then $
> print,'Has one or more surface' $
> else $
> print,'Has no surfaces'
>
> Surely there's a simpler way?

How about something like this:

xx = model->get(/all,isa='idlgrsurface', Count=numFound)
Print, numFound

> A related question is: how do I test if an object pointer (returned by
> the GetByName method, for example) is null?

If an object is NULL it is an invalid object:

IF Obj_Valid(theObject) EQ 0 THEN Print, 'Object is invalid.'

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Newbie question (w/colorful points)...
Next Topic: making an object from class structure?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 13:42:50 PDT 2025

Total time taken to generate the page: 1.32497 seconds