[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to find if an object contains another
I would try
if obj_valid((model->get(/all,isa='idlgrsurface'))) then $
print,'Has one or more surface' $
print,'Has no surfaces'
or, better yet, because it provides a useful list as the result:
surf_list = model->get(/all,isa='idlgrsurface', count=n_surfs)
if n_surfs gt 0 then .....
Same thing about finding out if GetbyName returned a valid object.
Dave Greenwood wrote:
> 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?
> A related question is: how do I test if an object pointer (returned by
> the GetByName method, for example) is null?
> Dave Greenwood Email: Greenwoodde@ORNL.GOV
> Oak Ridge National Lab %STD-W-DISCLAIMER, I only speak for myself