To make the attributes update their alignment
correctly, the WorkingDatabase property of the
HostApplicationServices object must be set to
the database that contains the attribute.
e.g.
AttributeReference att = // ...
Database current = HostApplicationServices.WorkingDatabase;
HostApplicationServices.WorkingDatabase = att.Database;
try
{
// modify text or attribute here
}
finally
{
HostApplicationServices.WorkingDatabase = current;
}
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
wrote in message news:5558899@discussion.autodesk.com...
It's not in the active document.
Example:
Public Shared Sub SetAttributeData(ByVal blkRef As BlockReference, fileName as string)
Dim Trans As Transaction = Nothing
dim db as New Database
db.ReadDwgFile(fileName, IO.FileShare.ReadWrite, False, Nothing)
Try
Trans = db.TransactionManager.StartTransaction
For Each oid As ObjectId In blkRef.AttributeCollection
Dim att As AttributeReference = Trans.GetObject(oid, OpenMode.ForWrite)
If string.compare(att.Tag, "test", true) = 0 Then
att.TextString = "test"
exit for
End If
att.Dispose()
Next
Trans.Commit()
db.Saveas(fileName)
Catch ex As Exception
If Not Trans Is Nothing Then
Trans.Abort()
End If
Finally
If Not Trans Is Nothing AndAlso Not Trans.IsDisposed Then
Trans.Dispose()
End If
End Try
End Sub