<?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: How to Create an instance of ResultBuffer. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11746042#M10034</link>
    <description>&lt;P&gt;Sorry I can't help you. The code you posted is incomprehensible.&lt;BR /&gt;Where does this JsonItems type come from?&lt;BR /&gt;You create an empty list (aroomrule), then an IEnumerable&amp;lt;roomrule&amp;gt; (rmrulelst) by applying the Dinstinct method to the empty list, what do you expect to happen?&lt;BR /&gt;You then launch a foreach on this sequence, what do you expect to happen?&lt;/P&gt;
&lt;P&gt;Please, if you want to get help, try to make an effort on your side not to post inconsistent code.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Feb 2023 17:29:03 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2023-02-10T17:29:03Z</dc:date>
    <item>
      <title>How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11745296#M10031</link>
      <description>&lt;P&gt;Hello, everyone. Now I am making a small project .NET. There I should embed a JSON data into DWG file.&lt;/P&gt;&lt;P&gt;I thought it maybe possible to use&amp;nbsp;Xrecord. Followings are my portion of code.&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public class roomrule
{
        public Polyline pl;
        public double width;
        public double height;
        public ObjectId objid;
        public Handle hnd;
}
public void WriteToNOD()
{
	List&amp;lt;JsonItems&amp;gt; jsonlists = new List&amp;lt;JsonItems&amp;gt;();
	public static List&amp;lt;roomrule&amp;gt; aroomrule = new List&amp;lt;roomrule&amp;gt;();
	IEnumerable&amp;lt;roomrule&amp;gt; rmrulelst = aroomrule.Distinct();
	//I added some data to aroomrule already.
	foreach (roomrule wrule in rmrulelst)
        {
                jsonlists.Add(new JsonItems
                {
                    layer = "_Room",
                    OId = wrule.objid.ToString(),
                    width = wrule.width,
                    height = wrule.height,
                    hndle = wrule.hnd.ToString(),
                    projtype = (int)Plugin.projtypestate,
                });
         }
            try
            {
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {                    
                    DBDictionary nod = (DBDictionary)trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite);
                    Xrecord myXrecord = new Xrecord();
                    ResultBuffer resbuf = new ResultBuffer(new TypedValue((int)DxfCode.Text, jsonlists[0].layer), new TypedValue((int)DxfCode.Int64, jsonlists[0].OId),
                    new TypedValue((int)DxfCode.Int64, jsonlists[0].OId), new TypedValue((int)DxfCode.Int32,jsonlists[0].height),
                    new TypedValue((int)DxfCode.Int64,jsonlists[0].hndle),new TypedValue((int)DxfCode.Int32,jsonlists[0].projtype));
                    foreach(TypedValue tv in resbuf)
                    {
                        Application.ShowAlertDialog(
                                  "===== Now write: " + tv.TypeCode.ToString()
                                  + ". " + tv.Value.ToString());
                    }
                    myXrecord.Data = resbuf;
                    nod.SetAt("PrevalData", myXrecord);
                    trans.AddNewlyCreatedDBObject(myXrecord, true);                    
                    trans.Commit();
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Print(e.ToString());
            }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 10 Feb 2023 13:24:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11745296#M10031</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2023-02-10T13:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11745718#M10032</link>
      <description>&lt;P&gt;What is your question ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note it is a better practice to get or create your own dictionary(ies) in the NOD and add the xrecords to this dictionary then to directly add xrecords to the NOD.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 15:55:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11745718#M10032</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-02-10T15:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11745933#M10033</link>
      <description>&lt;P&gt;Thanks _gile. You were kindly helping me.&amp;nbsp;Can you tell me specifically how to implement it? Thank you again.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 16:51:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11745933#M10033</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2023-02-10T16:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11746042#M10034</link>
      <description>&lt;P&gt;Sorry I can't help you. The code you posted is incomprehensible.&lt;BR /&gt;Where does this JsonItems type come from?&lt;BR /&gt;You create an empty list (aroomrule), then an IEnumerable&amp;lt;roomrule&amp;gt; (rmrulelst) by applying the Dinstinct method to the empty list, what do you expect to happen?&lt;BR /&gt;You then launch a foreach on this sequence, what do you expect to happen?&lt;/P&gt;
&lt;P&gt;Please, if you want to get help, try to make an effort on your side not to post inconsistent code.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 17:29:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11746042#M10034</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-02-10T17:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11747065#M10035</link>
      <description>&lt;P&gt;Hi, _gile.&amp;nbsp;It is difficult to describe the process of putting values in all lists here, so I omitted that part.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public class windowrule
    {
        public Polyline pl;
        public float width;
        public float height;
        public ObjectId objid;
        public Handle hnd;
    }

ResultBuffer resbuf = new ResultBuffer(new TypedValue((int)DxfCode.Text, jsonlists[0].layer), new TypedValue((int)DxfCode.Int64, jsonlists[0].OId),
                    new TypedValue((int)DxfCode.Int64, jsonlists[0].OId), new TypedValue((int)DxfCode.Int32,jsonlists[0].height),
                    new TypedValue((int)DxfCode.Int64,jsonlists[0].hndle),new TypedValue((int)DxfCode.Int32,jsonlists[0].projtype));
                  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I put an instance of this class(windowrule) into DBDictionary. In my previously posted code I get the values of&amp;nbsp;jsonlists, but in the line of creating resbuf my function returns. I want example code for you. Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2023 05:33:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11747065#M10035</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2023-02-11T05:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11747149#M10036</link>
      <description>&lt;P&gt;Some remarks&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The 'roomrule' or 'windowrule' class should not have a Polyline field because you should never use DBObjects outside of the scope of the transaction use to get or create them. Use their ObjectId or Handle instead.&lt;/LI&gt;
&lt;LI&gt;You should choose between ObjectId or Handle because you can get one from the other. Keep in mind that an ObjectId is unique per session and non persistent; a handle is unique per drawing and persistent between sessions (see &lt;A href="https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-8D56532D-2B17-48D1-8C81-B4AD89603A1C" target="_blank" rel="noopener"&gt;this topic&lt;/A&gt;)&lt;/LI&gt;
&lt;LI&gt;If you need to store more than one "JsonItems" in the NOD, you must have some key per item to be able differentiate the Xrecords.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Sat, 11 Feb 2023 07:41:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11747149#M10036</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-02-11T07:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11747174#M10037</link>
      <description>&lt;P&gt;Here is an example of how to structure this process. &lt;BR /&gt;Do not simply copy/paste this code. Try to understand how it works a rewrite it to suit your needs instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A RoomRule structure&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;    public struct RoomRule
    {
        public double Width { get; set; }
        public double Height { get; set; }
        public ObjectId ObjectId { get; set; }
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A JsonItem class&lt;/P&gt;
&lt;P&gt;EDIT: added a WriteToNod and CreateFromNod methods.&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;    public class JsonItem
    {
        // properties
        public string Layer { get; set; }
        public double Width { get; set; }
        public double Height { get; set; }
        public string Handle { get; set; }
        public int ProjType { get; set; }

        // constructors
        public JsonItem(RoomRule roomRule)
        {
            Layer = "_Room";
            Width = roomRule.Width;
            Height = roomRule.Height;
            Handle = roomRule.ObjectId.Handle.ToString();
            ProjType = Plugin.projtypestate;
        }

        public JsonItem(ResultBuffer resbuf)
        {
            if (resbuf != null)
            {
                var data = resbuf.AsArray();
                if (data.Length == 5)
                {
                    if (long.TryParse(
                        data[3].Value.ToString(),
                        System.Globalization.NumberStyles.HexNumber,
                        System.Globalization.CultureInfo.InvariantCulture,
                        out long longHandle))
                    {
                        var db = HostApplicationServices.WorkingDatabase;
                        var handle = new Handle(longHandle);
                        if (db.TryGetObjectId(new Handle(longHandle), out ObjectId id))
                        {
                            Layer = (string)data[0].Value;
                            Width = (double)data[1].Value;
                            Height = (double)data[2].Value;
                            Handle = handle.ToString();
                            ProjType = Convert.ToInt32(data[4].Value);
                        }
                    }
                }
            }
        }

        public ResultBuffer ToResultBuffer()
        {
            return new ResultBuffer(
                new TypedValue(1, Layer),
                new TypedValue(40, Width),
                new TypedValue(40, Height),
                new TypedValue(5, Handle),
                new TypedValue(71, ProjType));
        }

        public void WriteToNod(string key)
        {
            var db = HostApplicationServices.WorkingDatabase;
            using (var tr = db.TransactionManager.StartTransaction())
            {
                var Nod = (DBDictionary)tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead);

                // Get or create the GOLDHORSE dictionary
                DBDictionary goldhorseDict;
                if (Nod.Contains("GOLDHORSE"))
                {
                    goldhorseDict = (DBDictionary)tr.GetObject(Nod.GetAt("GOLDHORSE"), OpenMode.ForRead);
                }
                else
                {
                    tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite);
                    goldhorseDict = new DBDictionary();
                    Nod.SetAt("GOLDHORSE", goldhorseDict);
                    tr.AddNewlyCreatedDBObject(goldhorseDict, true);
                }

                // Get or create an Xrecord in GOLDHORSE dictionary with the supplied key
                Xrecord xrec;
                if (goldhorseDict.Contains(key))
                {
                    xrec = (Xrecord)tr.GetObject(goldhorseDict.GetAt(key), OpenMode.ForWrite);
                }
                else
                {
                    tr.GetObject(Nod.GetAt("GOLDHORSE"), OpenMode.ForWrite);
                    xrec = new Xrecord();
                    goldhorseDict.SetAt(key, xrec);
                    tr.AddNewlyCreatedDBObject(xrec, true);
                }

                // Set the xrecord data
                xrec.Data = ToResultBuffer();
                tr.Commit();
            }
        }

        public static JsonItem CreateFromNod(string key)
        {
            var db = HostApplicationServices.WorkingDatabase;
            using (var tr = db.TransactionManager.StartTransaction())
            {
                var Nod = (DBDictionary)tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead);

                // Get the GOLDHORSE dictionary
                if (!Nod.Contains("GOLDHORSE"))
                    return null;
                var goldhorseDict = (DBDictionary)tr.GetObject(Nod.GetAt("GOLDHORSE"), OpenMode.ForRead);

                // Get the Xrecord in GOLDHORSE dictionary with the supplied key
                if (!goldhorseDict.Contains(key))
                    return null;
                var xrec = (Xrecord)tr.GetObject(goldhorseDict.GetAt(key), OpenMode.ForRead);

                // Get the xrecord data
                var data = xrec.Data;
                if (data == null) 
                    return null;

                return new JsonItem(data);
            }
        }
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2023 12:46:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11747174#M10037</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-02-11T12:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11747183#M10038</link>
      <description>&lt;P&gt;Yes, in fact I use this class to add ResultBuffer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public class JsonItems
    {
        public string layer { get; set; }
        public string OId { get; set; }
        public double width { get; set; }
        public double height { get; set; }
        public string hndle { get; set; }
        public int projtype { get; set; }
    }&lt;/LI-CODE&gt;&lt;P&gt;In my opinion first parameter was mistake in this code.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;new TypedValue((int)DxfCode.Text, jsonlists[0].layer)&lt;/LI-CODE&gt;&lt;P&gt;This code works.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;myXrecord.Data = new ResultBuffer(
              new TypedValue((int)DxfCode.Int16, 1234),
              new TypedValue((int)DxfCode.Text,
                              "This drawing has been processed"));&lt;/LI-CODE&gt;&lt;P&gt;What is the main cause? I think you know why.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2023 08:23:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11747183#M10038</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2023-02-11T08:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11747259#M10039</link>
      <description>&lt;P&gt;Again it is impossible for me to diagnose with the informations you provide which are both incomplete and confusing.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2023 09:34:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11747259#M10039</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-02-11T09:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11747334#M10040</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12396114"&gt;@MarkJamesRogolino&lt;/a&gt;&amp;nbsp; a écrit&amp;nbsp;:&lt;BR /&gt;
&lt;P&gt;In my opinion first parameter was mistake in this code.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;new TypedValue((int)DxfCode.Text, jsonlists[0].layer)&lt;/LI-CODE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why do say that ?&lt;/P&gt;
&lt;P&gt;The reasons why this line of would not work are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;'jsonlists' is null or empty&lt;/LI&gt;
&lt;LI&gt;'jasonlists[0].layer' is null or empty&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Sat, 11 Feb 2023 11:02:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11747334#M10040</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-02-11T11:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11749942#M10041</link>
      <description>&lt;P&gt;Hi, _gile. have a good weekend?&lt;/P&gt;&lt;P&gt;Thanks for your help.&amp;nbsp; But some code does not work.&lt;/P&gt;&lt;P&gt;As you can see in my picture already PrevalData DBDictionary exists.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="goldhorsemillion_0-1676291954181.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1175577i807AADF5D5B10CDE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="goldhorsemillion_0-1676291954181.png" alt="goldhorsemillion_0-1676291954181.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But this code does not get DBDictionary.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var nod = (DBDictionary)trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead);
                    DBDictionary prevaldict;
                    if (nod.Contains("PrevalData"))
                    {
                        prevaldict = (DBDictionary)trans.GetObject(nod.GetAt("PrevalData"), OpenMode.ForRead);                        
                    }&lt;/LI-CODE&gt;&lt;P&gt;Can you tell me about this? Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 06:37:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11749942#M10041</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2023-02-13T06:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11749964#M10042</link>
      <description>&lt;P&gt;What is the type of "PrevalData' ? DBDictionary or Xrecord ?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 06:52:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11749964#M10042</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-02-13T06:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11750284#M10043</link>
      <description>&lt;P&gt;Sorry, _gile. my mistake. above code works well. but one more problem.&lt;/P&gt;&lt;P&gt;my source code is as&amp;nbsp; followings.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    var nod = (DBDictionary)trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead);
                    DBDictionary prevaldict;
                    if (nod.Contains("PrevalData"))
                    {
                        prevaldict = (DBDictionary)trans.GetObject(nod.GetAt("PrevalData"), OpenMode.ForRead);                        
                    }
                    else
                    {
                        trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite);
                        prevaldict = new DBDictionary();
                        nod.SetAt("PrevalData", prevaldict);
                        trans.AddNewlyCreatedDBObject(prevaldict, true);
                    }
                    Xrecord myXrecord = new Xrecord();
                    prevaldict.SetAt("JSonData", myXrecord);
                    trans.AddNewlyCreatedDBObject(myXrecord, true);

                    foreach (JsonItems item in jsonlists)
                    {
                        ResultBuffer resbuf = item.ToResultBuffer();
                        myXrecord.Data.Add(resbuf);
                    }

                    ObjectId myDataId = nod.GetAt("PrevalData");
                    Xrecord readBack = (Xrecord)trans.GetObject(
                                                  myDataId, OpenMode.ForRead);
                    foreach (TypedValue value in readBack.Data)
                        Application.ShowAlertDialog("===== OUR DATA: " + value.TypeCode.ToString()
                                  + ". " + value.Value.ToString());
                    trans.Commit();
                }&lt;/LI-CODE&gt;&lt;P&gt;Here jsonlists has 375 values. my code returns when runs "myXrecord.Data.Add(resbuf);" .&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 09:54:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11750284#M10043</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2023-02-13T09:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11750432#M10044</link>
      <description>&lt;P&gt;I do not know what is jsonlists.&lt;/P&gt;
&lt;P&gt;You never clearly explain what you're trying to achieve neither how you want these data to be stored.&lt;/P&gt;
&lt;P&gt;It is very hard to try to help you in this context.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 11:29:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11750432#M10044</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-02-13T11:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11750496#M10045</link>
      <description>&lt;P&gt;Sorry for not clear context. I will explain more in code. The resbuf has correct value runtimely in below code.&lt;/P&gt;&lt;P&gt;But myrecord.Data.Add function does not works.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;foreach (JsonItems item in jsonlists)
                    {
                        ResultBuffer resbuf = item.ToResultBuffer();
                        myXrecord.Data.Add(resbuf);
                    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;public class JsonItems
    {
        public string layer { get; set; }
        public string OId { get; set; }
        public double width { get; set; }
        public double height { get; set; }
        public string hndle { get; set; }
        public int projtype { get; set; }
        public ResultBuffer ToResultBuffer()
        {
            return new ResultBuffer(
                new TypedValue(1, layer),
                new TypedValue(5, OId),
                new TypedValue(40, width),
                new TypedValue(40, height),
                new TypedValue(5, hndle),
                new TypedValue(71, projtype));
        }
    }
List&amp;lt;JsonItems&amp;gt; jsonlists = new List&amp;lt;JsonItems&amp;gt;();
// I did not describe the function adds jsonlists value. But jsonlists has value really.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 12:17:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11750496#M10045</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2023-02-13T12:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an instance of ResultBuffer.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11750599#M10046</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12396114"&gt;@MarkJamesRogolino&lt;/a&gt;&amp;nbsp; a écrit&amp;nbsp;:&lt;BR /&gt;
&lt;P&gt;But myrecord.Data.Add function does not works.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;foreach (JsonItems item in jsonlists)
                    {
                        ResultBuffer resbuf = item.ToResultBuffer();
                        myXrecord.Data.Add(resbuf);
                    }&lt;/LI-CODE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The Xrecord.Data type is ResultBuffer and the ResultBuffer.Add method requires a TypedValue as argument not another Resultbuffer.&lt;/P&gt;
&lt;P&gt;The correct syntax would be (as shown upper):&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;myXrecord.Data = resbuf;&lt;/LI-CODE&gt;
&lt;P&gt;But doing this within your foreach loop&amp;nbsp; should ovewrite the XrecordData at each iteration and the data would be the one of the last item of 'jsonlists'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before writing any line of code, you must clearly define how you want to record this data. Usually, data is stored in a way that it can be easily retrieved. Dictionaries and xrecords are a convenient way to do this as long as you don't put all the data in a single xrecord.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;A dictionary can contain one or more dictionaries and one or more xrecords (like a folder can contain folders and files). Each dictionary and each xrecord is named so that the name serves as a key to access it.&lt;BR /&gt;The data stored in an xrecord can only be differentiated by their index.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Knowing this, you have to choose how to organize the storage of these data in the "PrevalData" dictionary.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;A single xrecord which contains the data of 375 "JsonItems", that is 375 * 6 = 2250 TypedValues.&lt;/LI&gt;
&lt;LI&gt;One xrecord per "JsonItems" (each of the 375 xrecords must be named differently) which contains 6 TypedValues, that is one TypedValue per property of the JsonItems instance.&lt;/LI&gt;
&lt;LI&gt;One dictionary per "JsonItems" (each of the 375 dictionaries must be named differently) which contains one xrecord per property of the "JsonItems". Each xrecord is named like the property and contains only one TypedValue.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 13:07:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-create-an-instance-of-resultbuffer/m-p/11750599#M10046</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-02-13T13:07:13Z</dc:date>
    </item>
  </channel>
</rss>

