TheSwamp

Code Red => Visual DCL Programming => AutoLISP (Vanilla / Visual) => OpenDCL => Topic started by: Guest on June 11, 2007, 01:02:00 PM

Title: Whose kid is this??
Post by: Guest on June 11, 2007, 01:02:00 PM
When selecting a child item in a treeview, is it possible to obtain the name of the parent item?
Title: Re: Whose kid is this??
Post by: MP on June 11, 2007, 01:09:28 PM
Did you try the Odcl_Tree_GetParent function?

e.g.

Code: [Select]
(if (setq parentKey (Odcl_Tree_GetParent MyProject_MyForm_MyTree childKey))
    (LetUsRollWithThe parentKey)
)
Title: Re: Whose kid is this??
Post by: Guest on June 11, 2007, 01:21:22 PM
But what if you don't know the parent's key?

I'm creating a tree based on folders/subfolders "auto-magically".

Code: [Select]
(defun SetUp ( / RootDir SubDir i1 i2 i3 i4 FosterParent ChildX FileList FileDir BlockList Path)
   (setq StartDir "s:\\caddstds\\details\\")
   (setq RootDir (dos_subdir StartDir))
   (foreach i1 RootDir
      (setq FosterParent (Odcl_Tree_AddParent  BlockTree_Form1_TreeControl1 i1))
      (setq x (strcat StartDir i1))
      (setq SubDir (dos_subdir (strcat StartDir i1)))
      (foreach i2 SubDir
         (setq ChildX (Odcl_Tree_AddChild BlockTree_Form1_TreeControl1 FosterParent i2))
         (setq FileDir (strcat x "\\" i2 "\\*.dwg"))
         (setq FileList (dos_dir FileDir 1))
         (foreach i3 FileList
            (setq Path (strcat x "\\" i2 "\\" i3))
            (if (findfile path)
               (setq BlockList (LoadBlocks (findfile Path)))
            )
            (if BlockList
               (foreach i4 BlockList
                  (Odcl_Tree_AddChild BlockTree_Form1_TreeControl1 ChildX i4)
               )
            )
         )
      )
   )
)
Title: Re: Whose kid is this??
Post by: jbuzbee on June 11, 2007, 03:48:03 PM
There are 2 arguments to setting a tree node item: the key and string; use the same value for key and string . . ..
Title: Re: Whose kid is this??
Post by: Kerry on June 14, 2007, 08:39:46 PM
Mat, did you get this resolved ?

Have a look at the TreeView Sample, you'll see a couple of statements that look something like this ..

(setq sKey (strcat "k" (itoa (+ nCount 1))))

... that may give you some ideas.

Title: Re: Whose kid is this??
Post by: Guest on June 15, 2007, 08:19:17 AM
I decided to go a different route with this one, but for another project that I'm going to start (I think I'll call it "Project X"  :wink:) I may need to know who the kid belongs to.

Thanks for your help!