[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to find if an object contains another
- Subject: Re: How to find if an object contains another
- From: davidf(at)dfanning.com (David Fanning)
- Date: Sun, 3 Dec 2000 09:52:23 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: Fanning Software Consulting
- References: <19OCT00.16364934@feda34.fed.ornl.gov>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:22416
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