LISP2LEARN Posted June 26, 2011 Share Posted June 26, 2011 (edited) 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 June 26, 2011 by LISP2LEARN Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 26, 2011 Share Posted June 26, 2011 UPDATEFIELD command? Quote Link to comment Share on other sites More sharing options...
LISP2LEARN Posted June 26, 2011 Author Share Posted June 26, 2011 (edited) 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 June 26, 2011 by LISP2LEARN Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 26, 2011 Share Posted June 26, 2011 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) Quote Link to comment Share on other sites More sharing options...
LISP2LEARN Posted June 26, 2011 Author Share Posted June 26, 2011 Thanks for the tip Lee, I'll continue with that. thanks again. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 26, 2011 Share Posted June 26, 2011 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)) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.