fixed xref detection and binding
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
; Just drag the script to the autocad window.
|
; Just drag the script to the autocad window.
|
||||||
; The script automatically starts after loading, no command needed.
|
; The script automatically starts after loading, no command needed.
|
||||||
|
|
||||||
; Version 1.5
|
; Version 1.6
|
||||||
; Created by Peter Gyetvai
|
; Created by Peter Gyetvai
|
||||||
; gyetpet@mailbox.org
|
; gyetpet@mailbox.org
|
||||||
; git repo: https://git.gyetpet.dynu.net/infeeeee/revitDwgImportCleaner
|
; git repo: https://git.gyetpet.dynu.net/infeeeee/revitDwgImportCleaner
|
||||||
@@ -16,25 +16,65 @@
|
|||||||
; ---------------------------------------------------------------------------- ;
|
; ---------------------------------------------------------------------------- ;
|
||||||
|
|
||||||
; ------------------------ XREFS: bind and detach all ------------------------ ;
|
; ------------------------ XREFS: bind and detach all ------------------------ ;
|
||||||
(defun bindAndDetachXrefs (/ really blk)
|
(defun bindXrefs (/ really blk blklist xrefpath xreflist)
|
||||||
|
(vl-load-com)
|
||||||
(graphscr)
|
(graphscr)
|
||||||
(initget 1 "Yes No")
|
|
||||||
(setq really (getkword "Bind xrefs? [Yes/No]"))
|
;; Select all blocks and xrefs in model space
|
||||||
(if
|
(foreach x
|
||||||
(= really "YES")
|
(mapcar 'cadr (ssnamex (ssget "_X" '((0 . "INSERT") (410 . "MODEL")))))
|
||||||
(foreach x
|
(setq blk (cdr (assoc 2 (entget x))))
|
||||||
(mapcar 'cadr (ssnamex (ssget "_X" '((0 . "INSERT") (410 . "MODEL")))))
|
(setq blklist (append blklist (list blk)))
|
||||||
(setq blk (cdr (assoc 2 (entget x))))
|
)
|
||||||
(if (assoc 1 (tblsearch "block" blk))
|
|
||||||
|
;; Clean duplicates
|
||||||
|
(setq blklist (LM:Unique blklist))
|
||||||
|
|
||||||
|
;; Create a list of found xrefs
|
||||||
|
(setq i 0);counter to zero
|
||||||
|
(setq imax 1);while variable
|
||||||
|
(while imax
|
||||||
|
|
||||||
|
(setq xrefpath (findfile (strcat (nth i blklist) ".dwg")))
|
||||||
|
(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")
|
||||||
|
(setq really (getkword "Bind xrefs? [Yes/No]"))
|
||||||
|
(if
|
||||||
|
(= really "Yes")
|
||||||
(progn
|
(progn
|
||||||
(command "_.-xref" "_bind" blk)
|
(setq i 0);counter to zero
|
||||||
(command "_.-xref" "_detach" blk)
|
(setq imax 1);while variable
|
||||||
|
(while imax
|
||||||
|
|
||||||
|
(command "_.-xref" "_bind" (nth i xreflist))
|
||||||
|
|
||||||
|
(setq i (1+ i));increments i
|
||||||
|
(if (= i (length xreflist)) (setq imax nil));finish function if i equals il
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
(princ "No xref found in model space.")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(defun LM:Unique ( l )
|
||||||
|
(if l (cons (car l) (LM:Unique (vl-remove (car l) (cdr l)))))
|
||||||
|
)
|
||||||
|
|
||||||
; ----------- deleteAllXlines.lsp: deletes all xlines in modelspace ---------- ;
|
; ----------- deleteAllXlines.lsp: deletes all xlines in modelspace ---------- ;
|
||||||
(defun dax (/ ss)
|
(defun dax (/ ss)
|
||||||
(graphscr)
|
(graphscr)
|
||||||
@@ -275,7 +315,7 @@
|
|||||||
(command "._MODEL")
|
(command "._MODEL")
|
||||||
|
|
||||||
;; Xrefs
|
;; Xrefs
|
||||||
(bindAndDetachXrefs)
|
(bindXrefs)
|
||||||
(command "._-xref" "d" "*")
|
(command "._-xref" "d" "*")
|
||||||
|
|
||||||
;; Xlines
|
;; Xlines
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
;; bindAndDetachXrefs.lsp
|
|
||||||
;;
|
|
||||||
;; bind and detach all xrefs, detach missing
|
|
||||||
;;
|
|
||||||
;; Created by Peter Gyetvai
|
|
||||||
;; gyetpet@mailbox.org
|
|
||||||
|
|
||||||
(defun C:bindAndDetachXrefs (/ really blk)
|
|
||||||
(graphscr)
|
|
||||||
(initget 1 "Yes No")
|
|
||||||
(setq really (getkword "Bind xrefs? [Yes/No]"))
|
|
||||||
(if
|
|
||||||
(= really "YES")
|
|
||||||
(foreach x
|
|
||||||
(mapcar 'cadr (ssnamex (ssget "_X" '((0 . "INSERT") (410 . "MODEL")))))
|
|
||||||
(setq blk (cdr (assoc 2 (entget x))))
|
|
||||||
(if (assoc 1 (tblsearch "block" blk))
|
|
||||||
(progn
|
|
||||||
(command "_.-xref" "_bind" blk)
|
|
||||||
(command "_.-xref" "_detach" blk)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
68
source scripts/bindXrefs.lsp
Normal file
68
source scripts/bindXrefs.lsp
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
;; bindAndDetachXrefs.lsp
|
||||||
|
;;
|
||||||
|
;; bind and detach all xrefs, detach missing
|
||||||
|
;;
|
||||||
|
;; Created by Peter Gyetvai
|
||||||
|
;; gyetpet@mailbox.org
|
||||||
|
|
||||||
|
(defun C:bindXrefs (/ really blk blklist xrefpath xreflist)
|
||||||
|
(vl-load-com)
|
||||||
|
(graphscr)
|
||||||
|
|
||||||
|
;; 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)))
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Clean duplicates
|
||||||
|
(setq blklist (LM:Unique blklist))
|
||||||
|
|
||||||
|
;; Create a list of found xrefs
|
||||||
|
(setq i 0);counter to zero
|
||||||
|
(setq imax 1);while variable
|
||||||
|
(while imax
|
||||||
|
|
||||||
|
(setq xrefpath (findfile (strcat (nth i blklist) ".dwg")))
|
||||||
|
(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")
|
||||||
|
(setq really (getkword "Bind xrefs? [Yes/No]"))
|
||||||
|
(if
|
||||||
|
(= really "Yes")
|
||||||
|
(progn
|
||||||
|
(setq i 0);counter to zero
|
||||||
|
(setq imax 1);while variable
|
||||||
|
(while imax
|
||||||
|
|
||||||
|
(command "_.-xref" "_bind" (nth i xreflist))
|
||||||
|
|
||||||
|
(setq i (1+ i));increments i
|
||||||
|
(if (= i (length xreflist)) (setq imax nil));finish function if i equals il
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(princ "No xref found in model space.")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Unique - Lee Mac
|
||||||
|
;; Returns a list with duplicate elements removed.
|
||||||
|
|
||||||
|
(defun LM:Unique ( l )
|
||||||
|
(if l (cons (car l) (LM:Unique (vl-remove (car l) (cdr l)))))
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user