<?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: Extension Dictionary added Xrecord not showing (C#) in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571418#M10856</link>
    <description>&lt;P&gt;Thanks for the response!&lt;/P&gt;&lt;P&gt;But I can access the 'Notes' data through the same DBDictionary API and read/write the value.&lt;/P&gt;&lt;P&gt;Is the customization only limited to the built-in 'Notes' parameter? We can't add more and show on the same tab?&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Autodesk.Aec.DatabaseServices.TextNote txt = new Autodesk.Aec.DatabaseServices.TextNote();
                                        txt.Note = pipe_1.HandleStr + "," + pipe_2.HandleStr + ",#" + tagNumber;
                                        acLdr.CreateExtensionDictionary();
                                        DBDictionary extDict = (DBDictionary)ts.GetObject(acLdr.ExtensionDictionary, OpenMode.ForWrite, false);
                                        extDict.SetAt(Autodesk.Aec.DatabaseServices.TextNote.ExtensionDictionaryName, txt);
                                        ts.AddNewlyCreatedDBObject(txt, true);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Nov 2022 21:31:17 GMT</pubDate>
    <dc:creator>Soojung_Kim</dc:creator>
    <dc:date>2022-11-22T21:31:17Z</dc:date>
    <item>
      <title>Extension Dictionary added Xrecord not showing (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571234#M10853</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to add a custom data to an entity and used the following code.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public void Test()
        {

            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            var ed = doc.Editor;

            Database db = doc.Database;

            using (Transaction ts = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
            {

                try
                {
                    ObjectId ldr = AutocadAPIs.GetSelectedObjectSingle();

                    MLeader acLdr = ts.GetObject(ldr, OpenMode.ForWrite) as MLeader;

                    DBDictionary extDict = (DBDictionary)ts.GetObject(acLdr.ExtensionDictionary, OpenMode.ForWrite, false);

                    extDict.UpgradeOpen();
                    Xrecord xRec = new Xrecord();
                    ResultBuffer rb = new ResultBuffer();
                    rb.Add(new TypedValue((int)DxfCode.ExtendedDataAsciiString, "test description"));
                    //rb.Add(new TypedValue((int)DxfCode.ExtendedDataReal,10.2));
                    //set the data
                    xRec.Data = rb;
                    extDict.SetAt("Tag Description", xRec);
                    ts.AddNewlyCreatedDBObject(xRec, true);

                }
                catch (Exception e)
                {
                    ed.WriteMessage(e.Message);
                }
                finally
                {

                    ts.Commit();


                }
            }


        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can see the data being added but I don't see the data in the drawing.&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="SoojungKim_1-1669148272332.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1143103iC7FC23795709FD71/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SoojungKim_1-1669148272332.png" alt="SoojungKim_1-1669148272332.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No 'Tag Description' showing.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SoojungKim_2-1669148319484.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1143104iE65D411D3717AE39/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SoojungKim_2-1669148319484.png" alt="SoojungKim_2-1669148319484.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure what I'm doing wrong here. Can anyone give an advice?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 20:20:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571234#M10853</guid>
      <dc:creator>Soojung_Kim</dc:creator>
      <dc:date>2022-11-22T20:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Extension Dictionary added Xrecord not showing (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571386#M10854</link>
      <description>&lt;P&gt;"Extended Data" tab of the Properties window is used by AutoCAD verticals (C3D, Arch, MEP...) to show PropertySet data, not entity's ExtenssionDictionary data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 21:17:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571386#M10854</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2022-11-22T21:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Extension Dictionary added Xrecord not showing (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571400#M10855</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dictionary objects cannot contain drawing entities so they are not displayed on the 'drawing'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;XRecords are added and retrieved via code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Perhaps look at responses from&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&amp;nbsp;here&lt;BR /&gt;&lt;A href="https://forums.autodesk.com/t5/net/class-to-handle-xdictionary-xrecords/m-p/8204596#M60045" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/net/class-to-handle-xdictionary-xrecords/m-p/8204596#M60045&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;added:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Oops, I may have misunderstood the problem.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 21:27:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571400#M10855</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2022-11-22T21:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Extension Dictionary added Xrecord not showing (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571418#M10856</link>
      <description>&lt;P&gt;Thanks for the response!&lt;/P&gt;&lt;P&gt;But I can access the 'Notes' data through the same DBDictionary API and read/write the value.&lt;/P&gt;&lt;P&gt;Is the customization only limited to the built-in 'Notes' parameter? We can't add more and show on the same tab?&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Autodesk.Aec.DatabaseServices.TextNote txt = new Autodesk.Aec.DatabaseServices.TextNote();
                                        txt.Note = pipe_1.HandleStr + "," + pipe_2.HandleStr + ",#" + tagNumber;
                                        acLdr.CreateExtensionDictionary();
                                        DBDictionary extDict = (DBDictionary)ts.GetObject(acLdr.ExtensionDictionary, OpenMode.ForWrite, false);
                                        extDict.SetAt(Autodesk.Aec.DatabaseServices.TextNote.ExtensionDictionaryName, txt);
                                        ts.AddNewlyCreatedDBObject(txt, true);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 21:31:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571418#M10856</guid>
      <dc:creator>Soojung_Kim</dc:creator>
      <dc:date>2022-11-22T21:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Extension Dictionary added Xrecord not showing (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571419#M10857</link>
      <description>Thank you, I've seen that post and followed snippet of the code to add the data. But as you said the data is there but not displayed. If that's the limitation, I'll have to look for a workaround. Thanks!</description>
      <pubDate>Tue, 22 Nov 2022 21:32:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571419#M10857</guid>
      <dc:creator>Soojung_Kim</dc:creator>
      <dc:date>2022-11-22T21:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Extension Dictionary added Xrecord not showing (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571470#M10858</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;It looks like you're confusing xdata (extended data) and xrecord.&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;Maybe I misunderstood the question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        [CommandMethod("TESTXDATA")]
        public static void TestXdata()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            var per = ed.GetEntity("\nSelect object: ");
            if (per.Status != PromptStatus.OK) 
                return;

            using (var tr = db.TransactionManager.StartTransaction())
            {
                var entity = (Entity)tr.GetObject(per.ObjectId, OpenMode.ForWrite);

                // Check if the RegAppTable contains the application name
                string appName = "TestAppName";
                var regAppTable = (RegAppTable)tr.GetObject(db.RegAppTableId, OpenMode.ForRead);
                // Register the application Name
                if (!regAppTable.Has(appName))
                {
                    var regApp = new RegAppTableRecord();
                    regApp.Name = appName;
                    regAppTable.UpgradeOpen();
                    regAppTable.Add(regApp);
                    tr.AddNewlyCreatedDBObject(regApp, true);
                }

                // add the extended data to the entity
                // (typed values with specific extended dat Dxf codes)
                var data = new ResultBuffer(
                    new TypedValue(1001, appName),
                    new TypedValue(1000, "Extended data"),
                    new TypedValue(1040, 25.4));
                entity.XData = data;
                tr.Commit();
            }
        }

        [CommandMethod("TESTXRECORD")]
        public static void Test()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            var per = ed.GetEntity("\nSelect object: ");
            if (per.Status != PromptStatus.OK)
                return;

            using (var tr = db.TransactionManager.StartTransaction())
            {
                var entity = (Entity)tr.GetObject(per.ObjectId, OpenMode.ForWrite);

                // Create the extension dictionary of the entity
                // if it did not already have one
                if (entity.ExtensionDictionary == ObjectId.Null)
                {
                    if (!entity.IsWriteEnabled)
                        tr.GetObject(entity.ObjectId, OpenMode.ForWrite);
                    entity.CreateExtensionDictionary();
                }
                var xdict = (DBDictionary)tr.GetObject(entity.ExtensionDictionary, OpenMode.ForRead);

                // Add a new Xrecord with the key 
                // if the extension dictionary did not already have one
                string key = "XrecordKey";
                Xrecord xrec;
                if (xdict.Contains(key))
                {
                    xrec = (Xrecord)tr.GetObject((ObjectId)xdict[key], OpenMode.ForWrite);
                }
                else
                {
                    tr.GetObject(xdict.ObjectId, OpenMode.ForWrite);
                    xrec = new Xrecord();
                    xdict.SetAt(key, xrec);
                    tr.AddNewlyCreatedDBObject(xrec, true);
                }

                // add the data to the Xrecord
                // (typed values with standard Dxf codes)
                var data = new ResultBuffer(
                    new TypedValue(1, "Xrecord data"),
                    new TypedValue(40, 25.4));
                xrec.Data = data;
                tr.Commit();
            }
        }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 22:08:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571470#M10858</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-11-22T22:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: Extension Dictionary added Xrecord not showing (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571585#M10859</link>
      <description>Thank you so much for providing the codes. I've tried both methods and both run without any error but I still don't see the data from the Extended Data tab. Am I supposed to see the added data there or is that something we can't do?</description>
      <pubDate>Tue, 22 Nov 2022 22:49:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11571585#M10859</guid>
      <dc:creator>Soojung_Kim</dc:creator>
      <dc:date>2022-11-22T22:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Extension Dictionary added Xrecord not showing (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11572182#M10860</link>
      <description>&lt;P&gt;Look at &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt; 's &lt;A href="https://forums.autodesk.com/t5/net/extension-dictionary-added-xrecord-not-showing-c/m-p/11571386/highlight/true#M74914" target="_blank" rel="noopener"&gt;reply&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;The data you want to add seems to be specific to AutoCAD verticals products, neither 'vanilla' xdata nor xrecord.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 07:22:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11572182#M10860</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-11-23T07:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: Extension Dictionary added Xrecord not showing (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11573653#M10861</link>
      <description>&lt;P&gt;Okay, so it won't work on vertical products. + Or I'll have to look into a way to add property sets, not xrecord or xdata.&lt;/P&gt;&lt;P&gt;I'll find a workaround then. Thanks for the help!!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 17:12:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11573653#M10861</guid>
      <dc:creator>Soojung_Kim</dc:creator>
      <dc:date>2022-11-23T17:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Extension Dictionary added Xrecord not showing (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11576108#M10862</link>
      <description>&lt;P&gt;Well, I do not use Acad Arch, thus have no idea what "TextNote" object is in Acad arch. But if you want to attach some data to regular AutoCAD entities (in your case, MLeader, does not matter here) and want the data can be seen in Properties window's "Extended Data" tab, you simply use PropertyData: add reference to "AecPropDataMgd.dll",&amp;nbsp; and have a brief study on "Autodesk.Aec.PropertyData/DatabaseServices" namespace, you can easily go ahead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 16:52:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extension-dictionary-added-xrecord-not-showing-c/m-p/11576108#M10862</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2022-11-24T16:52:45Z</dc:date>
    </item>
  </channel>
</rss>

