Steven P Posted February 6, 2020 Posted February 6, 2020 Good afternoon, I wonder if anyone has anything like this they could share with me? So the engineer removes 'Note 3' from the notes. In the drawing are references to note 6, note 7 and 10 (for example) which of course will need to be changed to note 5, 6, and 9. So does anyone have a LISP that can search the drawing to find 'Note xyz' and larger and increment it by a set number (in the above example a -1 increment). Perhaps with options to specify the preliminary text ('Note', or 'See Note' being common here) and the start number (for example 3, above).. and then off it goes and does it's magoc Thanks Quote
stevsmith Posted February 6, 2020 Posted February 6, 2020 Why don't you just leave the note in and change the content of 'Note 3' with the comment "Note Removed for xx (RevXX)"? Quote
BIGAL Posted February 7, 2020 Posted February 7, 2020 Agree "Not Applicable", you can renumber auto but not a relation ship to another note number, not sure if can be done in Word if so that's the way to go as you can copy and paste into mtext. Quote
rlx Posted February 7, 2020 Posted February 7, 2020 (edited) just quickly put & pasted together , no example -> no testing ; test (renum "12ab34cd5.65<90" +1 1) -> "13ab34cd5.65<90" [start incrementing from first number] ; (renum "12ab34cd5.65<90" -1 1) -> "12ab34cd5.65<91" [start incrementing from last number] (defun renum ( %txt %start %verschil / txt-l nr-begin nr-l nrs i voor-txt getal na-txt) ;testen of input geldig is en binnen grenzen (if (and (= (type %txt) 'str) (> (setq txt-l (strlen %txt)) 0) (wcmatch %txt "*#*")) (progn (if (or (null %start)(= %start 0)(not (numberp %start))) (setq %start 1)) (if (> (abs %start) txt-l) (if (minusp %start) (setq %start (- 0 txt-l)) (setq %start txt-l))) (if (minusp %start) (setq i (+ 1 txt-l %start))(setq i %start)) (if (or (null %verschil)(= %verschil 0)(not (numberp %verschil))) (setq %verschil 1)) (setq nrs '(48 49 50 51 52 53 54 55 56 57) nr-begin '() nr-l '() getal '() voor-txt "" na-txt "") ;testen of er een cijfer op het startpunt staat (while (and (> i 0)(<= i txt-l)(not nr-begin)) (if (member (ascii (substr %txt i 1)) nrs) (setq nr-begin i)) (if (minusp %start)(setq i (1- i))(setq i (1+ i)))) (if nr-begin (progn (while (and (> i 0) (<= i txt-l)(member (ascii (substr %txt i 1)) nrs)) (if (minusp %start) (setq i (1- i)) (setq i (1+ i)))) (cond ( (= i 0) (setq nr-l nr-begin nr-begin 1)) ( (> i txt-l) (setq nr-l (1+ (- txt-l nr-begin)))) (t (if (minusp %start) (setq nr-l (- nr-begin i) nr-begin (1+ i)) (setq nr-l (- i nr-begin))))) (setq voor-txt (substr %txt 1 (1- nr-begin)) getal (itoa (+ (atoi (substr %txt nr-begin nr-l)) %verschil)) na-txt (substr %txt (+ nr-begin nr-l))) (while (and (= #VtKeepZeros "1") (< (strlen (strcat voor-txt getal na-txt)) txt-l)) (setq getal (strcat "0" getal))) (strcat voor-txt getal na-txt) ) (setq %txt %txt) ) );end progn (setq %txt %txt) );end if ) ; test (ripcar "abc123") (defun ripcar (s) (vl-list->string (vl-remove-if '(lambda(x)(or (< x 48)(> x 57)))(vl-string->list s)))) (defun wai (blk tag val) (setq tag (strcase tag) blk (ent->vla blk)) (if blk (vl-some '(lambda (x) (if (= tag (strcase (vla-get-tagstring x))) (progn (vla-put-textstring x val) val))) (vlax-invoke blk 'getattributes)))) (defun tai ( blk tag ) (setq tag (strcase tag) blk (ent->vla blk)) (if blk (vl-some '(lambda (x) (if (= tag (strcase (vla-get-tagstring x))) (vla-get-textstring x))) (vlax-invoke blk 'getattributes)))) (defun ent->vla ( e / ss ) (cond ((= (type e) 'VLA-OBJECT) e) ((= (type e) 'ENAME)(vlax-ename->vla-object e)) ((and (= (type e) 'STR) (tblsearch "block" e)(setq ss (ssget "x" (list (cons 0 "INSERT")(cons 2 e))))) (ent->vla (ssname ss 0))) (t nil))) ;selection set to entity list (defun SS->Lst (ss / i l)(setq i 0 l '())(repeat (sslength ss)(setq l (cons (ssname ss i) l) i (1+ i))) l) ; start with (c:nono) or just nono on commandline after routine is loaded (defun c:nono ( / incr pos sel att att-dat att-name att-txt blk blk-dat blk-name note-no s) ; incr = number by which to increment , pos = start postion (-1 start from back) (setq incr -1 pos -1) (if (and (setq sel (nentsel "Select note to delete : ")) (setq att (car sel)) (setq att-dat (entget att)) (= (cdr (assoc 0 att-dat)) "ATTRIB") (setq att-name (cdr (assoc 2 att-dat))) (setq blk (cdr (assoc 330 att-dat))) (setq blk-dat (entget blk)) (setq blk-name (cdr (assoc 2 blk-dat))) (setq att-txt (tai blk att-name)) (setq note-no (atoi (ripcar att-txt)))) (progn (entdel blk) (if (setq ss (ssget "_X" (list (cons 0 "INSERT")(cons 2 blk-name)))) (foreach blk (ss->lst ss) (if (> (atoi (ripcar (setq s (tai blk att-name)))) note-no)(wai blk att-name (renum s pos incr)))))) (princ "\nNo note selected") ) (princ) ) Edited February 7, 2020 by rlx Quote
Steven P Posted February 7, 2020 Author Posted February 7, 2020 Thanks RLX, I'll have to look at this on Monday now. Stevsmith, thats not always possible or aceptable to the clients Quote
Steven P Posted February 13, 2020 Author Posted February 13, 2020 hi RLX, It's Thursday now and I haven't really had a chance to test this this week. A first go and it didn't do much so I might have to ask you a question or 2 next week on how it works if I can't work out why Quote
rlx Posted February 13, 2020 Posted February 13, 2020 don't worry , I can keep myself busy I just made a block with one attribute and put a text in it note-1 , note-2 etc. You select the note you want to delete (you must select the attribute) , it then read the number (in my example the number is 6) and then it deletes note six and renumbers the attributes higher than 6 so note-7 to note-9 will become note-6 to -8. NoNo.dwg 1 Quote
BIGAL Posted February 14, 2020 Posted February 14, 2020 rlx I think he is talking about like a Word DOC approach with autonumbering if you make it in word a bit easier then you gets Notes 1 2 3 4 etc we had around 5 sections each started at Item 1 General, Environment, Structural etc, something word does well. So if I removed item 23 a paragraph the complete notes would be renumbered again from 1. So no missing 23. To quote OP So the engineer removes 'Note 3' from the notes. In the drawing are references to note 6, note 7 and 10 (for example) which of course will need to be changed to note 5, 6, and 9. Do you have company notes ? If not numbered paste into word and number paragraphs then paste into Mtetxt remove a para and request makes sense. Quote
rlx Posted February 14, 2020 Posted February 14, 2020 @bigal ... nope I don't have company notes. It probably can be done if AutoCAD is linked with Word but that's uncharted terrain for me. Quote
Steven P Posted February 14, 2020 Author Posted February 14, 2020 thanks BigAl, that's pretty much wat I was wanting to do rlx code is a good start - so long as the 'see note xyz' text is a block, it will work so I just need to get my brain thnking to adjust it so it looks at text and mtext as well (probably easy but I will need to think about it). I' quite simple with my CAD - I don't like linking things to word or whatever, partly because the clients typically get the CAD files and their -non CAD- engineer moan if they have to do anyting other than open a dawing straight off an e-mail Thanks Quote
BIGAL Posted February 14, 2020 Posted February 14, 2020 I just referred to Word as it was easier to make the numbered notes then paste into Mtext. I don't think word allows referenced items either. Mtext has numbering. Quote
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.