Hi guys hav a GooD dAy...!!
i want to paste the today date over the selected text after that zoom extent the screen automatically by lisp ...
i attached files for ur reference.
Plz help me this bcz the same change i hav to do 40 files per day...
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Something like this perhaps.
(vl-load-com) (defun c:demo (/ cd day dte mth obj ss txt yer) (prompt "\nSelect Text text to place current date: ") (if (setq ss (ssget "_+.:E:S:L" '((0 . "TEXT,MTEXT")))) (progn (or *acad* (setq *acad* (vlax-get-acad-object)) ) (setq obj (vlax-ename->vla-object (ssname ss 0)) cd (getvar "CDATE") dte (rtos cd 2 4) yer (substr dte 1 4) mth (substr dte 5 2) day (substr dte 7 2) txt (strcat day "." mth "." yer) ) (vlax-put obj 'TextString txt) (vla-zoomextents *acad*) ) ) (princ) )
HTH
Henrique
Here are two options, the first uses a Field (i.e. the text will automatically update to display the current date), the second uses plain text:
(defun c:test1 ( / ent ) (while (progn (setvar 'errno 0) (setq ent (car (nentsel "\nSelect text, mtext or attribute: "))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil) ( (not (wcmatch (cdr (assoc 0 (entget ent))) "TEXT,MTEXT,ATTRIB")) (princ "\nInvalid object selected.") ) ( (vla-put-textstring (vlax-ename->vla-object ent) "%<\\AcVar Date \\f \"dd.MM.yyyy\">%")) ) ) ) (princ) ) (vl-load-com) (princ)
(defun c:test2 ( / ent ) (while (progn (setvar 'errno 0) (setq ent (car (nentsel "\nSelect text, mtext or attribute: "))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil) ( (not (wcmatch (cdr (assoc 0 (entget ent))) "TEXT,MTEXT,ATTRIB")) (princ "\nInvalid object selected.") ) ( (vla-put-textstring (vlax-ename->vla-object ent) (menucmd "m=$(edtime,0,dd.mo.yyyy)"))) ) ) ) (princ) ) (vl-load-com) (princ)
I modified hmsilva's lisp lines and made them bold.
-Changed .'s to /'s
-Changed Month/Day/Year
-Added string to omit the zero in front of the months with 01-09 number months.
(vl-load-com)
(defun c:cd (/ cd day dte mth obj ss txt yer)
(prompt "\nSelect Text text to place current date: ")
(if (setq ss (ssget "_+.:E:S:L" '((0 . "TEXT,MTEXT"))))
(progn
(or *acad*
(setq *acad* (vlax-get-acad-object))
)
(setq obj (vlax-ename->vla-object (ssname ss 0))
cd (getvar "cdate")
dte (rtos cd 2 4)
yer (substr dte 3 2)
mth (itoa(atoi(substr dte 5 2)))
day (substr dte 7 2)
txt (strcat mth "/" day "/" yer)
)
(vlax-put obj 'TextString txt)
)
)
(princ)
)
Can't find what you're looking for? Ask the community or share your knowledge.