Selecting a block inside the table and updating value

Selecting a block inside the table and updating value

BranoFRXKW
Community Visitor Community Visitor
147 Views
1 Reply
Message 1 of 2

Selecting a block inside the table and updating value

BranoFRXKW
Community Visitor
Community Visitor

I’m new to Lisp and looking for some guidance on a problem I’m trying to solve.

I have a block in my drawing named NOTE SHEET 02. This block serves as a drawing note and contains a numbered circle (NOTE CIRCLE) inside autocad table. The number in the circle reflects the block’s suffix (in this case, 02 → 2).

If there is no block named NOTE SHEET 01 inside the drawing, i want to rename NOTE SHEET 02 to NOTE SHEET 01 and update the NOTE CIRCLE block inside the table to change its number from 2 to 1.

I have no idea how to access the NOTE CIRCLE block inside the AutoCAD table and update its value in lisp.

I’d greatly appreciate any advice. Thanks!

0 Likes
148 Views
1 Reply
Reply (1)
Message 2 of 2

Sea-Haven
Mentor
Mentor

You can get at the attribute in a couple of ways, the 1st is to use NENTSEL and pick the attribute in the table this exposes that attribute directly and you can change its value. See code below.

 

The second is to get the cell and the object inside then work through the object and change the attribute number. This is maybe more useful in a big table.

(defun c:wow ( / obj str)
  (setq obj (vlax-ename->vla-object (car (nentsel "\nPick object "))))
  (setq str (getstring "\nEnter new number "))
  (vlax-put obj 'Textstring str)
  (command "regen")
  (princ)
)

 

0 Likes