Search the Community
Showing results for tags 'write text at a point'.
-
Lisp to open multiple DWG's and write in each one
andr3flaviano posted a topic in AutoLISP, Visual LISP & DCL
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) ; (setq num0 (ssget "_C" '(347.06 18.12) '(350.90 18.12))) ; (command ".erase" num0 "" ); (setq pt1 '(346.5 15.84)) ; (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) (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")) (setq num (getstring t "\nType the numer: ")) ; (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) ; (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?- 1 reply
-
- open dwg
- function calling
-
(and 3 more)
Tagged with: