Script cleanup, fix if no xref found
This commit is contained in:
@@ -16,42 +16,25 @@
|
|||||||
; ---------------------------------------------------------------------------- ;
|
; ---------------------------------------------------------------------------- ;
|
||||||
|
|
||||||
; ------------------------ XREFS: bind and detach all ------------------------ ;
|
; ------------------------ XREFS: bind and detach all ------------------------ ;
|
||||||
(defun bindXrefs (/ really blk blklist xrefpath xreflist)
|
(defun bindXrefs (/ ss really blk blklist xrefpath xreflist)
|
||||||
(vl-load-com)
|
(vl-load-com)
|
||||||
(graphscr)
|
(graphscr)
|
||||||
|
|
||||||
;; Select all blocks and xrefs in model space
|
;; Check if there are inserts at all
|
||||||
(foreach x
|
(setq ss (ssget "_A" '((0 . "INSERT") (410 . "MODEL"))))
|
||||||
(mapcar 'cadr (ssnamex (ssget "_X" '((0 . "INSERT") (410 . "MODEL")))))
|
|
||||||
(setq blk (cdr (assoc 2 (entget x))))
|
|
||||||
(setq blklist (append blklist (list blk)))
|
|
||||||
)
|
|
||||||
|
|
||||||
;; Clean duplicates
|
(if ss
|
||||||
(setq blklist (LM:Unique blklist))
|
(progn
|
||||||
|
;; Select all blocks and xrefs in model space
|
||||||
|
(foreach x
|
||||||
|
(mapcar 'cadr (ssnamex (ssget "_X" '((0 . "INSERT") (410 . "MODEL")))))
|
||||||
|
(setq blk (cdr (assoc 2 (entget x))))
|
||||||
|
(setq blklist (append blklist (list blk)))
|
||||||
|
)
|
||||||
|
|
||||||
;; Create a list of found xrefs
|
;; Clean duplicates
|
||||||
;; Removed this part, because it fails if the xrefs name differs from the filename:
|
(setq blklist (LM:Unique blklist))
|
||||||
;; (setq i 0);counter to zero
|
|
||||||
;; (setq imax 1);while variable
|
|
||||||
;; (while imax
|
|
||||||
|
|
||||||
|
|
||||||
;; (setq xrefpath (findfile (strcat (nth i blklist))))
|
|
||||||
;; (if xrefpath
|
|
||||||
;; (progn
|
|
||||||
;; (setq xreflist (append xreflist (list (nth i blklist))))
|
|
||||||
;; (princ (strcat "Xref found: " (nth i blklist) ".dwg\n"))
|
|
||||||
;; )
|
|
||||||
;; )
|
|
||||||
|
|
||||||
;; (setq i (1+ i));increments i
|
|
||||||
;; (if (= i (length blklist)) (setq imax nil));finish function if i equals il
|
|
||||||
;; )
|
|
||||||
|
|
||||||
;; Show prompt only if there are xrefs in the file:
|
|
||||||
;; (if xreflist
|
|
||||||
;; (progn
|
|
||||||
(initget 1 "Yes No")
|
(initget 1 "Yes No")
|
||||||
(setq really (getkword "Bind xrefs? [Yes/No]"))
|
(setq really (getkword "Bind xrefs? [Yes/No]"))
|
||||||
(if
|
(if
|
||||||
@@ -70,9 +53,8 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
;; )
|
)
|
||||||
;; (princ "No xref found in model space.")
|
)
|
||||||
;; )
|
|
||||||
)
|
)
|
||||||
|
|
||||||
(defun LM:Unique ( l )
|
(defun LM:Unique ( l )
|
||||||
|
|||||||
Reference in New Issue
Block a user