Author Topic: XREF-reload, unload, detach  (Read 6997 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: XREF-reload, unload, detach
« Reply #15 on: August 23, 2006, 01:46:20 PM »
Okay, here you go.  Now you can only select blocks, and it will make sure that it is an xref before preforming the opperation to it. Use with the other portions or Randy's code.
Code: [Select]
(defun Xref-Loader (XrefOpp / ActDoc BlkCol ss Ent BlkObj)

(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vla-StartUndoMark ActDoc)
(setq BlkCol (vla-get-Blocks ActDoc))
(if (setq ss (ssget '((0 . "INSERT"))))
 (foreach Lst (ssnamex ss)
  (if
   (and
    (= (type (setq Ent (cadr Lst))) 'ENAME)
    (= (vla-get-IsXref (setq BlkObj (vla-Item BlkCol (cdr (assoc 2 (entget Ent)))))) :vlax-true)
   )
   (vlax-invoke BlkObj XrefOpp)
  )
 )
)
(vla-EndUndoMark ActDoc)
(princ)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

nivuahc

  • Guest
Re: XREF-reload, unload, detach
« Reply #16 on: August 23, 2006, 01:52:21 PM »
Something different but similar, courtesy of MP:

Code: [Select]
(defun GetXrefPath ( ename / object )
    (cond
        (   (and
                (eq 'ename (type ename))
                (eq "AcDbBlockReference"
                    (vla-get-objectname
                        (setq object
                            (vlax-ename->vla-object
                                ename
                            )
                        )
                    )   
                )
                (vlax-property-available-p object 'path)
            )
            (vla-get-path object)
        )   
    )
)


(defun c:XOpen ( / path )
    (if (setq path (GetXrefPath (car (entsel))))
        (if (zerop (getvar "sdi"))
            (vla-open
                (vla-get-documents (vlax-get-acad-object))
                path
            )
            (vla-sendcommand
                (vla-get-activedocument (vlax-get-acad-object))
                (strcat ".open " path "\n")
            )
        )
    )   
    (princ)   
)

CADaver

  • Guest
Re: XREF-reload, unload, detach
« Reply #17 on: August 23, 2006, 03:26:21 PM »
CADaver, sorry  I didnt mean to imply that you stole barrow (or whatver) I did and I did thank him.  <I got the proof>   :-)
Oh, I didn't think you did, it's just that the codes are sorta similar, and I have been known to ...ummm... borrow a line or two. :angel: