Jump to content

need help with field


LISP2LEARN

Recommended Posts

how can I auto update the field value (base on fieldeval) for SNUM and STITLE on my drawing plot sheet without running the code each time I set up a new plot sheet. File would be "A.1.1 FIRST FLOOR PLAN.dwg" . Thanks.

 

Sample code:

(DEFUN c:TEST ()
(vl-load-com)
(setq DNAME (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 4)))
(setq SNUM (substr dname 1 (vl-string-search " " dname)))
(setq STITLE (substr DNAME (+ (vl-string-search " " dname) 2) 99))
(princ)
)

Edited by LISP2LEARN
Link to comment
Share on other sites

Yes, Lee. Thanks. SNUM and STITLE stored the value just for the first sheet but not on the second sheet. Here is the process that I been doing.

 

1. Set up a new sheet and name it "A.1.1 FIRST FLOOR PLAN".

Run the routine and insert the SNUM and STITLE variable as a field and save the drawing.

 

2. Use "SAVE AS" to create a new sheet "A.1.2 SECOND FLOOR PLAN".

 

3. Run the routine so SNUM and STITLE gets updated and use UPDATEFIELD command

to update the field value on the drawing.

 

4. Do step 2 and 3 until I'm finish setting up the plot sheets.

 

Is there is a way to skip step 3? auto update the field value when I save the drawing (fieldeval = 2).

I tried diesel but it didn't work because we have a poor naming convention "Project# A-1-1 SheetName". I need to manipute the DNAME so SNUM show correctly.

Base on our standard.

Edited by LISP2LEARN
Link to comment
Share on other sites

Oh, I see - you are using the LISP variables in the Field Expression. This isn't ideal since the variables will only persist in the active drawing session and so the Fields won't display correctly if the LISP hasn't been run (such as on a clients machine).

 

I can't immediately see a way to code your field using DIESEL, so the only alternative I can see is to use a command reactor to run the LISP program to update the variables before saving.

 

Note that your code could be changed to this, since it will currently error if the Drawing Name doesn't contain a space.

 

(defun c:test ( / name pos )
   (setq name (vl-filename-base (getvar 'DWGNAME)))
   (if (setq pos (vl-string-search " " name))
       (setq snum   (substr name 1 pos)
             stitle (substr name (+ pos 2))
       )
   )
   (princ)
)
(vl-load-com)

Link to comment
Share on other sites

I tried diesel but it didn't work because we have a poor naming convention "Project# A-1-1 SheetName". I need to manipute the DNAME so SNUM show correctly.

Base on our standard.

 

DIESEL could be used if the "Project#" was a fixed length, but this is quite a weak assumption.

 

For example, if the "Project#" has length 8:

 

$(substr,$(getvar,DWGNAME),1,

$(substr,$(getvar,DWGNAME),10,$(-,$(strlen,$(getvar,DWGNAME)),13))

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...