Laymrg stop at first drawing in script.

Laymrg stop at first drawing in script.

Anonymous
Not applicable
1,233 Views
5 Replies
Message 1 of 6

Laymrg stop at first drawing in script.

Anonymous
Not applicable

Hello, 

 

can someone fix my lisp error ? Laymrg run done in the first drawing then not run to another drawing.

 

;; Load Supporting Functions
;; Old Version of 'BrowseForFolder' by: Tony Tanzillo
(defun BrowseForFolder
(Message / sh folder parentfolder folderobject result)
(vl-load-com)
(setq sh (vla-getInterfaceObject
(vlax-get-acad-object)
"Shell.Application"
)
)
(setq folder (vlax-invoke-method sh 'BrowseForFolder 0 Message 0))
(vlax-release-object sh)
(if folder
(progn
(setq parentfolder (vlax-get-property folder 'ParentFolder))
(setq FolderObject
(vlax-invoke-method
ParentFolder
'ParseName
(vlax-get-property Folder 'Title)
)
)
(setq result (vlax-get-property FolderObject 'Path))
(mapcar 'vlax-release-object
(list folder parentfolder folderobject)
)
(if (/= (substr result (strlen result)) "\\")
(setq result (strcat result "\\"))
result
)
)
)
)
(defun c:change_layer (/ DirPath DwgFile DwgList my_lisp_file Ofile)

(if (setq DirPath (BrowseForFolder "Select directory to scan drawings.")
)
(progn
(setq my_lisp_file "change Layer.lsp")
(setq Scrfile (strcat DirPath "test.scr"))
(setq Ofile (open Scrfile "w"))
(setq DwgList (vl-directory-files DirPath "*.dwg" 1))
(foreach Dwg DwgList
(setq DwgFile (strcat DirPath Dwg))
(write-line
(strcat "_.open\r" (chr 34) DwgFile (chr 34) "\r")
Ofile
)
(write-line
(strcat "(load " (chr 34) my_lisp_file (chr 34) ")")
Ofile
)
(write-line "_.qsave" Ofile)
(write-line "_.close" Ofile)
)
(close Ofile)
(command "_.script" Scrfile)
(vla-sendcommand
(vla-get-activedocument (vlax-get-acad-object))
"(vl-file-delete Scrfile)\r"
)
(princ)
)
)
(command "_PURGE""A" "" "N")
(command "_PURGE""A" "" "N")
(command "_PURGE""A" "" "N")
(setvar "FILEDIA" 0)
(princ)
)

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

(defun change_layer (/ lst2 lst1 n layer1 layer2 )
(vl-load-com)
(setvar "cmdecho" 0)
;;;***************************************************************************************************************************************
(command "_.layer"
"unlock" "*" "thaw" "*" "on" "*"
"m" "Defpoints" "c" "4" "" "l" "Continuous" "" "plot" "no" "" NIL
"_Make" "A-SYMB" "_Color" "111""" "Ltype" "Continuous" "" "Lweight" "0.18""" "plot" "PLOT" ""NIL
"_Make" "A-CEILING" "_Color" "32""" "Ltype" "Continuous" "" "Lweight" "0.13""" "plot" "PLOT" ""NIL
"A-DOOR" "_Color" "31""" "Ltype" "Continuous" "" "Lweight" "0.13""" "plot" "PLOT" ""NIL
"A-ES" "_Color" "61""" "Ltype" "Continuous" "" "Lweight" "0.13""" "plot" "PLOT" ""NIL
"_Make" "A-ESSYMB" "_Color" "64""" "Ltype" "Continuous" "" "Lweight" "0.13""" "plot" "PLOT" ""NIL

"" )
(setq lst2 '("A-A1"
"A-A2"
"A-A3"

))
(setq lst1 '("0-B1"
"L-B2"
"L-B3"
))
(setq n 0)
(repeat
(Length lst1)
(setq layer1 (nth n lst1))
(setq layer2 (nth n lst2))
(if (tblsearch "LAYER" layer1)
(if (tblsearch "LAYER" layer2)
(command "_.-LAYMRG" "_Name" layer1 "" "_N" layer2 "_Y")
);if layer2
);if layer1
(setq n (+ n 1))
)


(setvar "cmdecho" 1)

);defun

 

Thanks for solution.

^_^

0 Likes
Accepted solutions (1)
1,234 Views
5 Replies
Replies (5)
Message 2 of 6

hmsilva
Mentor
Mentor
Accepted solution

@Anonymous wrote:

Hello, 

 

can someone fix my lisp error ? Laymrg run done in the first drawing then not run to another drawing.

 

...


Untested...

Try to change

 

(command "_.-LAYMRG" "_Name" layer1 "" "_N" layer2 "_Y")

 

to

 

(command "_.-LAYMRG" "_Name" layer1 "" "_N" layer2)
(while (> (getvar 'CMDACTIVE) 0)
   (command "_Y")
)

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 3 of 6

Anonymous
Not applicable

ok, that's right

 

Thanks Henrique

0 Likes
Message 4 of 6

Anonymous
Not applicable

heizz, next error,

 

load lisp done but not auto creat layer. hik.

0 Likes
Message 5 of 6

hmsilva
Mentor
Mentor

@Anonymous wrote:

heizz, next error,

 

load lisp done but not auto creat layer. hik.


You'll have to answer/enter all the prompts inside the command  LAYER...

 

(command "_.layer"
"unlock" "*" "thaw" "*" "on" "*"
"_Make" "Defpoints" "_Color" "4" "" "_Ltype" "Continuous" "" "plot" "no" ""
"_Make" "A-SYMB" "_Color" "111""" "_Ltype" "Continuous" "" "Lweight" "0.18""" "plot" "PLOT" ""
"_Make" "A-CEILING" "_Color" "32""" "_Ltype" "Continuous" "" "Lweight" "0.13""" "plot" "PLOT" ""
"_Make""A-DOOR" "_Color" "31""" "_Ltype" "Continuous" "" "Lweight" "0.13""" "plot" "PLOT" ""
"_Make""A-ES" "_Color" "61""" "_Ltype" "Continuous" "" "Lweight" "0.13""" "plot" "PLOT" ""
"_Make" "A-ESSYMB" "_Color" "64""" "_Ltype" "Continuous" "" "Lweight" "0.13""" "plot" "PLOT" ""
"" )

 

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 6 of 6

Anonymous
Not applicable

Ok . thanks herrique.

 

I'll check later.

0 Likes