hosyn Posted July 10, 2014 Posted July 10, 2014 ;;; 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! ***|; I've received this lisp code for merge layers from LEE MAC , and i have 3 layer with name layer1,layer2,layer3,.. ,i wanna use this lisp for merge these layers to "0" layer and i wrote this command: (LayMrg2:GetNames "layer1,layer2,layer3,...") But didn't do well it ,any suggestion?? Quote
BlackBox Posted July 10, 2014 Posted July 10, 2014 LayMrg2:GetNames is a sub-function that returns a list of valid Layer names (as part of the larger routine/command); to utilize the routine above, one must invoke the LayMrg2 Command. HTH Quote
hosyn Posted July 10, 2014 Author Posted July 10, 2014 Is there any way to use LayMrg2 Command for this purpose??? or need to modify the main program?? Quote
BlackBox Posted July 10, 2014 Posted July 10, 2014 Is there any way to use LayMrg2 Command for this purpose??? As written, the above command does not support being called as a sub-function. In order to achieve the functionality I suspect you to be after (it is a bit unclear to me; language barrier?), then you would need to code your own sub-function with the desired syntax, and properly accredit the author of the source code you culled (if applicable). Cheers Quote
BIGAL Posted July 11, 2014 Posted July 11, 2014 Also this error (defun LayMrg2:GetNames (lst ;;;the variable lst is a list of layer names (setq lst (list "layer1" "layer2" "layer3".....)) or (LayMrg2:GetNames (list "layer1" "layer2" "layer3"...")) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.