>> Dim iter As IEnumerator = bRecord.GetEnumerator
>> iter.Reset()
>> Dim i As Integer = 0
>> While iter.MoveNext
>> Dim id As ObjectId = iter.Current
>> Dim ent As Entity = CType(trans.GetObject(id,......
Fatty, does the VB 'For Each' statement also
not work for you?
Dim id As ObjectId
For Each id in bRecord
' use id here
Next
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
wrote in message news:5624488@discussion.autodesk.com...
Do not mix Attributes with AttributeDefinitions
See how it will works for you,
tested on A2007 only
You can covert the code with help
of this page:
http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx
~'J'~
---------------------------------------------------
Imports System
Imports System.IO
Imports System.Reflection
Imports System.Collections.Generic
Imports System.Data
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Namespace BlockUtils
Public Class AttDefUtils
_
Public Sub GetAttDefs()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Using db As Database = HostApplicationServices.WorkingDatabase()
Using trans As Transaction = db.TransactionManager.StartTransaction()
Try
Dim bTable As BlockTable = CType(trans.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
Dim bRecord As BlockTableRecord = CType(trans.GetObject(bTable("*MODEL_SPACE"), OpenMode.ForWrite), BlockTableRecord)
Dim iter As IEnumerator = bRecord.GetEnumerator
iter.Reset()
Dim i As Integer = 0
While iter.MoveNext
Dim id As ObjectId = iter.Current
Dim ent As Entity = CType(trans.GetObject(id, OpenMode.ForWrite), Entity)
If (TypeOf ent Is AttributeDefinition) Then
Dim atdef As AttributeDefinition = CType(trans.GetObject(ent.ObjectId, OpenMode.ForWrite), AttributeDefinition)
If atdef.Tag.ToUpper = "MYTAG" Then
atdef.UpgradeOpen()
If atdef.IsWriteEnabled = True Then
atdef.TextString = "MyNewValueForAttributeDefinition"
i += 1
End If
ent.Dispose()
End If
End If
End While
MsgBox(String.Format("Changed AttributeDefinition(s): {0}", i))
trans.Commit()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
MsgBox(ex.StackTrace)
Finally
trans.Dispose()
End Try
End Using
End Using
End Sub
End Class
End Namespace