Author Topic: Determine nesting tree  (Read 2049 times)

0 Members and 1 Guest are viewing this topic.

mkweaver

  • Bull Frog
  • Posts: 352
Determine nesting tree
« on: March 21, 2011, 12:53:38 PM »
I know that, given a nested object in the current drawing, I can use  vla-get-ownerid and vla-objectidtoobject to climb back out the nesting tree for the original object.  But  vla-objectidtoobject only works in the current drawing, so when my nested object is in a drawing xreffed into the current drawing I seem to be out of luck.

Is there any way to get the nesting for objects in an xref?

The whole purpose of this is to get the vertex points for a nested pline.  I've done this before when I know the nesting, but in this case the nesting may vary.

Thanks,
Mike

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Determine nesting tree
« Reply #1 on: March 21, 2011, 01:39:21 PM »
Playing around with the OwnerID, but I'm not sure this is any use since it'll always take you back to the Block Table

Code: [Select]
(defun c:GetNesting ( / _getnesting _princ doc sel lst i ) (vl-load-com)

  (defun _getnesting ( doc obj )
    (if (and (vlax-property-available-p obj 'ownerid) (not (zerop (vla-get-ownerid obj))))
      (cons obj (_getnesting doc (vla-objectidtoobject doc (vla-get-ownerid obj))))
      (list obj)
    )
  )

  (defun _princ ( x i )
    (princ "\n") (repeat i (princ "   ")) (princ x)
  )

  (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))

  (if (setq sel (car (nentsel)))
    (progn
      (_princ
        (strcat " +--+ "
          (vla-get-Objectname
            (car
              (setq lst
                (reverse
                  (_getnesting doc (vlax-ename->vla-object sel))
                )
              )
            )
          )
        )
        (setq i 0)
      )     
      (foreach x (cdr lst)
        (_princ " |" (setq i (1+ i)))
        (_princ (strcat " +--+ " (vla-get-ObjectName x)) i)
      )
    )
  )
  (princ)
)

For Block Nesting, perhaps this will help you more:

http://www.theswamp.org/index.php?topic=37148.msg421352#msg421352


jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Determine nesting tree
« Reply #2 on: March 22, 2011, 08:38:23 AM »
Open the xref with ObjectDBX?

just a guess.
James Buzbee
Windows 8