TheSwamp
Code Red => Visual DCL Programming => AutoLISP (Vanilla / Visual) => OpenDCL => Topic started 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?
-
Did you try the Odcl_Tree_GetParent function?
e.g.
(if (setq parentKey (Odcl_Tree_GetParent MyProject_MyForm_MyTree childKey))
(LetUsRollWithThe parentKey)
)
-
But what if you don't know the parent's key?
I'm creating a tree based on folders/subfolders "auto-magically".
(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)
)
)
)
)
)
)
-
There are 2 arguments to setting a tree node item: the key and string; use the same value for key and string . . ..
-
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.
-
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!