.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

XData problem

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
stuartnathan
882 Views, 3 Replies

XData problem

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

3 REPLIES 3
Message 2 of 4

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 -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 4
dgorsman
in reply to: Alfred.NESWADBA

Let me guess - .Handle is DXF code 5, .ExtendedDataHandle is DXF code 1005?

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 4 of 4
stuartnathan
in reply to: dgorsman

Smiley SurprisedOnly way to fly!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost