Jump to content

Adjust Date


Ohnoto

Recommended Posts

Below is my LISP code. What it currently does is adjust the date field on our drawings. I am trying to modify it where it will prompt for today's date, or then it can be adjusted manually.

 

The problem is that when prompted for today's date and hitting enter, the value isn't stored and comes out as "----", but when it is typed out, it works fine.

 

(defun c:AD ()
(vl-load-com)                                        ;;; Do not forget to add
 (Today)
  (setq str (getstring t (strcat "\nDate to be Placed - <" TodayDate ">")))
  (if (null str)
      (setq str TodayDate))
 
  (_dwgru-dwgprops-set-custom-prop "PlotDate" str nil)
 
  (princ "\n ----------------------------------------------")
  (princ (strcat "\n --------- Adjust Date - Version " ADTVerNum " ---------"))
  (princ (strcat "\n ---------------- Date: " str " --------------"))
  (princ "\n ----------------------------------------------")
 
 (princ)
  )

If anyone needs more of the code, I will post it up, but since this is dealing with the if statement not sure if it's needed.

Link to comment
Share on other sites

This is an example of how to save a value to argument ...

 

(setq wid (if wid
           width
           100.0
         )
)
(if (progn (initget 6)
          (setq width (cond ((getdist (strcat "\n Width of Rectangle : <"
                                              (rtos wid 2 2)
                                              ">:"
                                      )
                             )
                            )
                            (T wid)
                      )
          )
   )
 (setq wid width)
)

 

TharwaT

Link to comment
Share on other sites

This will feed the current date as a string to a LISP function:

 

(menucmd "M=$(edtime,$(getvar,date),YYYY-MO-DD)")

 

 

... And this is DIESEL for an attribute field:

%<\AcDiesel $(edtime, 0,M"/"DD"/"YYYY H:MM:SS AM/PM)>%

 

Hope this helps!

Link to comment
Share on other sites

Consider this example:

 

(defun c:AD ( / str today )

 (setq str
   (cond
     (
       (eq ""
         (setq str
           (getstring t
             (strcat "\nDate to be Placed <"
               (setq today (menucmd "m=$(edtime,$(getvar,DATE),DD.MO.YYYY)")) ">: "
             )
           )
         )
       )
       today
     )
     ( str )
   )
 )

 (princ str)
 (princ)
)

Link to comment
Share on other sites

I'm not looking to automatically do today's date in a field. I do know how to do that. The reason being is that when we send off prints, and then get them back we use the date to verify the drawing in that it wasn't a revision, as we only update the dates on prints with revisions, and if we had the date automatically update we couldn't do that. Not having these dates auto update is important since many times our dates have to coincide with permitting jurisdictions as well.

 

So currently our date's are embedded into a block, and I came up with a LISP to update a custom field to allow for updating the date without needing to go into the block editor. And I'm just having an issue with that if statement.

Link to comment
Share on other sites

I'm not looking to automatically do today's date in a field. I do know how to do that. The reason being is that when we send off prints, and then get them back we use the date to verify the drawing in that it wasn't a revision, as we only update the dates on prints with revisions, and if we had the date automatically update we couldn't do that. Not having these dates auto update is important since many times our dates have to coincide with permitting jurisdictions as well.

 

So currently our date's are embedded into a block, and I came up with a LISP to update a custom field to allow for updating the date without needing to go into the block editor. And I'm just having an issue with that if statement.

 

Dude, I never suggested that you to hard code either the LISP, or DIESEL expressions to automatically revise your block.

 

We use several expressions in what we call a 'plot stamp'... when the drawing was last saved, and by whom, when the drawing was last printed, and by whom, and the drawing's file path, and layout name. Each updates only when the applicable task is executed.

 

As Lee showed you in his posted example, the menucmd statement I provided above works quite nicely.

 

Personally, I use a toolbox function:

 

(defun i:Date ()
 (menucmd "M=$(edtime,$(getvar,date),YYYY-MO-DD)"))

 

... for tasks like this:

 

(defun c:AD  (/ str today)
 (setq str
        (cond ((eq ""
                   (setq
                     str (getstring t
                                    (strcat "\nDate to be Placed <"
                                            (setq today [b][color=red]([/color][/b][color=blue]i:Date[/color][b][color=red])[/color][/b])
                                            ">: "))))
               today)
              (str)))
 (princ str)
 (princ))

 

... But that's becasue I'm lazy, and don't like to re-type everything.

Link to comment
Share on other sites

I apologize, I wasn't being rude or trying to dismiss you. I just read through your posting too quickly and when I saw the diesel code thought that it was for auto-updating date and time, and in my error further explained my working procedure.

Link to comment
Share on other sites

I apologize, I wasn't being rude or trying to dismiss you. I just read through your posting too quickly and when I saw the diesel code thought that it was for auto-updating date and time, and in my error further explained my working procedure.

 

No worries, Ohnoto. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...