Code Red > AutoLISP (Vanilla / Visual)
Erase Reactor for XREF
Andrea:
Hi all,..
I'm trying to make a simple routine to detach XREF when user delete it.
But i can't find how to make my code working.
any help will be appreciated. thanks.
--- Code: ---;;(vlr-remove-all)
(if EraseEnded (vlr-remove EraseEnded))
(if EraseStarted (vlr-remove EraseStarted))
;;Start Reactor
(setq EraseEnded
(vlr-command-reactor nil '((:vlr-commandEnded . *EraseEnded*)))
)
(setq EraseStarted
(vlr-command-reactor nil '((:vlr-commandWillStart . *EraseStarted*)))
)
;;Check If Deleted and Detach if was Xref
(defun checkIFdeleted (XRefList)
(foreach xr XRefList
(if (vlax-erased-p xr)
(vla-Detach xr)
)
)
(setq XRLi nil)
)
;;Create Xref List
(defun XRerList (/ blocks actdoc)
(setq XRLi ())
(setq actdoc (vla-get-activeDocument (vlax-get-acad-object)))
(setq blocks (vla-get-blocks actdoc))
(vlax-for xref blocks
(if (eq :vlax-true (vla-get-IsXRef xref))
(setq XRLi (append XRLi (list xref)))
)
)
)
;;Reactor on Start ERASE
(defun *EraseStarted* (call-reactor scI )
(if (= (nth 0 scI ) "ERASE") (XRerList))
)
;;Reactor on ended ERASE
(defun *EraseEnded* (call-reactor scI)
(if (= (nth 0 scI ) "ERASE") (if XRLi (checkIFdeleted XRLi)))
)
--- End code ---
ronjonp:
Won't the xref detach itself when the drawing is reopened if it is unreferenced?
T.Willey:
--- Quote from: ronjonp on April 11, 2008, 02:13:27 PM ---Won't the xref detach itself when the drawing is reopened if it is unreferenced?
--- End quote ---
Not on mine system it doesn't. It just says it's unreferenced.
Andrea:
--- Quote from: ronjonp on April 11, 2008, 02:13:27 PM ---Won't the xref detach itself when the drawing is reopened if it is unreferenced?
--- End quote ---
Yes, but for some reason, user here dont want to close the drawing and reopen-it.
they load over than 30 xref per drawings... :ugly:
Andrea:
--- Quote from: T.Willey on April 11, 2008, 02:18:36 PM ---
--- Quote from: ronjonp on April 11, 2008, 02:13:27 PM ---Won't the xref detach itself when the drawing is reopened if it is unreferenced?
--- End quote ---
Not on mine system it doesn't. It just says it's unreferenced.
--- End quote ---
your right, same on my PC..
maybe is a variable !?
Navigation
[0] Message Index
[#] Next page
Go to full version