PDA

View Full Version : Change multiple Atribute values globally


marcus.hahn
2008-02-17, 10:02 AM
Hello,

My problem: I have a number of drawings in which I need to change the attribute value in a large number of attributes. The attributes have the same block name and tag. I have looked at solutions with the find and replace tool but haven't yet found a way to change a sequence of blocks with different values in a way that i can trust.

I imagine a script would be a good solution but I have very little experience of scripting.
The operation i need is something like;

In the blocks "fönsterdörr" (block name) with the tag "FD", change or replace the values:

FD17k4l to FD17vk4l
FD23k5 to FD23vk5
FD32vk4s to FD32k4s and so on....

Could anyone please give me a hint of what this code string would look like and how i could use it?

Best regards/ Marcus

abdulhuck
2008-02-17, 02:09 PM
Marcus,

Try the attached lisp file. You have to edit the file with your block name, list of desired strings and their corresponding values... You can even call this command in a script file.

Regards

Abdul

aaronic_abacus
2008-02-17, 09:19 PM
;This autolisp program sets all named attributes in all named blocks.


(DEFUN C:SAV ()
(PROMPT "\n*SET ATTRIBUTE VALUES*")
(SETQ BE (CAR (ENTSEL "\nSelect block entity for name: ")))
(SETQ BEL (ENTGET BE))
(SETQ BELBN (CDR (ASSOC 2 BEL)))
(SETQ BELBNF (LIST (CONS 2 BELBN)))
(SETQ TMV (GETVAR "TILEMODE"))
(SETVAR "TILEMODE" 1)
(SETQ BS (SSGET "X" BELBNF))
(SETVAR "TILEMODE" TMV)
(SETQ BSL (SSLENGTH BS))
(SETQ CT (- BSL 1))
(SETQ NEAS (CAR (NENTSEL "\nSelect attribute to change: ")))
(SETQ NEASL (ENTGET NEAS))
(SETQ NEASLAN (CDR (ASSOC 2 NEASL)))
(PROMPT "\nNew attribute value: ")
(SETQ NOFUV (READ-LINE))
(SETQ NOFNU (CONS 1 NOFUV))
(SETQ LP 1)
(WHILE LP
(SETQ NE (SSNAME BS CT))
(SETQ CT2 0)
(SETQ LP2 1)
(WHILE LP2
(SETQ NE (ENTNEXT NE))
(SETQ NEL (ENTGET NE))
(SETQ NEAET (CDR (ASSOC 0 NEL)))
(SETQ NEA (CDR (ASSOC 2 NEL)))
(IF (= NEA NEASLAN)
(PROGN
(SETQ OFNU (ASSOC 1 NEL))
(SETQ NNEL (SUBST NOFNU OFNU NEL))
(ENTMOD NNEL)
));END PROGN/IF
(IF (= NEAET "SEQEND") (SETQ LP2 NIL))
);END WHILE LP2
(SETQ CT (- CT 1))
(IF (< CT 0) (SETQ LP NIL))
);END WHILE LP
(COMMAND "REGEN")
(PRINC)
);END SAV