Hello,
I have on every drawing a Block with the Attribute "Date". I created a Lisp to find this block and change the date to today.
This works very well.
Code:
(defun C:td (/ ss p )
(setq cdate_val (rtos (getvar "CDATE") 2 0))
(setq YYYY (substr cdate_val 1 4)
M (substr cdate_val 5 2)
D (substr cdate_val 7 2)
)
(setq adate(strcat YYYY "-" M "-" D))
(if
(ssget "_x" '((0 . "INSERT")))
(vlax-map-collection (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
(function (lambda (b)
(foreach at (vlax-invoke b 'getattributes)
(if
(eq (vla-get-tagstring at) "DATE")
(vla-put-textstring at adate)
)
)))))
(vla-delete ss)(princ)
)
But for this solution i must open every file.
So i had the idea to create a batch file to open the drawings in the core-console and run the lisp/scr
My batch file
Code:
echo off
:: Path to AutoCAD core console
set accoreexe="C:\Program Files\Autodesk\AutoCAD 2020\accoreconsole.exe"
:: Path the directory to process
set "source=C:\Users\robocop1989\Documents\Test"
:: Path to the script to run
set script="C:\Users\robocop1989\Documents\Autocad\test.scr"
FOR /f "delims=" %%f IN ('dir /b "%source%\*.dwg"') DO %accoreexe% /i "%source%\%%f" /s %script%
:: comment the following to automatically close the console when batch ends
pause
the script file
Code:
(load "C:/Users/robocop1989/Documents/Autocad/TODAY.lsp")
td
Filedia
0
save
Filedia
1
I think the problems are the "vlx" or "vla" comments in the list, because other lisp without this, are works.
Must i load something else in the script file?