Valued Contributor
Posts: 70
Registered: ‎02-17-2005
Message 1 of 4 (354 Views)
Accepted Solution

XData problem

354 Views, 3 Replies
12-10-2011 03:05 AM

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.ScaleFactors = New Scale3d(Scale, Scale, 1)
      blk.Rotation = 0
      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
   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
         Dim ratr As New RegAppTableRecord()
         ratr.Name = regAppName
         tr.AddNewlyCreatedDBObject(ratr, True)
      End If
   End Sub

 I get the following error:- eInvalidInput

at the line blk.Xdata = rb

*Expert Elite*
Posts: 8,887
Registered: ‎06-29-2007
Message 2 of 4 (353 Views)

Re: XData problem

12-10-2011 03:15 AM in reply to: stuartnathan



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 -

Ingenieur Studio HOLLAUS ... www.hollaus.at
*Expert Elite*
Posts: 5,102
Registered: ‎10-12-2006
Message 3 of 4 (297 Views)

Re: XData problem

12-12-2011 08:00 AM 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.
Adopt. Adapt. Overcome. Or be overcome.
A good question will be halfway to a good answer.

Valued Contributor
Posts: 70
Registered: ‎02-17-2005
Message 4 of 4 (289 Views)

Re: XData problem

12-12-2011 09:37 AM in reply to: dgorsman

:smileysurprised:Only way to fly!

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community