96
322
234
后起之秀
;;; Function to load LayMrg2 dialog(defun load_dialog_LayMrg2 (/ fn f) (setq fn (strcat (getvar "TEMPPREFIX") "LayMrg2.DCL")) (setq f (open fn "w")) (write-line "LayMrg2 : dialog {" f) (write-line " label = "Merge Layers";" f) (write-line " : text { key = "Label"; label = "Layers to merge:"; }" f) (write-line " : list_box { key = "List"; height = 17; width = 50; multiple_select = true; }" f) (write-line " ok_cancel;" f) (write-line "}" f) (close f) (load_dialog fn)) ;_ end of defun(defun LayMrg2:GetNames (lst / dcl names enter lay) (if (and (= (getvar 'cmddia) 1) (= (logand (getvar 'cmdactive) (+ 4 32 64)) 0) (setq dcl (load_dialog_LayMrg2)) (new_dialog "LayMrg2" dcl) ) (progn (while (setq lay (tblnext "LAYER" (not lay))) (if (wcmatch (setq enter (cdr (assoc 2 lay))) "~*|*") (setq names (cons enter names)) ) ) (start_list "List") (mapcar 'add_list (setq lay (acad_strlsort names))) (end_list) (set_tile "List" (vl-string-trim "()" (vl-princ-to-string (vl-sort (mapcar '(lambda (lay) (vl-position lay names)) lst) '<)))) (setq names nil) (action_tile "List" "(setq names (read (strcat "(" $value ")")))") (if (= (start_dialog) 1) (setq names (mapcar '(lambda (n) (nth n lay)) names)) (setq names nil) ) (unload_dialog dcl) ) (while (setq enter (getstring t "Enter a layer name to add (Enter to stop): ")) (if (setq dcl (tblsearch "LAYER" enter)) (if (not (member (setq dcl (cdr (assoc 2 dcl))) names)) (setq names (cons dcl names)) ) (princ "That layer doesn't exist.\n") ) ) ) names);; Layer Merge but keep color & linetype settings(defun c:LayMrg2 (/ en ed ln llst ld) (while (progn (initget "Name") (setq en (entsel "\nSelect object on layer to merge or [Name]: ")) ) ;_ end of progn (if (= en "Name") (if (setq ln (LayMrg2:GetNames llst)) (setq llst ln) (princ "No layer selected, try again.") ) (progn (princ "\n") (if (setq ed (entget (car en))) (if (not (member (cdr (assoc 8 ed)) llst)) (setq llst (cons (cdr (assoc 8 ed)) llst)) ) ;_ end of if ) ;_ end of if ) ;_ end of progn ) ;_ end of if (princ (strcat "Selected layers: " (car llst))) (foreach ln (cdr llst) (princ (strcat "," ln)) ) ;_ end of foreach ) ;_ end of while (setq en (entnext)) ;Get 1st entity (while (and en (setq ed (entget en))) (if (setq ln (member (cdr (assoc 8 ed)) llst)) (progn (setq ld (tblsearch "LAYER" (car ln))) ;; Color (if (not (assoc 62 ed)) (setq ed (append ed (list (assoc 62 ld)))) ) ;; Linetype (if (not (assoc 6 ed)) (setq ed (append ed (list (assoc 6 ld)))) ) (entmod ed) ) ) (setq en (entnext en)) ) (if (and (= (getvar 'cmddia) 1) (= (logand (getvar 'cmdactive) (+ 4 32 64)) 0) ) (initdia) ) (command "._LAYMRG") (foreach ln llst (command "_Name" ln) ) ;_ end of foreach (command "") (while (> (getvar "CMDACTIVE") 0) (command pause) ) ;_ end of while (princ)) ;_ end of defun(princ);|«Visual LISP© Format Options»(120 2 1 2 nil "end of " 100 9 0 0 1 nil T nil T);*** DO NOT add text below the comment! ***|;