Author Topic: Whose kid is this??  (Read 4330 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
Whose kid is this??
« 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?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Whose kid is this??
« Reply #1 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)
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Guest

  • Guest
Re: Whose kid is this??
« Reply #2 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)
               )
            )
         )
      )
   )
)

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Whose kid is this??
« Reply #3 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 . . ..
James Buzbee
Windows 8

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Whose kid is this??
« Reply #4 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.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Guest

  • Guest
Re: Whose kid is this??
« Reply #5 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!