<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why I can not add Xrecord to DBDictionary in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7894723#M26500</link>
    <description>&lt;P&gt;When you updated your code to VS2015, did you change your project's references to the targeted AutoCAD version's assemblies, and did you also update your targeted framework version to the version&amp;nbsp;required by the targeted AutoCAD release?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For AutoCAD 2018, your target framework should be .NET 4.6 and you also need to set the references to AutoCAD 2018 assemblies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymouswrote:&lt;BR /&gt;&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used to think so too, I checked this case.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But it is does not work even I add empty XRecord&lt;/SPAN&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Mar 2018 16:24:31 GMT</pubDate>
    <dc:creator>ActivistInvestor</dc:creator>
    <dc:date>2018-03-29T16:24:31Z</dc:date>
    <item>
      <title>Why I can not add Xrecord to DBDictionary</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7893343#M26496</link>
      <description>&lt;P&gt;I have simple code that creates an entity and extension dictionary for it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This procedure I made with Visual Basic 2010 and used it with AutoCAD 2011. It worked fine. When I tried to update my code with Visual Studio 2015 and use it with AutoCAD 2018 it leads to failure of application.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think that problem occurs when method SatAt is called.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Th&lt;SPAN&gt;ank you in advance !&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        &amp;lt;CommandMethod("Test_Add")&amp;gt; Public Sub Add_XRec()

            '' Get the current document and database, and start a transaction
            Dim acPoly As Polyline
            Dim acDoc As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim acCurDb As Database = acDoc.Database

            Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
                '' Open the Block table record for read
                Dim acBlkTbl As BlockTable
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                   OpenMode.ForRead)

                '' Open the Block table record Model space for write
                Dim acBlkTblRec As BlockTableRecord
                acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace),
                                      OpenMode.ForWrite)

                '' Create a polyline
                acPoly = New Polyline()
                acPoly.AddVertexAt(0, New Point2d(1, 1), 0, 0, 0)
                acPoly.AddVertexAt(1, New Point2d(1, 2), 0, 0, 0)
                'acPoly.Closed = False

                '' Add the new object to the block table record and the transaction
                acBlkTblRec.AppendEntity(acPoly)
                acTrans.AddNewlyCreatedDBObject(acPoly, True)

                Dim exd As DBDictionary
                Dim ent As Entity = CType(acTrans.GetObject(acPoly.ObjectId, OpenMode.ForWrite), Polyline)

                ent.CreateExtensionDictionary()
                exd = acTrans.GetObject(ent.ExtensionDictionary, OpenMode.ForWrite)

                '' Create a ResultBuffer and Xrecord
                Dim xr As New Xrecord()
                Dim buff As New ResultBuffer()

                buff.Add(New TypedValue(DxfCode.ExtendedDataAsciiString, "TEXT_1"))
                buff.Add(New TypedValue(DxfCode.ExtendedDataAsciiString, "TEXT_2"))
                xr.Data = buff

                Try
                    '' Add the new Xrecord to the extension dictionary  and the transaction
                    exd.SetAt("XREC_KEY", xr)
                    acTrans.AddNewlyCreatedDBObject(xr, True)

                Catch ex As System.Exception
                    acDoc.Editor.WriteMessage(vbLf &amp;amp; ex.Message)
                    acTrans.Abort()
                End Try


                '' Save objects to the database
                acTrans.Commit()
            End Using

        End Sub&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Mar 2018 08:47:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7893343#M26496</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-29T08:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why I can not add Xrecord to DBDictionary</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7893487#M26497</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems to me you use a wrong DxfCode.&lt;/P&gt;
&lt;P&gt;DxfCode.ExtendedDataAsciiString (1000) is to be used with extended data, not xrecord.&lt;/P&gt;
&lt;P&gt;Use DxfCode.Text (1) instead.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 09:40:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7893487#M26497</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-03-29T09:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why I can not add Xrecord to DBDictionary</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7893626#M26498</link>
      <description>&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used to think so too, I checked this case.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But it is does not work even I add empty XRecord&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 10:35:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7893626#M26498</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-29T10:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Why I can not add Xrecord to DBDictionary</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7893814#M26499</link>
      <description>&lt;P&gt;This seems to work here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        [CommandMethod("Test_Add")]
        public void Add_XRec()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord modelSpace = (BlockTableRecord)tr.GetObject(
                    SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
                Polyline pline = new Polyline();
                pline.AddVertexAt(0, new Point2d(1.0, 1.0), 0.0, 0.0, 0.0);
                pline.AddVertexAt(1, new Point2d(1.0, 2.0), 0.0, 0.0, 0.0);
                modelSpace.AppendEntity(pline);
                tr.AddNewlyCreatedDBObject(pline, true);

                pline.CreateExtensionDictionary();
                DBDictionary xdict = (DBDictionary)tr.GetObject(pline.ExtensionDictionary, OpenMode.ForWrite);
                Xrecord xrec = new Xrecord();
                ResultBuffer data = new ResultBuffer(
                    new TypedValue((int)DxfCode.Text, "TEXT1"),
                    new TypedValue(1, "TEXT2"));
                xrec.Data = data;
                xdict.SetAt("XREC_KEY", xrec);
                tr.AddNewlyCreatedDBObject(xrec, true);
                tr.Commit();
            }
        }&lt;/PRE&gt;
&lt;P&gt;VB conversion with &lt;A href="http://converter.telerik.com/" target="_blank"&gt;telerik&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;CommandMethod("Test_Add")&amp;gt;
Public Sub Add_XRec()
    Dim doc As Document = Application.DocumentManager.MdiActiveDocument
    Dim db As Database = doc.Database
    Using tr As Transaction = db.TransactionManager.StartTransaction()
        Dim modelSpace As BlockTableRecord = CType(tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite), BlockTableRecord)
        Dim pline As Polyline = New Polyline()
        pline.AddVertexAt(0, New Point2d(1, 1), 0, 0, 0)
        pline.AddVertexAt(1, New Point2d(1, 2), 0, 0, 0)
        modelSpace.AppendEntity(pline)
        tr.AddNewlyCreatedDBObject(pline, True)
        pline.CreateExtensionDictionary()
        Dim xdict As DBDictionary = CType(tr.GetObject(pline.ExtensionDictionary, OpenMode.ForWrite), DBDictionary)
        Dim xrec As Xrecord = New Xrecord()
        Dim data As ResultBuffer = New ResultBuffer(New TypedValue(CInt(DxfCode.Text), "TEXT1"), New TypedValue(1, "TEXT2"))
        xrec.Data = data
        xdict.SetAt("XREC_KEY", xrec)
        tr.AddNewlyCreatedDBObject(xrec, True)
        tr.Commit()
    End Using
End Sub

'=======================================================
'Service provided by Telerik (www.telerik.com)
'Conversion powered by Refactoring Essentials.
'Twitter: @telerik
'Facebook: facebook.com/telerik
'=======================================================&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 11:45:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7893814#M26499</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-03-29T11:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why I can not add Xrecord to DBDictionary</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7894723#M26500</link>
      <description>&lt;P&gt;When you updated your code to VS2015, did you change your project's references to the targeted AutoCAD version's assemblies, and did you also update your targeted framework version to the version&amp;nbsp;required by the targeted AutoCAD release?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For AutoCAD 2018, your target framework should be .NET 4.6 and you also need to set the references to AutoCAD 2018 assemblies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymouswrote:&lt;BR /&gt;&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used to think so too, I checked this case.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But it is does not work even I add empty XRecord&lt;/SPAN&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 16:24:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7894723#M26500</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2018-03-29T16:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Why I can not add Xrecord to DBDictionary</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7900544#M26501</link>
      <description>&lt;P&gt;Yes I do. I start new progect to check how does it work but the resulte is the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="No_Name_1.jpg" style="width: 681px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/483103i8C2BBD92B059D224/image-size/large?v=v2&amp;amp;px=999" role="button" title="No_Name_1.jpg" alt="No_Name_1.jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="No_Name_2.jpg" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/483104i0F85EFB48478360E/image-size/large?v=v2&amp;amp;px=999" role="button" title="No_Name_2.jpg" alt="No_Name_2.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 08:47:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7900544#M26501</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-04-02T08:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why I can not add Xrecord to DBDictionary</title>
      <link>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7900750#M26502</link>
      <description>&lt;P&gt;Post the actual code you say isn't working so someone can verify that it's correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymouswrote:&lt;BR /&gt;&lt;P&gt;Yes I do. I start new progect to check how does it work but the resulte is the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 11:36:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/why-i-can-not-add-xrecord-to-dbdictionary/m-p/7900750#M26502</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2018-04-02T11:36:12Z</dc:date>
    </item>
  </channel>
</rss>

