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 Sub
I get the following error:- eInvalidInput
at the line blk.Xdata = rb
Solved! Go to Solution.
Solved by Alfred.NESWADBA. Go to Solution.
Hi,
first guess:
don't use this: New TypedValue(DxfCode.Handle, Hwnd)
instead try this: New TypedValue(DxfCode.ExtendedDataHandle, Hwnd)
The DxfCode.Handle can only exist once for an object, and that's the object's handle, not a referenced handle from another entity.
HTH, - alfred -
Let me guess - .Handle is DXF code 5, .ExtendedDataHandle is DXF code 1005?
Can't find what you're looking for? Ask the community or share your knowledge.