Author Topic: Select and edit a tag in a block with multiple attributes.  (Read 1839 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
Select and edit a tag in a block with multiple attributes.
« on: June 19, 2017, 02:36:51 PM »
I would like to know how to edit a specific tag in an attribute without having to explicitly defining the tag id. I have seen this somewhere before I can't recall where.
In case I had a block with two attribute tags I would like to click on either text it would edit that specific tag. See attached for an example of the block. If someone could help me out with some sample code. Much appreciated. Thanks.

*Would like to utilize entsel or entmod to edit the attribute*

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Select and edit a tag in a block with multiple attributes.
« Reply #1 on: June 19, 2017, 03:10:44 PM »
Maybe:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ e)
  2.   (if (and (setq e (car (nentsel))) (= "ATTRIB" (cdr (assoc 0 (setq e (entget e))))))
  3.     (entmod (subst (cons 1 "TEST") (assoc 1 e) e))
  4.   )
  5.   (princ)
  6. )
You can also hold down CNTRL and double click the attribute to edit with out the 'Enhanced Attribute Editor".

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

dubb

  • Swamp Rat
  • Posts: 1105
Re: Select and edit a tag in a block with multiple attributes.
« Reply #2 on: June 19, 2017, 03:21:23 PM »
That is exactly what I'm looking for. Thanks Ron.

Maybe:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ e)
  2.   (if (and (setq e (car (nentsel))) (= "ATTRIB" (cdr (assoc 0 (setq e (entget e))))))
  3.     (entmod (subst (cons 1 "TEST") (assoc 1 e) e))
  4.   )
  5.   (princ)
  6. )
You can also hold down CNTRL and double click the attribute to edit with out the 'Enhanced Attribute Editor".

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Select and edit a tag in a block with multiple attributes.
« Reply #3 on: June 19, 2017, 03:42:26 PM »
Glad to help :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

dubb

  • Swamp Rat
  • Posts: 1105
Re: Select and edit a tag in a block with multiple attributes.
« Reply #4 on: June 20, 2017, 12:06:25 PM »
Here is what I a made.

Next thing I want to do is update or edit an attribute in a block without having to define the tag id. The block only has one attribute.

Code: [Select]
;select text or mtext
;select attribute
;edits attribute with text
(defun c:atxt (/ e)
  (setq txt (cdr(assoc 1 (entget(car(entsel))))))
    (if (and (setq e (car (nentsel))) (= "ATTRIB" (cdr (assoc 0 (setq e (entget e))))))
    (entmod (subst (cons 1 txt) (assoc 1 e) e))
  )
  (princ)
)
« Last Edit: June 20, 2017, 12:11:30 PM by dubb »