Re: IDLgrView::GetByName [message #46219 is a reply to message #46218] |
Tue, 08 November 2005 13:14   |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
IDLmastertobe wrote:
> Hi, I am dealing with IDLgrView object named oView, oView holds a lot of
> other objects. I am trying to get access to those objects by using
> oView->GetByName function as follows:
>
> oView -> GetByName, oTop=oTop
> oTop -> GetByName, oGroup = oGroup
> oGroup->GetByName, oBox = oBox
> oBox -> SetProperty, thick=3
>
> oTop was added to oView and oGroup was added to oTop, maybe the chain
> GetByName structure is not necessary, but i received an error message:
>
> "Attempt to call undefined method: 'IDLGRVIEW::GETBYNAME'."
>
> why is GetByName not defined in IDLgrView oView?
>
> Does anyone know why? Thanks for your time.
Well, all objects of the IDLgrView class and its subclasses should have
a GetByName method (since version 5.0, the first version in which Object
Graphcis appeared). But the problem may be that you aren't calling it
right. It takes no keyword arguments, only a single positional argument
which should be a scalar string.
Here is how you might use it
IDL> oview = obj_new('IDLgrView')
IDL> otop = obj_new('IDLgrModel', NAME='top')
IDL> oview->Add, otop
IDL> ogroup = obj_new('IDLgrModel', NAME='group')
IDL> otop->Add, ogroup
IDL> obox = obj_new('IDLgrPolygon', NAME='box')
IDL> ogroup->Add, obox
(I'm just guessing about the object types.)
Then, later, when you've lost the references to the contained objects
IDL> otop = oview->GetByName('top')
IDL> ogroup = oview->GetByName('top/group')
IDL> obox = oview->GetByName('top/group/box')
IDL> print, otop, ogroup, obox
<ObjHeapVar10009(IDLGRMODEL)><ObjHeapVar10011(IDLGRMODEL)><ObjHeapVar10013(IDLGRPOLYGON) >
--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
|
|
|