From 777da7e906364d04c1057c5ea3f2e98b63c6b02d Mon Sep 17 00:00:00 2001 From: infeeeee Date: Thu, 22 Oct 2020 17:04:19 +0200 Subject: [PATCH] Script cleanup, fix if no xref found --- revitDwgImportCleaner.lsp | 50 +++++++++++++-------------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/revitDwgImportCleaner.lsp b/revitDwgImportCleaner.lsp index 0d16167..7949aa9 100644 --- a/revitDwgImportCleaner.lsp +++ b/revitDwgImportCleaner.lsp @@ -16,42 +16,25 @@ ; ---------------------------------------------------------------------------- ; ; ------------------------ XREFS: bind and detach all ------------------------ ; -(defun bindXrefs (/ really blk blklist xrefpath xreflist) +(defun bindXrefs (/ ss 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))) - ) + ;; Check if there are inserts at all + (setq ss (ssget "_A" '((0 . "INSERT") (410 . "MODEL")))) - ;; Clean duplicates - (setq blklist (LM:Unique blklist)) - - ;; Create a list of found xrefs - ;; Removed this part, because it fails if the xrefs name differs from the filename: - ;; (setq i 0);counter to zero - ;; (setq imax 1);while variable - ;; (while imax + (if ss + (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))) + ) - - ;; (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 + ;; Clean duplicates + (setq blklist (LM:Unique blklist)) + (initget 1 "Yes No") (setq really (getkword "Bind xrefs? [Yes/No]")) (if @@ -70,9 +53,8 @@ ) ) ) - ;; ) - ;; (princ "No xref found in model space.") - ;; ) + ) + ) ) (defun LM:Unique ( l )