×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Update "DATE" field via lisp routine

Update "DATE" field via lisp routine

Update "DATE" field via lisp routine

(OP)
Since this thread has been closed:
http://www.tek-tips.com/viewthread.cfm?qid=1005434&page=26

I'm needing assistance to have our date field updated automatically.
What I have done is used a date field and I have to manually update this field to show the current date.  This lisp routine looks like a time saver but I'm having issues using it.
Please help.

RE: Update "DATE" field via lisp routine

Since you're using a field then you'd use a somewhat different approach.

According to help, "Note-The Date field is updated by UPDATEFIELD, but it is not updated automatically based on the setting of the  FIELDEVAL system variable."

How/when would you want this field/date updated? Is this for one particular drawing, or for many drawings, and a common block, or...
A routine could be made that is initiated with a command; or on opening a file. If you wanted it updated automatically upon, say plotting, I believe it would take a reactor.

RE: Update "DATE" field via lisp routine

(OP)
Yes, you are correct the UPDATEFIELD is not automatic.
Whenever a new drawing is open I would like our print-status date to be updated.
We send updated prints to our PM's and field hands and the print status date shows them the latest drawing they need to be referring to.
It would multiple drawings at certain times.
We have a template setup and this date would be in this template.
Reactor?  Please elaborate more . . .  

RE: Update "DATE" field via lisp routine

If the date needs to be updated just when you open the drawing, I believe that can be handled with come code in acad.lsp or acaddoc.lsp file, rather than using  the reactor method. A reactor is code that is executed upon some event, such as when a certain command is issued, the reactor code would fiirst be executed.

So back to your template, I assume this is a block with attributes, or a separate mtext field? How do you manually update the date, do you run UPDATEFIELD and select this block? I'm thinking the lisp routine would duplicate the manual method, except the block name would be provided in the code. This code would be executed on opening a drawing, so it runs automatically.

RE: Update "DATE" field via lisp routine

(OP)
Yes, it is a block with multiple attributes.  To update the fields we normally just double click the TB and it opens the enhanced attribute editor.
I'm following you so far smile . . . .
Thats why I thought the link I provided would help, it could either run automatically (which I prefer) or run as a lisp routine and we key it in.
Thanks in advance!

RE: Update "DATE" field via lisp routine

Try the following lisp routine..once we get it working it could be placed in acad.lsp file & modified to run upon opening a drawing.

CODE

(defun c:upd ()
  (setq tb_set (ssget "_X" (list '(0 . "INSERT") (cons 2 "Title_block_name_here"))))
  (if tb_set
      (command "._UPDATEFIELD" (ssname 0 tb_set) ""))
   )
   (princ)
)

Modify code above to replace "Title_block_name_here" with the titleblock's block name. Save the text to a text file, save with any desired name with a ".lsp" extension. Load the lisp, run it by typing "upd". (alternatively for testing purposes could copy & paste the code to the command line)

 

RE: Update "DATE" field via lisp routine

(OP)
It worked, although I did get an error message.  I had to manually select the field.
It will do the same thing if I was to type in updatefield.
But I guess like you said, we can tweek this lisp so it will run upon opening a any drawing everytime.  Even any previous saved drawing(s)?
See attached file for reference

RE: Update "DATE" field via lisp routine

OK as usual I had some typos..I actually tested the following code:

CODE

(defun c:upd ()
(setq tb_set (ssget "_X" (list '(0 . "INSERT") (cons 2 "block_name_here"))))
(if tb_set
(command "._UPDATEFIELD" (ssname tb_set 0) "")
)
(princ)
)

RE: Update "DATE" field via lisp routine

(OP)
Now it doesnt update any fields?

[Command: upd
._UPDATEFIELD
Select objects:   1 found

Select objects:
0 field(s) found.
0 field(s) updated. ]

Any ideas?

RE: Update "DATE" field via lisp routine

Hmmm, don't know offhand,as it worked for a simple test block, single attribute with a "date" field.
Looks like the block is getting selected but the field is not found/updated. Are you sure the date field is really an attribute versus some stand alone mtext field? If this is the case, the code could change to select all mtext:



CODE

(defun c:upd ()
  (setq mt_set (ssget "_X" '((0 . "MTEXT"))))
  (if mt_set
     (command "._UPDATEFIELD" mt_set "")
  )
  (princ)
)

RE: Update "DATE" field via lisp routine

(OP)
the title block is an attribute and the actual date field is single text converted to a date field. Sorry if I didnt iterate that correctly.
Could the lisp you provided read within the attribute which tag to change?  If so, that would be great.  Because the title blocks tags can all stay as one attribute block and the lisp could read withing the block and look for the date tag and update that?

RE: Update "DATE" field via lisp routine

For some reason that link doesn't wotrk for me.
What would be most helpful would be if you could send me a drawing,

c a b AT e e i t e a m DOT c o m
 

RE: Update "DATE" field via lisp routine

OK I saw the second link...
1. Seeing it is a block with attributes it should have worked if you edited the code for block name
(0 . "INSERT") (cons 2 "Vac Title Block_Original")

2. In the editor dialogue box at the link, no "value" is shown for he "date" tag, is that correct? With my test the last updated date would show up as the value.

RE: Update "DATE" field via lisp routine

(OP)
Here's what i have.
The Template dwt
Title block is inserted into the paperspace as an insert,
within the actual template.  This is kept as a block and not exploded.
Now the statusdate in the title block has a date field in it. I dont update the title block's statusdate but I update the date field with "UPD".
It ask for me to select it and it will change.
So, what i did was revert back to our original TB and removed the date field from the template so I could update the statusdate within the title block.
The command line prompts me this:
Command: upd
._UPDATEFIELD
Select objects:   1 found
1 was not in current space.

RE: Update "DATE" field via lisp routine

From that last message, sounds like you ran "upd" while in MS, but the block is in PS? Any difference if you run it from PS?

I really need to sse the setup, I'd be gals to look at if you email me an example drawing to address I posted above.

 

RE: Update "DATE" field via lisp routine

(OP)
You have mail!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close