Code Red > VB(A)

How do replace an attribute in a table?

(1/1)

Refri:
How do replace an attribute in a table?
There is a table.
It contains a block with an attribute.
It is necessary through VBA in the first line of the table to change the attribute "ATR" value "DD25" to "HH38".
I'm trying to get a block and change the attribute, but it changes it for everyone.


--- Code: ---Set block = ThisDrawing.Blocks
For Each item In block
str = item.EntityName
 'Get t attributes
If item.EntityName = "AcDbAttributeDefinition" Then
if item.TextString ="DD25" then  item.TextString="HH38"
End If
End If
Next item
--- End code ---

DEVITG:
Hi, I   know almost nothing about VBA , but what you have to change ia at BLOCKREFERENCE , not at the BLOCKCOLLECTION . I do Lisp.
If you look for BLOCKCOLLECTION , of course all will be changed .
Hope it help 

Refri:
Problem is that these blocks do not exist in the BLOCKREFERENCE.
If there is an example of a lisp - give

roy_043:

--- Code - Auto/Visual Lisp: ---(defun c:Test ( / attDefId blk blkRecId enm tbl)  (if    (and      (setq enm (car (entsel)))      (setq tbl (vlax-ename->vla-object enm))      (= "AcDbTable" (vla-get-objectname tbl))      (/= 0 (setq blkRecId (vla-getblocktablerecordid tbl 0 0)))    )    (progn      (setq blk (vla-objectidtoobject (vla-get-activedocument (vlax-get-acad-object)) blkRecId))      (vlax-for obj blk        (if          (and            (not attDefId)            (= "AcDbAttributeDefinition" (vla-get-objectname obj))          )          (setq attDefId (vla-get-objectid obj))        )      )      (if attDefId        (vla-setblockattributevalue tbl 0 0 attDefId "New String")      )    )  )  (princ))

Refri:
roy_043
Excellent !
Thank you ! Exactly what is needed. The question is solved.

Navigation

[0] Message Index

Go to full version