[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: Wed, 17 Jan 2001 07:01:20 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: Fanning Software Consulting
- References: <19OCT00.firstname.lastname@example.org>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:23011
Dave Greenwood (email@example.com) 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 eq 11 then $
> print,'Has one or more surface' $
> else $
> print,'Has no surfaces'
> Surely there's a simpler way?
That's one way. But, and I think you have stumbled
upon this, it is much easier (and produces more
readable code) if you give the objects you are
looking for "names" and fish them out with the
> A related question is: how do I test if an object pointer (returned by
> the GetByName method, for example) is null?
You use the Obj_Valid function to find a null object:
IF Obj_Valid(theObject->GetByName('MYSURFACE') THEN $
Print, "Object Found!!!" ELSE Print, "Object Not Here."
P.S. I think Martin is on vacation at the moment, but
he has a wonderful modified IDL_CONTAINER object named
MGS_CONTAINTER that can find any object by name. You
can use wildcard searches, etc. It's very nice for this
kind of thing. You can find it in his extensive program
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: firstname.lastname@example.org
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155