Hello.
I have a problem with changes in drawings head. I need a help in writing a lisp which will add some text to block attribute in multiple drawings.
I will explain exactly what I want to achieve:
- I have a block with attribute (tag name: POS_NUM, value:335)
- I need to change attribute (tag name: NUMERO, value:S-355). As you can see I need to add prefix to attribute without deleting the old values.
I have managed with changing only values and tag names in block, but I can`t find any solution for adding prefix.
I also want to change a blockname.
I don`t know also if it is possible to have a lisp which will delete normal text (e.g. “drawing_number”) in block?
Is it also possible to add prefix on the left side but without changing the position of old text in attribute?
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
Export the attributes values by using ATTOUT.
Open the text file created by ATTOUT in excel and add the prefix, save the text file.
Then in autocad type ATTIN and select the text file.
To chanage the TAG name, use BATTMAN command and rename.
@Anonymous wrote:
Hello.
I have a problem with changes in drawings head. I need a help in writing a lisp which will add some text to block attribute in multiple drawings......
You have too much going on with this thread kosiel. I think its easier if you post a drawing sample..
I have managed with changing only values and tag names in block,
How? Manually or using a lisp routine? if its the latter then post the ode here and we will ammend if for you.
-- but I can`t find any solution for adding prefix.
-- I also want to change a blockname.
-- i don`t know also if it is possible to have a lisp which will delete normal text (e.g. “drawing_number”) in block?
YES to all three
Is it also possible to add prefix on the left side but without changing the position of old text in attribute?
I'm guessing the position gets out of whack when you run attsync. Again post a sample drawing
Hi,
As you wrote I attache a picture with explainings. Additionally I post a file with drawing head.
I have managed with some problems by lisp. Also attache this file.
Hope that it`s more clear now. Thanks for your help.
@Anonymous wrote:
Hi,
As you wrote I attache a picture with explainings. Additionally I post a file with drawing head.
I have managed with some problems by lisp. Also attache this file.
Hope that it`s more clear now. Thanks for your help.
I*'ll see what i can do kosiel, wait for it......
EDIT: is this a repair job? just need to run once per drawing and wont be needing the routine after block is "repaired" ?
And what about the prefix? will that be a constant prefix for all drawing sheets?
Another question is, does the company your working for use multiple layout tabs? meaning there would be more than 1 instance of the title block "HYPERSTEELPAGEHEADER"?
Hi,
"EDIT: is this a repair job? just need to run once per drawing and wont be needing the routine after block is "repaired" ?"
To be onest I don`t understand. Drawins are ready and I need to change some elements in block. After changes drawings will be ready 🙂 and there will be no need to change anything in the drawing. But I am not sure if my explanation helped you.
"And what about the prefix? will that be a constant prefix for all drawing sheets?"
Yes, there will be always constant prefix.
There is always 1 layout (1 block in the drawing)
Hope my answers are clear, if not please write.
@Anonymous wrote:
Hi,
"EDIT: is this a repair job? just need to run once per drawing and wont be needing the routine after block is "repaired" ?"
To be onest I don`t understand. Drawins are ready and I need to change some elements in block. After changes drawings will be ready 🙂 and there will be no need to change anything in the drawing. But I am not sure if my explanation helped you.
"And what about the prefix? will that be a constant prefix for all drawing sheets?"
Yes, there will be always constant prefix.
There is always 1 layout (1 block in the drawing)
Hope my answers are clear, if not please write.
Ok, i think i get the idea.
BTW: what i meant by "repair job" is the routine is for this specific task only.
I have something for you later today..
Code Removed: I just realize the code is too "specific".... i'll post the modfied code in a few....
EDIT: come to think of it, i dont think i can avoid using "specifics" on this routine to accomodate the OPs request. so instead of using a sub with argujments, i will just stick with the regular defun.
I was trying to run lisp, but error occure :/.
Lisp has done some work, but not all. Prefix hasn`t been added. I add a file saved after running lisp.
@Anonymous wrote:
I was trying to run lisp, but error occure :/.
Lisp has done some work, but not all. Prefix hasn`t been added. I add a file saved after running lisp.
Well kosiel, works here on my end. i'm not sure of you're intention, i only updated two (2) tags as stated on the post "POS_NUM" "NUMERO" and "DRAWING_NO" to "TEGNNRU" [delete the TEXT and add to that tag]
Thinking about it now and looking at the lisp6 code you posted, there's more to it than just the two tags. is that what you mean by "not all"?
IS the tag name "DRAWING_NO" the only TAG that needed the "special attention" of adding the TEXT to the current value?
EDIT: define "prefix" for me kosiel
Oops, found a bug. a missplaced parenthesis on the groupby sub. anyhoo, I will modfy the code as soon as you can answer my querie regarding "prefix"
Sorry for mess and misunderstanding which I made.
I have added 2 pictures explaining exacly what I want to acheve. There is a picture before.png (before modification) and after.png (after modification). I think that this two picture show everyting.
@Anonymous wrote:
Sorry for mess and misunderstanding which I made.
I have added 2 pictures explaining exacly what I want to acheve. There is a picture before.png (before modification) and after.png (after modification). I think that this two picture show everyting.
OK then..
try this
(defun c:Uptb ( / _groupby atrv tagN ipt f g taglist bn) ;;; pBe 24July2014 ;;; ;;; ;;; (defun _groupby (lst / a b c nlst) (While (setq a (Car lst)) (setq b (cdr lst)) (setq a (list (Car a)(list (cdr a)))) (foreach ls b (if (eq (car a)(Car ls)) (setq c (list (car a) (cons (cdr ls) (cadr c))) b (vl-remove ls b))) ) (setq lst b nlst (cons c nlst) c nil) ) nlst ) (setq atrv nil bn "HYPERSTEELPAGEHEADER" taglist '(("DRAWING_NO" "TEGNNRU" ) ("POS_NUM2" "TEGN3" ) ("USERPROJATTR5" "GENERALTOL" ) ("SCALE" "SKA1" ) ("REVISION_INDEX" "REV" ) ("USERPROJATTR1" "GODK" ) ("DESIGNER" "KONF" ) ("DETAILER" "INIT" ) ("DETAILER" "REVINIT" ) ("DATE_DRAW" "REVDATE" ) ("DATE_DRAW" "DATOK" ) ("DATE_DRAW" "DATOG" ) ("DATE_DRAW" "DATO" ) ("DRAWING_NO" "TEGNNRU" ) ("POS_NUM" "NUMERO" ) ) ) (if (and (tblsearch "BLOCK" bn) (setq ss (ssget "_X" (list '(0 . "INSERT") '(66 . 1) (cons 2 bn) ) ) ) ) (progn (vlax-for o (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)) ) bn ) (if (vlax-write-enabled-p o) (cond ((and (eq (vla-get-objectname o) "AcDbAttributeDefinition") (setq tagN (assoc (setq tgn (vla-get-TagString o)) taglist) ) ) (if (eq tgn "DRAWING_NO") (vlax-put o 'Insertionpoint ipt) ) (vla-put-TagString o (cadr tagN)) ) ((and (eq (vla-get-objectname o) "AcDbText") (vl-every '(lambda (p v) (= (vlax-get o p) v) ) '( "Layer" "Alignment" "Height") '( "0dsy³acze" 9 5.0) ) ) (setq pref_ (vla-get-textstring o)) (setq ipt (vlax-get o 'Insertionpoint)) (vla-delete o) ) ) ) ) (repeat (setq i (sslength ss)) (setq o (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (foreach itm (vlax-invoke o 'GetAttributes) (if (member (vla-get-TagString itm) (mapcar 'car taglist)) (setq atrv (cons (list o (vla-get-TagString itm) (vla-get-textstring itm) ) atrv ) ) ) ) ) (command "_attsync" "_name" bn) (foreach itm (_groupby atrv) (setq _sblst (cadr itm)) (foreach ntag (vlax-invoke (Car itm) 'GetAttributes) (if (and (setq f (assoc (vla-get-tagstring ntag) (mapcar 'reverse taglist) ) ) (setq g (assoc (cadr f) _sblst)) ) (vla-put-textstring ntag (strcat (if (eq (cadr f) "DRAWING_NO") pref_ "") (cadr g) ) ) ) ) ) ) )(princ) ) (vl-load-com)
HTH
Thanks,
There is still problem with Drawing_No. Error eccure during running lisp. Lisp has changed almost everything, but Drawing_No hasn`t changed (see attached picture).
@Anonymous wrote:
Thanks,
There is still problem with Drawing_No. Error eccure during running lisp. Lisp has changed almost everything, but Drawing_No hasn`t changed (see attached picture).
I dont get any error on my end. Tell you what: copy and paste this and pick on the "BWV_513_056" text on you title block
(defun c:what (/ o layer Alignment Height Textstring) (if (And (setq ob (car (nentselp "\nSelect \"BWV_513_056\" on your title block") ) ) (Eq (Cdr (Assoc 0 (entget ob))) "TEXT") (setq o (vlax-ename->vla-object ob)) ) (progn (mapcar '(lambda (p) (print (set (read p) (Vlax-get o p))) ) '("Layer" "Alignment" "Height" "Textstring") ) (print (assoc 70 (entget (tblobjname "Layer" "0")))) ) ) (princ) )
And paste here what you got
Thanks a lot!!!!
That works. problem was with Layer name. It should be "Odsy3acze"!! Your program helped with finding it.
@Anonymous wrote:
Thanks a lot!!!!
That works. problem was with Layer name. It should be "Odsy3acze"!! Your program helped with finding it.
Well good for you. I knew it had to be one of those properties, Glad you had it sorted
You are welcome kosiel.
Happy to help.