Message 1 of 4
Not applicable
12-10-2011
03:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have used Kean Walmsley's article http://through-the-interface.typepad.com/through_the_interface/2007/04/adding_xdata_to.html as a basis for trying to add xdata to a block.
I am trying to add the handle of another object to the block. Here is the code:-
Private Sub Insert(ByVal tr As Transaction, ByVal Name As String, ByVal Path As String, _
ByVal Scale As Integer, ByVal ip As Point3d, ByVal Hwnd As Handle)
Dim btr As BlockTableRecord = CType(tr.GetObject(CurDb.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
Dim BlkId As ObjectId = CreateBlockReference(tr, Name, Path, btr) ' insert blockreference
Dim blk As BlockReference = New BlockReference(ip, BlkId) ' insert block
blk.SetDatabaseDefaults()
blk.ScaleFactors = New Scale3d(Scale, Scale, 1)
blk.Rotation = 0
btr.AppendEntity(blk)
tr.AddNewlyCreatedDBObject(blk, True) ' add it to transaction
AddRegAppTableRecord(tr, "MYXDATA")
Dim values() As TypedValue = {New TypedValue(1001, "MYXDATA"), New TypedValue(DxfCode.Handle, Hwnd)}
Dim rb As New ResultBuffer(values)
blk.XData = rb
rb.Dispose()
End Sub
Private Sub AddRegAppTableRecord(ByVal tr As Transaction, ByVal regAppName As String)
Dim rat As RegAppTable = DirectCast(tr.GetObject(CurDb.RegAppTableId, OpenMode.ForRead, False), RegAppTable)
If Not rat.Has(regAppName) Then
rat.UpgradeOpen()
Dim ratr As New RegAppTableRecord()
ratr.Name = regAppName
rat.Add(ratr)
tr.AddNewlyCreatedDBObject(ratr, True)
End If
End SubI get the following error:- eInvalidInput
at the line blk.Xdata = rb
Solved! Go to Solution.