Hello everybody,
I recently stumbled upon a post "SON OF A BATCH! AUTOCAD CORE CONSOLE THROUGH LISP" about applying lisp scripts to many .dwg files without needing to open a full AutoCAD instance. It fit our needs perfectly.
After a bit of testing I was able to write a quick program to open all of the .dwg files I wanted to run the script in, in accoreconsole windows.
(defun modifyNameInEachDWG ( / )
;;remplacer tous les \ par les / pour le faire fonctionner
(setq chemin "C:/Users/XX/Desktop/XX-Copy")
(setq files (vl-directory-files chemin "*.dwg"))
(foreach file files
;; don't forget the spaces at the end!
(command "start" (strcat "accoreconsole.exe "
"/i \"" chemin "/" file "\" "
"/s \"M:/Ingenierie/Ingenieur/Code/renommer des calques.scr\" "
"/l en-US"))
);_foreach
)
This works great, launching the roughly 20 accoreconsole.exe windows I would expect for each .dwg. The problem is the code I'm running
"Renommer des calques.scr"
doesn't seem to apply the layer name change. This is puzzling as it does do the save operation correctly, and the layer name change works great when used one at a time on designs.
(vl-load-com)
(vlax-for lyr (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (setq table (cons (vla-get-name lyr) table)));_vlax-for
(foreach layer table (if (vl-string-search "CT_NOTES" layer) (vl-cmdf "-Rename" "LAYER" layer (vl-string-subst "CT_DEVIS" "CT_NOTES" layer))));_foreach
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
(vla-Save doc)
Does anybody have an idea why the layer name change is not applied while the save is, in the batch run version, while both work in the single run version?
Thank you in advance for any suggestions.
MasterMiner