For the line.......
(command "save" (strcat (getvar "dwgprefix") (getvar "dwgname")) "Y")
You use .......
(command "save" (strcat (getvar "dwgprefix") (getvar "dwgname")))
About the Code, this is a valid/working Code........ Did you check it properly..........
For trial Check the below code over multiple Drawings (into a Folder), only by selecting the Folder (containing the Drawings)......... This Code will draw a line from 0,0,0 to 1000,1000,1000 into each Drawing into the Folder.......
(defun C:TEST ( / sh folder folderobject result SDI_Val LISPI_Val Files_Folder n)
(defun *error* ( msg )
(vl-cmdf "SDI" SDI_Val)
(vl-cmdf "LISPINIT" LISPI_Val)
(if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*"))
(princ (strcat "\nOops an Error : " msg " occurred."))
)
(princ)
)
(vl-load-com)
(setq sh (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application" ))
(setq folder (vlax-invoke-method sh 'BrowseForFolder 0 "" 0 ))
(vlax-release-object sh)
(setq SDI_Val (getvar "SDI"))
(setq LISPI_Val (getvar "LISPINIT"))
(if folder
(progn
(vl-cmdf "SDI" 1)
(vl-cmdf "LISPINIT" 0)
(setq folderobject (vlax-get-property folder 'Self))
(setq result (vlax-get-property FolderObject 'Path))
(vlax-release-object folder)
(vlax-release-object FolderObject)
(setq Files_Folder (vl-directory-files result "*.dwg"))
; (command "save" (strcat (getvar "dwgprefix") (getvar "dwgname")) "Y")
(command "save" (strcat (getvar "dwgprefix") (getvar "dwgname")))
(setq n 0)
(while (< n (length Files_Folder))
(command "fileopen" (strcat result "\\" (nth n Files_Folder)))
(command "line" "0,0,0" "1000,1000,1000" "")
(vl-cmdf "save" (strcat result "\\" (nth n Files_Folder)))
(setq n (+ 1 n))
)
(vl-cmdf "SDI" SDI_Val)
(vl-cmdf "LISPINIT" LISPI_Val)
)
)
)
You check you Attached lines into the Code.......
Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....