hi guys! someone out there check my lsp code i was trying to figure out
how can i change this format 0001-02-01 to 0001-02-02, 0001-02-03, 0001-02-04 and so on....
Code:
(defun c:I-2(/ *Error* Inc Ent Obj OldStr Mode
NewStr OldNum Lst Res Pt)
(defun *Error* (Msg)
(cond
((or (not Msg)
(member Msg '("console break"
"Function cancelled"
"quit / exit abort"))))
((princ (strcat "\nError: " Msg)))
) ;cond
(setvar "cmdecho" 1)
(princ)
) ;end
(vl-load-com)
(defun Str2Num (str / test numlst lst)
(setq test (list 46 48 49 50 51 52 53 54 55 56 57))
(setq charlst (vl-string->list str))
(foreach x charlst
(if (member x test)
(setq lst (cons x lst))
(setq lst (cons 32 lst))
)
)
(read (vl-list->string (reverse lst)))
)
(defun DecimalTest (str)
(if
(or
(= "." (substr str 1 1))
(= "-." (substr str 1 2))
(= "-.-" (substr str 1 3))
)
(vl-princ-to-string (atof str))
str
)
)
(defun PickTest ()
(while
(or
(null (setq Obj (entsel "\nSelect text to increment or Cancel to end:
")))
(and
(/= "MTEXT" (cdr (assoc 0 (entget (car Obj)))))
(/= "TEXT" (cdr (assoc 0 (entget (car Obj)))))
) ;and
) ;or
(setq Obj (entsel "\nText object not selected - try again: "))
) ;while
) ;end
(setvar "cmdecho" 0)
(setq Inc (read (DecimalTest
(getstring "\nEnter increment value positive or negative: "))))
(initget 1 "Y N ")
(setq Mode (getkword "\nCopy text [Yes/No] : "))
(if (or (= Mode "") (= Mode "N"))
(setq Mode "N")
)
(while T ;repeat
(cond
((= Mode "N")
(PickTest)
(setq Ent (car Obj))
) ;cond
((= Mode "Y")
(if (null Ent)
(progn
(PickTest)
(setq Ent (car Obj) Pt (cadr Obj))
(command ".copy" Ent "" Pt pause)
(setq Ent (entlast))
)
(progn
(command ".copy" (entlast) "" (getvar "lastpoint") pause)
(setq Ent (entlast))
)
) ;if
) ;cond
) ;cond
(setq Lst (entget Ent))
(setq OldStr (DecimalTest (cdr (assoc 1 (entget Ent)))))
(setq OldNum (Str2Num OldStr))
(if OldNum
(progn
(setq Res (+ Inc OldNum)
Res (vl-princ-to-string Res)
OldNum (vl-princ-to-string OldNum)
NewStr (vl-string-subst Res OldNum OldStr 0)
Lst (subst (cons 1 NewStr) (assoc 1 Lst ) Lst))
(entmod Lst)
(entupd Ent)
)
(princ "\nNumber not found in text object ")
) ;if
) ;while
(*Error* nil)
(princ)
) ;end
;shortcut
(defun c:IT () (c:IncrementText))
in this code i was able to change 0001-02-01 to 0002-02-01, 0003-02-01, 0004-02-01 and so on
please i wiil be very greatful if some does thanks!!!