I am using the following command to delete a layer in my drawing.
(command "-laydel" "name" "Y-24x36-AV" "" "yes")
There are currently items on that layer and autocad puts up a warning that there are items on those layers and the warning pops up that says this. Is there a way to disable this warning and just push deleting the layer and everything on it?
On a similar note, is there a way to automatically override a file with saveas and push overriding a dwg?
(command "_.saveas" "_2018" "S:\\Templates\\Civil Templates\\CAD Templates\\07_24x36\\02_ONSITE\\C-0 TITLE SHEET.dwg")
@emilio24DRY
I use this LISP I put together awhile back to do delete a layer and save as a specific file type without giving errors. i'll list out what you need below. below that is my full LISP. in my full LISP, i will occasionally change it to run on STARTUP, so i can open hundreds of files at once to run through them all automatically for me.
(defun c:G ()
;; Delete DEFPOINTS layer if it exists
(if (tblsearch "LAYER" "DEFPOINTS")
(command "_.LAYDEL" "N" "DEFPOINTS" "" "YES")
)
;; Select objects on layer "0"
(setq ss (ssget "_X" '((8 . "0"))))
;; Delete selected objects
(if ss
(command ".erase" ss "" "")
)
(command "purge" "A" "*" "N")
;;change the ac2004_dwg to the style year of your choice
(vla-saveas (vla-get-activedocument (vlax-get-acad-object))
(strcat (getvar 'dwgprefix)
(if (getvar 'dwgtitled)
(getvar 'dwgname)
"Drawingname"))
ac2004_dwg)
(command ".CLOSE")
);END
----------------------------------------------------------------------------------------------------------
MY FULL LISP
(defun c:G ()
;; Delete DEFPOINTS layer if it exists
(if (tblsearch "LAYER" "DEFPOINTS")
(command "_.LAYDEL" "N" "DEFPOINTS" "" "YES")
)
;; Select objects on layer "0"
(setq ss (ssget "_X" '((8 . "0"))))
;; Delete selected objects
(if ss
(command ".erase" ss "" "")
)
(command "purge" "A" "*" "N")
(command "UCS" "W")
(command "-VIEW" "SW")
(command "ZOOM" "_E")
(command "VSCURRENT" "R")
(command "VSEDGES" "0")
(command "VSCURRENT" "2")
(command "OSMODE" "0")
(command "-LAYER" "M" "" "")
(command "_point" "0,0,0")
;;(command "._QSAVE")
(vla-saveas (vla-get-activedocument (vlax-get-acad-object))
(strcat (getvar 'dwgprefix)
(if (getvar 'dwgtitled)
(getvar 'dwgname)
"Drawingname"))
ac2004_dwg)
;;(command "OSMODE" "11")
;;(princ "\nVERY GOOD!")
;;(princ)
(command ".CLOSE")
);END
Thank you both. I thought that the lisp routine was stopping because of the warnings, but fortunately, the lisp routine ignores the warnings and continues with the rest of the commands.
@emilio24DRY wrote:
Thank you both. I thought that the lisp routine was stopping because of the warnings, but fortunately, the lisp routine ignores the warnings and continues with the rest of the commands.
Look into vl-cmdf
The vl-cmdf function is similar to the command function, but differs from command in the way it evaluates the arguments passed to it. The vl-cmdf function evaluates all the supplied arguments before executing the AutoCAD command, and will not execute the AutoCAD command if it detects an error during argument evaluation. In contrast, the command function passes each argument in turn to AutoCAD, so the command may be partially executed before an error is detected.
Can't find what you're looking for? Ask the community or share your knowledge.