Hello, guys!
I'm creating a lisp to open multiple DWG's in a directory and alterate a number at a especific position. I have a function (called txt) to write the number at a position and I have another function (called change_all) to open every DWG in the directory and execute the function "txt".
I want that the "Change_all" asks me the number and then execute the "txt" to write that number in all DWG's. The functions are already working, but i couldn't call the "txt" with the parameter number previously defined
Here are the code:
(defun c:txt (tval) ; < ---- Value to be writen at a point
(setq num0 (ssget "_C" '(347.06 18.12) '(350.90 18.12))) ;<---
(command ".erase" num0 "" ); <--- Erase the actual value at the point
(setq pt1 '(346.5 15.84)) ; <----- The coordinates of the point
(if (not (tblsearch "Layer" "TEXT"))
(command "-layer" "m" "TEXT" "")
) ;_ end if
(entmake (list '(0 . "TEXT")
'(8 . "TEXT5")
(cons 10 pt1)
(cons 40 4.5)
(cons 1 tval)
'(50 . 0.0)
'(7 . "ROMANS")
'(71 . 0)
'(62 . 4)
'(72 . 0)
'(73 . 0)
) ;_ end list
) ;_ end entmake
(*error* "")
(princ)
) ;_ end defun
(defun c: change_all (/ dwglist dwgname dwgpre file openfile uhoh len)
(setq num (getstring t "\nType the numer: ")) ; <-- Asks the value to be written
(vl-load-com)
(if (and (setq dwgpre (getvar 'dwgprefix))
(setq dwglist (vl-sort (vl-remove (strcat dwgpre (getvar 'dwgname))
(mapcar '(lambda (dwgname) (strcat dwgpre dwgname))
(vl-directory-files dwgpre "*.dwg")
)
)
'<
)
)
(setq uhoh
"Readonly drawings will not be processed!"
)
(setq len (strlen uhoh))
)
(progn (setq openfile (open (setq file (strcat dwgpre "myscript.scr")) "w"))
(progn (foreach f dwglist
(if (and
(not (Is_ReadOnly f))
(/= (checkAttFile f) 1)
)
(progn
(write-line (strcat "_.open \"" f "\"") openfile)
(write-line "(C: (txt num))" openfile) ;<-- Should open multiple DWG’s and execute the function “txt” with num as tval. but it don't work...
(write-line "_.qsave _.close" openfile)
)
(setq uhoh (strcat uhoh "\n" f))
)
)
(close openfile)
(command "_.script" file)
(if (= (strlen uhoh) len)
(princ "All drawings successfully processed...")
(alert uhoh)
)
)
)
)
(princ)
) ; End Defun
Could someone help me, please?