Need lisp to Delete attributes

Need lisp to Delete attributes

Anonymous
Not applicable
1,623 Views
15 Replies
Message 1 of 16

Need lisp to Delete attributes

Anonymous
Not applicable

Hi, befor you say "look and you will find some" i have some, but they dont work i dont know why cause im a absolute rookie in autocad lisps but yeah.
I will attach you a cad 2010 (I work on autocad mep 2018 or autocad 2018)  saved file with the block reference i need, cause i have much more and they should safe there attributes.


I hope its clear what i want and i hope you will help me ^^"

0 Likes
1,624 Views
15 Replies
Replies (15)
Message 2 of 16

ВeekeeCZ
Consultant
Consultant

So you want to remove an attribute or its content?

If the first one, use pendean's routine HERE 

If the latter, then use dlanor's HERE 

Just tried both and both works.

0 Likes
Message 3 of 16

cadffm
Consultant
Consultant

Wenn du nur die Werte von gleichnamigen Attributen löschen möchtest und nicht die Attribute,

dann kannst du die Blockreferenzen wählen und den Wert in der Eigenschaftenpalette löschen.

 

Auch kannst du ATTOUT <in Excel bearbeiten> und ATTIN benutzen.

 

Was ich aber überhaupt nicht verstehe: Du hast doch schon einen anderen Thread eröffnet

und nach genau so einer individuellen Programmierung gefragt und hast diese bekommen,

warum also die erneute Frage und ein anderer Thread anstatt in dem bestehenden zu bleiben?

 

Your other thread

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-delete-attributes-and-lisp-t...

Command CBA

 

 

googletrans

If you only want to delete the values of attributes with the same name and not the attributes,
then you can select the block references and clear the value in the Properties palette.
Also you can edit ATTOUT <in Excel> and use ATTIN.
What I do not understand at all: You've already opened another thread
and asked for exactly such individual programming and got them
So why the repeat question and another thread instead of staying in the existing one?

Sebastian

0 Likes
Message 4 of 16

Anonymous
Not applicable

Let´s take this code what do i have to change that it works for my drawing. My biggest problem with this codes is that everything is is shortcutted and so im never sure what i can change and what i cant without i kill the complete code. 

 

(vl-load-com)
;Clear Block Attributes : This is will clear all variable attributes in ALL selected blocks in modelspace (set textstring to "")
(defun c:CBA (/ *error* ss obj atts)

  (defun *error* ( msg )
    (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nAn Error : " msg " occurred.")))
    (princ)
  );_end_*error*_defun

  (prompt "\nSelect Attributed Blocks to Empty : ")             ;; If you want to automate remove this line
  (setq ss (ssget '((0 . "INSERT") (66 . 1) (410 . "Model"))))  ;; If you want to automate (EVERY BLOCK) change this line to (setq ss (ssget "_X" '((0 . "INSERT") (66 . 1) (410 . "Model"))))

  (if ss
    (repeat (setq cnt (sslength ss))
      (setq obj (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt))))
            atts (vlax-invoke obj 'getattributes)
      );end_setq
      (mapcar '(lambda (x) (vla-put-textstring x "")) atts)
    );end_repeat
    (princ "\nNothing Selected/Found")
  );end_if
  (princ)
);end_defun

@cadffm  wie ich eben oben beschreibe komme ich mit den codes nicht zurecht und die person die mir bis dato geholfen hat ist jetzt eine woche nicht da, dazu kommt das ich in dem thread 2 fragen gestellt habe wovon eine sich erledigt hat.

0 Likes
Message 5 of 16

cadffm
Consultant
Consultant

>"Let´s take this code what do i have to change that it works for my drawing."

NOTHING! so long we are talking about attributeVALUEs only (like your sample. Left blockreference is like "before" and the right one is the "result" of CBA)

 

You start the CBA command and select your blockreferences, or in the other order,

and CBA delete all attributevalues from all attributes of selected blockreferences.

(if layer0 is unlocked, what should be EVER the case)

Sebastian

0 Likes
Message 6 of 16

ВeekeeCZ
Consultant
Consultant

So the code works. Good.

And you don't understand the code. The code is really very simple, there is nothing much to change without some knowledge.

So the question is

- what you don't understand 

- what change would like to make

0 Likes
Message 7 of 16

Anonymous
Not applicable

okey than tell me why it doesnt i tryed it right now selected the block references loaded the CBA...nothing 
loaded the CBA selected the blocks ...still nothing 

unfortunly im not allowed to give you the complete drawing so you can test but yeah 

0 Likes
Message 8 of 16

cadffm
Consultant
Consultant

NO

YOU HAVE to test CBA with the given BULB.dxf first

 

if it is working there we can talk about your complete drawing

after you tested it in MODEL tab and ALL Layers unlocked.

 

____

Sorry, but a "does not work" is the weakest description you can deliver
Normally error messages should appear [F2].

Sebastian

0 Likes
Message 9 of 16

cadffm
Consultant
Consultant

@Anonymous  schrieb:

 loaded the CBA...n


 

 

LOADED???

You have to LOAD the lisp and then you have to START the new command!

Befehl: CBA

 

 

Sebastian

0 Likes
Message 10 of 16

Anonymous
Not applicable

yeah might me a weak discription but thats the case 

Just drag and dropped : Befehl: (LOAD "C:/Users/Aleks/Desktop/Skript Projekt/Lisps/Attdel - Kopie (2).lsp") C:CBA

 

Appload loaded: Befehl: APPLOAD
Attdel - Kopie (2).lsp erfolgreich geladen.

 

btw in the bulb not the complete drawing

 

there are no frozen disabled or locked layers and im in the model tab. I also restarted autocad just to make sure

0 Likes
Message 11 of 16

ВeekeeCZ
Consultant
Consultant

HERE  is some basic info on how to use LISP.

0 Likes
Message 12 of 16

cadffm
Consultant
Consultant

@cadffm  schrieb:

NO

YOU HAVE to test CBA with the given BULB.dxf first

if it is working there we can talk about your complete drawing


 

Open your bulb.dxf

drag&drop your lsp file

and start

Befehl: CBA

Select Attributed Blocks to Empty :
Objekte wählen:

 

Let us know at what step you stucked, it sounds you are not starting the new command by type in CBA..

 

Sebastian

0 Likes
Message 13 of 16

Anonymous
Not applicable

okey i missed that step thats the reason why it didnt work: Befehl: CBA.

with the missed step it works in the complete drawing also ^^

can we automize it so far that the lisp is choosing the right blocks automaticly ?

i really apriciate your patience.

0 Likes
Message 14 of 16

cadffm
Consultant
Consultant

For non-dynamic blocks it is simple, for dynamic blocks you need another code.

 

What are "the right blocks"? Just the one "DECKENLEUCHTE_M" ? Just in Model-Tab?

 

A stupid variant of this code:

(defun c:CBA_DECKENLEUCHTE_M (/ *error* ss obj atts)
  (defun *error* ( msg )
    (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nAn Error : " msg " occurred.")))
    (princ)
  );_end_*error*_defun

  (prompt "\nSelect Attributed Blocks to Empty : ")             ;; If you want to automate remove this line
  (setq ss (ssget "_X" '((0 . "INSERT")(2 . "DECKENLEUCHTE_M") (66 . 1) (410 . "Model"))))  ;; If you want to automate (EVERY BLOCK) change this line to (setq ss (ssget "_X" '((0 . "INSERT") (66 . 1) (410 . "Model"))))

  (if ss
    (repeat (setq cnt (sslength ss))
      (setq obj (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt))))
            atts (vlax-invoke obj 'getattributes)
      );end_setq
      (mapcar '(lambda (x) (vla-put-textstring x "")) atts)
    );end_repeat
    (princ "\nNothing Selected/Found")
  );end_if
  (princ)
);end_defun

 

Sebastian

0 Likes
Message 15 of 16

Anonymous
Not applicable

yeah its just this one block and just in model space so your code works fine. thx.

can we make that CBA_DECKENLEUCHTE_M tipping automized to ? or is this a nacessary step i have to do ?

 

0 Likes
Message 16 of 16

cadffm
Consultant
Consultant

There are so many ways to reach the goal and I hate to give a solution if I know there is too little knowledge about the process.

One possibility would be to add a (C: CBA) at the end of the Lisp file.
Whenever the file is loads, the command is executed.

But you better build a button that does the loading and running separately,
or you always load the file and you just have to start the command.


You go the worst way to learn = in a hurry

That's why i am out here.

Sebastian

0 Likes