Edit Attributes in a block

Edit Attributes in a block

ladimirabdala
Advocate Advocate
356 Views
3 Replies
Message 1 of 4

Edit Attributes in a block

ladimirabdala
Advocate
Advocate
Some users help me to get an spefic block, now I'm trying get the attributes.

Set oLayout = ThisDrawing.ActiveLayout
Set oblock = oLayout.Block
For Each oEnt In oblock
If TypeOf oEnt Is AcadBlockReference Then
If oEnt.Name = "myspecificBlock" Then
msgbox "at this point I get the block as I want."
msgbox "How get the attributes this block?"
End If
End If
Next

How get and edit the attributes this block?
Sorry, must be a simple code, but my experience is in Lisp.

All help will be welcome.

Ladimir Abdala
CAD Systems Analyst
0 Likes
357 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
look up GetAttributes and HasAttributes in the help files
also do a google search on this ng
you'll get lots of samples

hth
mark

wrote in message news:5782554@discussion.autodesk.com...
Some users help me to get an spefic block, now I'm trying get the
attributes.

Set oLayout = ThisDrawing.ActiveLayout
Set oblock = oLayout.Block
For Each oEnt In oblock
If TypeOf oEnt Is AcadBlockReference Then
If oEnt.Name = "myspecificBlock" Then
msgbox "at this point I get the block as I want."
msgbox "How get the attributes this block?"
End If
End If
Next

How get and edit the attributes this block?
Sorry, must be a simple code, but my experience is in Lisp.

All help will be welcome.

Ladimir Abdala
CAD Systems Analyst
0 Likes
Message 3 of 4

ladimirabdala
Advocate
Advocate
Thank you.

I found this code that function very well.
And I want share with others:

Option Explicit
Sub chngAtt()
Dim objEnt As ACADObject
Dim objRef As AcadBlockReference
Dim varAtts As Variant
Dim objAtt As AcadAttributeReference
Dim emptyPt As Variant''

ThisDrawing.Utility.GetEntity objEnt, emptyPt, "Select block...: "
If objEnt.ObjectName = "AcDbBlockReference" Then
Set objRef = objEnt
If objRef.HasAttributes Then
varAtts = objRef.GetAttributes
Set objAtt = varAtts(0)
objAtt.TextString = "CHANGED THIS TEXT"

End If
End If

End Sub


Ladimir Abdala
CAD Systems Analyst
0 Likes
Message 4 of 4

Anonymous
Not applicable
fwiw, from what the experts say...

If objEnt.ObjectName = "AcDbBlockReference" Then

is slightly better written as;

If TypeOf objEnt Is AcadBlockReference Then


wrote in message news:5783418@discussion.autodesk.com...
Thank you.

I found this code that function very well.
And I want share with others:

Option Explicit
Sub chngAtt()
Dim objEnt As ACADObject
Dim objRef As AcadBlockReference
Dim varAtts As Variant
Dim objAtt As AcadAttributeReference
Dim emptyPt As Variant''

ThisDrawing.Utility.GetEntity objEnt, emptyPt, "Select block...: "
If objEnt.ObjectName = "AcDbBlockReference" Then
Set objRef = objEnt
If objRef.HasAttributes Then
varAtts = objRef.GetAttributes
Set objAtt = varAtts(0)
objAtt.TextString = "CHANGED THIS TEXT"

End If
End If

End Sub


Ladimir Abdala
CAD Systems Analyst
0 Likes