Editting specified attribute with autolisp

Editting specified attribute with autolisp

10nji
Participant Participant
297 Views
4 Replies
Message 1 of 5

Editting specified attribute with autolisp

10nji
Participant
Participant

Hello, I'm new in this forum, and I'd like you to help me.

I need to edit a lot of attribute values based on the database frequently. Doing it manually is very ineffficient, so I'd like to make it automated. This is an example I want solve (sorry it is Japanese version):

shanbenzhenzhi2_0-1658215778877.png

 

In the above picture, for example, I want to change the attribute value "B" to "D" by entering " ATT2 D  ". If possible, I also want to edit several block attributes simultaneously from a csv file. 

 

Because of my poor English, this instruction may be hard to understand, so please ask me anything if you cannot understand well. Thank you.

0 Likes
298 Views
4 Replies
Replies (4)
Message 2 of 5

3wood
Advisor
Advisor

You can try command ATTOUT and ATTIN to manage multiple attributes with a csv file.

0 Likes
Message 3 of 5

ВeekeeCZ
Consultant
Consultant

Also, look at Lee's programs, he has quite a few for working with attributes.

http://www.lee-mac.com/programs.html

0 Likes
Message 4 of 5

Sea-Haven
Mentor
Mentor

Yes can enter string "Att2 D" note when asked for string enclose in "    " 

 

 

(defun c:wow ( / str obj oldtag )
; thanks to Lee-mac for this defun 
; www.lee-mac.com
(defun _csv->lst ( str / pos )
	(if (setq pos (vl-string-position 32 str))
		(cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2))))
		(list str)
    )
)
(setq str (getstring "\Enter att tag and new val "))
(setq obj (vlax-ename->vla-object (car  (entsel "Pick Block"))))
(setq lst (_csv->lst str))
(foreach att (vlax-invoke obj 'getattributes)
(if (= (strcase (nth 0 lst)) (strcase (vla-get-tagstring att)))
(vla-put-textstring att (nth 1 lst))
)
)
(princ)
)

 

Why not hold Ctrl key down and pick attribute does the same much easier.

Message 5 of 5

10nji
Participant
Participant

OK..... Thank you @3wood and @ВeekeeCZ , I found some information seemed useful, but it is difficult for me... I have to study harder at the time being. Thanks to your Information, I can understand my problem well..

0 Likes