PDA

View Full Version : Date Stamp Routine


Robert.Hall
2005-05-20, 04:38 PM
Anybody have a lisp routine that will replace x-xx with the current date in hyphenated format
(ie. 5-20-05) ?????

I use x-xx to represent dates and then when a drawing gets released I replace it with the current date. Ive seen some lisp routines for the date stamps, but nothing that would do what I need.

RobertB
2005-05-20, 04:51 PM
Why not use a field?

Robert.Hall
2005-05-20, 06:59 PM
How would that work????

If I insert several fields for the date, I don't see how I could update all of them in one shot.

jwanstaett
2005-05-23, 03:48 PM
use the find command to replace all the xx-xxx to the new date

note: find command new in 2000 was part of express tool on r14
with some changes in 2005 and 2006

Robert.Hall
2005-05-23, 06:37 PM
That would work except I am looking for something that would just take "Todays Date"
and fill it in............all my designers would need to do is run a lisp routine and everything would be dated for release.

scwegner
2005-05-23, 07:11 PM
Try using a rtext with diesel (assuming you have the express tools).

http://discussion.autodesk.com/thread.jspa?messageID=2122069
http://discussion.autodesk.com/thread.jspa?messageID=441390
http://discussion.autodesk.com/thread.jspa?messageID=447505

RobertB
2005-05-23, 07:53 PM
Try using a rtext with diesel (assuming you have the express tools).

http://discussion.autodesk.com/thread.jspa?messageID=2122069
http://discussion.autodesk.com/thread.jspa?messageID=441390
http://discussion.autodesk.com/thread.jspa?messageID=447505
I would advise not using RText if you are planning on supporting AutoCAD 2006. There is a serious bug returned by ActiveX when it hits RText. ActiveX does not know how to handle RText and throws an exception.

scwegner
2005-05-23, 07:55 PM
I would advise not using RText if you are planning on supporting AutoCAD 2006. There is a serious bug returned by ActiveX when it hits RText. ActiveX does not know how to handle RText and throws an exception.
Oops. Didn't know that. So I guess there are some advantages to using stone-age AutoCAD.

bbapties
2005-05-23, 08:01 PM
im still confused on why you can't use fields......after inserting they would update everytime you open the drawing........or if for some reason you worked starting at 11pm on one day and needed to plot at 1am the next (assuming you still had the drawing open) you could just do a quick "updatefield"....

Robert.Hall
2005-05-23, 10:14 PM
Updating the date everytime I open a drawing or resave the file is unacceptable. Im working with an engineering change level/release date. Has nothing to do with when a drawing was plotted and/or worked on.

kennet.sjoberg
2005-05-24, 12:03 AM
Anybody have a lisp routine that will replace x-xx with . . .

;;; Change ALL rhall's "x-xx" with Mont-Day-Year (ie. 5-20-05)
(defun c:rhallDate ( / SelSet Index Counter Ent EntDxf )
(if (setq SelSet (ssget "_X" '((0 . "TEXT"))) ) ; <-- You can add layer as filter here
(progn
(setq Index 0 Counter 0 )
(setq Ent (ssname SelSet Index ) )
(while Ent
(setq EntDxf (entget (ssname SelSet Index )) )
(if (wcmatch (cdr (assoc 1 EntDxf )) "*x-xx*" )
(progn
(setq EntDxf
(subst
(cons
1
(vl-string-subst
(strcat
(substr (rtos (getvar "CDATE")) 4 1)
"-"
(substr (rtos (getvar "CDATE")) 7 2)
"-"
(substr (rtos (getvar "CDATE")) 5 2)
)
"x-xx"
(cdr (assoc 1 (entget (ssname SelSet Index))) )
)
)
(assoc 1 (entget (ssname SelSet Index)))
EntDxf
)
)
(entmod EntDxf )
(setq Counter (1+ Counter ) )
)
( )
)
(setq Index (1+ Index ) )
(setq Ent (ssname SelSet Index ) )
)
(princ (strcat (itoa (sslength SelSet )) " text investigated, and " (itoa Counter) " changed." ) )
)
(princ "No text to change" )
)
(princ)
)

: ) Happy Computing !

kennet

RobertB
2005-05-24, 02:49 AM
Updating the date everytime I open a drawing or resave the file is unacceptable. Im working with an engineering change level/release date. Has nothing to do with when a drawing was plotted and/or worked on.
Then you would use the Date field. It updates only when manually updated.

Robert.Hall
2005-05-24, 02:55 PM
Thanks to Kennet for the great routine..........I tried it on a file that has 20 instances
of the x-xx date and it replaced them perfectly with the current date. This is going to
come in real handy.

I tried using fields, however, the only way I could get them to update was to manually edit them. Constantly changing them on saving, closing, etc. would not be good for me.

jwanstaett
2005-05-24, 03:30 PM
im still confused on why you can't use fields......after inserting they would update everytime you open the drawing........or if for some reason you worked starting at 11pm on one day and needed to plot at 1am the next (assuming you still had the drawing open) you could just do a quick "updatefield"....
?? I am using 2002 no fields
can fields use formula to show the drawing Properties
if so use fields like RText to display one of the drawing custom property
this way all you do is change the Custom property and the data is update
you will also be able to check the date in explorer with out opening the drawing

kennet.sjoberg
2005-05-24, 09:39 PM
Thanks to Kennet for the great routine..........
I am glad when You are glad, one day You may help me.

Happy Computing !

kennet

. . . and thanks for RP :)

RobertB
2005-05-25, 06:34 PM
I tried using fields, however, the only way I could get them to update was to manually edit them. Constantly changing them on saving, closing, etc. would not be good for me.So why didn't you use the SaveDate field?

Robert.Hall
2005-05-25, 07:39 PM
So why didn't you use the SaveDate field?

I dont quite see how I can start that off as "X-XX" and then later down the road get every
instance (several) throughout my drawing to then show the current date. I found by using fields that I had to select each field I wanted to update individually and couldn't start off with the text string as "X-XX". :?

saf13562003
2005-05-26, 07:40 PM
I have a plot stamp I use, it has worked great for the past )*()%%, years... give this a try
you must put an attribute in your title block name "plot"
;=========== PLOT DATE ========================
; BY: STEVE FUQUA
(defun c:pd (/ a b c d e f g h z y v1 v2 v3 v4 td xa)
; (command "zoom" "e")
(setq a (getvar"cdate"))
(setq ax (getvar"ctab"))
(setq b (rtos a 2 9))
(setq c (substr b 3 2))
(setq d (substr b 5 2))
(setq e (substr b 7 2))
(setq f (getvar"dwgname"))
(setq g (substr b 10 2))
(setq h (substr b 12 2))
(setq f (strcase f))
(setq dv(getvar "dwgprefix"))
(setq td (strcat d"/"e"/"c" "dv""f" " g":"h ""))
(command "attedit" "y" "*" "PLOT" "*" "C" (getvar"extmin")
(getvar"extmax") "v" "r" (eval td)(command))
(command "attedit" "y" "*" "xtab" "*" "C" (getvar"extmin")
(getvar"extmax") "v" "r" (eval ax)(command))
)
;=====================================================



let me know if this helps saf13562003@yahoo.com

RobertB
2005-05-31, 11:44 PM
I dont quite see how I can start that off as "X-XX" and then later down the road get every
instance (several) throughout my drawing to then show the current date. I found by using fields that I had to select each field I wanted to update individually and couldn't start off with the text string as "X-XX". :?
#1 Don't worry about starting it off as X-XX. Why bother, when every time you save you know you will get the correct date?

#2 The SaveDate field does not require a manual update. Only the Date field does.

Robert.Hall
2005-06-01, 02:19 PM
I need non dated draft copies to read X-XX :-p

RobertB
2005-06-01, 05:37 PM
I need non dated draft copies to read X-XX :-p
Think process efficiency here, not "how it's always been done". Too often the "powers to be" (I'm one of them) says, in a thunderous voice "THAT IS THE WAY WE HAVE ALWAYS DONE IT, THOU SHALT NOT DEVIATE!!!!", which, of course, is just beating ourselves up.
Why not simply plot draft copies with a "Draft" watermark?

Robert.Hall
2005-06-01, 06:47 PM
I did...........however, people were using them as controlled copies even though they were stamped draft. As per TS16949, it was a major noncomformance. What is to stop people from doing so??? Nothing. Currently I am paperless with password controlled dwf files.
Unless I post a dated drawing, nothing exists. All non-dated paper copies are for my own use and are worth shredding. I use a placeholder where the date belongs.

Robert.Hall
2005-06-02, 03:15 PM
I have the routine shown below.........I tried this today and I need it to
return 6-2-05. What I got was 5-02-06.......please advise, I played around
and I couldn't correct the format. I kept getting an error.
;;; Change ALL rhall's "x-xx" with Mont-Day-Year (ie. 5-20-05)
(defun c:today ( / SelSet Index Counter Ent EntDxf )
(if (setq SelSet (ssget "_X" '((0 . "TEXT"))) ) ; <-- You can add layer as filter here
(progn
(setq Index 0 Counter 0 )
(setq Ent (ssname SelSet Index ) )
(while Ent
(setq EntDxf (entget (ssname SelSet Index )) )
(if (wcmatch (cdr (assoc 1 EntDxf )) "*X-XX*" )
(progn
(setq EntDxf
(subst
(cons
1
(vl-string-subst
(strcat
(substr (rtos (getvar "CDATE")) 4 1)
"-"
(substr (rtos (getvar "CDATE")) 7 2)
"-"
(substr (rtos (getvar "CDATE")) 5 2)
)
"X-XX"
(cdr (assoc 1 (entget (ssname SelSet Index))) )
)
)
(assoc 1 (entget (ssname SelSet Index)))
EntDxf
)
)
(entmod EntDxf )
(setq Counter (1+ Counter ) )
)
( )
)
(setq Index (1+ Index ) )
(setq Ent (ssname SelSet Index ) )
)
(princ (strcat (itoa (sslength SelSet )) " text investigated, and " (itoa Counter) " changed." ) )
)
(princ "No text to change" )
)
(princ)
)

tyshofner
2005-06-02, 03:29 PM
Here you go note changes in red:
;;; Change ALL rhall's "x-xx" with Mont-Day-Year (ie. 5-20-05)
(defun c:today ( / SelSet Index Counter Ent EntDxf )
(if (setq SelSet (ssget "_X" '((0 . "TEXT"))) ) ; <-- You can add layer as filter here
(progn
(setq Index 0 Counter 0 )
(setq Ent (ssname SelSet Index ) )
(while Ent
(setq EntDxf (entget (ssname SelSet Index )) )
(if (wcmatch (cdr (assoc 1 EntDxf )) "*X-XX*" )
(progn
(setq EntDxf
(subst
(cons
1
(vl-string-subst
(strcat
(substr (rtos (getvar "CDATE")) 5 2)
"-"
(substr (rtos (getvar "CDATE")) 7 2)
"-"
(substr (rtos (getvar "CDATE")) 3 2)
)
"X-XX"
(cdr (assoc 1 (entget (ssname SelSet Index))) )
)
)
(assoc 1 (entget (ssname SelSet Index)))
EntDxf
)
)
(entmod EntDxf )
(setq Counter (1+ Counter ) )
)
( )
)
(setq Index (1+ Index ) )
(setq Ent (ssname SelSet Index ) )
)
(princ (strcat (itoa (sslength SelSet )) " text investigated, and " (itoa Counter) " changed." ) )
)
(princ "No text to change" )
)
(princ)
)

Ty :mrgreen:

kennet.sjoberg
2005-06-03, 12:41 AM
.......please advise
rhall (getvar "CDATE") shows 2.00506e+007 as real, and converted real to string
(rtos (getvar "CDATE") 2 16 ) shows "20050603.00170648" means YYYYMMDD.HHmmss = Year Month Day.Hour minutes seconds and part of seconds.
To returns a substring of a string, use substr :
(substr (rtos (getvar "CDATE")) 1 4 ) shows 2005 = YYYY, start at position 1 and show 4 positions
(substr (rtos (getvar "CDATE")) 5 2 ) shows 06 = MM start at in position 5 and show 2 positions
(substr (rtos (getvar "CDATE")) 7 2 ) shows 03 = DD start at in position 7 and show 2 positions

simple as to mark the substr in Vlide and click the [?] icon

: ) Happy Computing !

kennet

Robert.Hall
2005-06-03, 02:31 PM
Thanks for the explanation........I am starting to understand lisp and have written a couple of routines on my own. Slowly but surely wins the race :razz: