Hi MC,
"Active" is from a helper class I got
here somewhere but the link eludes me:
''' <summary>
''' Provides easy access to several "active" objects in the AutoCAD
''' runtime environment.
''' </summary>
Public NotInheritable Class Active
Private Sub New()
End Sub
''' <summary>
''' Returns the active Editor object.
''' </summary>
Public Shared ReadOnly Property Editor() As Editor
Get
Return Document.Editor
End Get
End Property
''' <summary>
''' Returns the active Document object.
''' </summary>
Public Shared ReadOnly Property Document() As Document
Get
Return Application.DocumentManager.MdiActiveDocument
End Get
End Property
''' <summary>
''' Returns the active Database object.
''' </summary>
Public Shared ReadOnly Property Database() As Database
Get
Return Document.Database
End Get
End Property
''' <summary>
''' Sends a string to the command line in the active Editor
''' </summary>
''' <param name="message">The message to send.</param>
Public Shared Sub WriteMessage(message As String)
Editor.WriteMessage(message)
End Sub
''' <summary>
''' Sends a string to the command line in the active Editor using String.Format.
''' </summary>
''' <param name="message">The message containing format specifications.</param>
''' <param name="parameter">The variables to substitute into the format string.</param>
Public Shared Sub WriteMessage(message As String, ParamArray parameter As Object())
Editor.WriteMessage(message, parameter)
End Sub
End Class
blkDB is (a wblocked version of) the block I'm looking for; hence I only need to insert it into the currentDb:
Dim btrId As ObjectId = Active.Database.Insert(tmpblkref.Name, blkDb, True)
Redefining the block is great, but how would I keep the existing attributereference.textstring information in the current version of the blockreference?
Is it a case of doing the redefine as you said and then iterating through the attributecollection(s) of both old/new blockreferences, finding the matching attributedefinition.tag values (since they haven't changed!) and transferring the attributereference.textstring value from old to new?
or am I overthinking what needs to be done?