# UserDictionary

**URL:** <https://discourse.mcneel.com/t/userdictionary/7456>\
**Category:** Rhino Developer\
**Created:** [April 11, 2014, 12:30pm UTC](https://discourse.mcneel.com/t/userdictionary/7456 "2014-04-11T12:30:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![karol\_wierzbicki](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/karol_wierzbicki/32/164716_2.png) [@karol\_wierzbicki](https://discourse.mcneel.com/u/karol_wierzbicki)\
**Post date:** [April 11, 2014, 12:30pm UTC](https://discourse.mcneel.com/t/userdictionary/7456/1 "2014-04-11T12:30:11Z")

</div>

Hi,

I have some problems with using user dictionary, I was searching for possible causes all over the forum, but without success.  
I think, that problem might be related with this one:

> [@\[RhinoCommon\] File3dmObject UserDictionary content not available in RhinoDoc](http://discourse.mcneel.com/t/rhinocommon-file3dmobject-userdictionary-content-not-available-in-rhinodoc/5703):
>
> When I write a File3dm that has geometry in it with content in its UserDictionary, this content is not available when that file is subsequently opened in Rhino. To reproduce follow the following two steps: draw a plane or other surface run the first command as below. This will save test.3dm on your desktop open the written test.3dm file run the second command on the geometry in the opened file. It will show the user dictionary to be empty. Please let me know if this is by design (I suspect i…

And the problem is, that I can’t write surface with user dictionary, this is the code:

public Result Build1stOrderQuadAsSurfaces(List gcoords, MyGelmnt1 element, MyGelref1 gelref1, RhinoDoc doc)  
{  
var defaultAttr = new ObjectAttributes();  
defaultAttr.ObjectColor = Color.Green;  
defaultAttr.ColorSource = ObjectColorSource.ColorFromObject;

```
        Point3dList point3dList = new Point3dList();

        point3dList.Insert(0, P3d(gcoords, element.Nodin[0]));
        point3dList.Insert(1, P3d(gcoords, element.Nodin[1]));
        point3dList.Insert(2, P3d(gcoords, element.Nodin[3]));
        point3dList.Insert(3, P3d(gcoords, element.Nodin[2]));

        int count = (int)Math.Sqrt(point3dList.Count);

        var srf = NurbsSurface.CreateFromPoints(point3dList, count, count, 1, 1);

        srf.UserDictionary.Set("Elno", gelref1.Elno.ToString());
        srf.UserDictionary.Set("Matno", gelref1.Matno.ToString());
        srf.UserDictionary.Set("Addno", gelref1.Addno.ToString());
        srf.UserDictionary.Set("Intno", gelref1.Intno.ToString());
        srf.UserDictionary.Set("Mintno", gelref1.Mintno.ToString());
        srf.UserDictionary.Set("Strano", gelref1.Strano.ToString());
        srf.UserDictionary.Set("Streno", gelref1.Streno.ToString());
        srf.UserDictionary.Set("Strepono", 0);
        srf.UserDictionary.Set("GeonoOpt", gelref1.GeonoOpt.ToString());
        srf.UserDictionary.Set("FixnoOpt", gelref1.FixnoOpt.ToString());
        srf.UserDictionary.Set("EccnoOpt", gelref1.EccnoOpt.ToString());
        srf.UserDictionary.Set("TransnoOpt", gelref1.TransnoOpt.ToString());

        if (doc.Objects.AddSurface(srf, defaultAttr) != Guid.Empty)
        {
            return Result.Success;
        }

        return Result.Failure;
    }

```

This part, doesn’t show any properties applied to surface:

```
    protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
    {
        Rhino.DocObjects.ObjRef objref;
        var rc = Rhino.Input.RhinoGet.GetOneObject("Select Face", false, Rhino.DocObjects.ObjectType.Surface, out objref);
        if (rc != Rhino.Commands.Result.Success)
            return rc;

        GeometryBase srf = objref.Surface();

        if (srf.UserDictionary.ContainsKey("Elno"))
        {
            RhinoApp.WriteLine("{0} = {1}", "Element number ", srf.UserDictionary["Elno"].ToString());
        }

        return Rhino.Commands.Result.Success;
    }

```

can you please help?

---

<div class="post-metadata">

**Author:** ![menno](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/menno/32/770384_2.png) [@menno](https://discourse.mcneel.com/u/menno)\
**Post date:** [April 11, 2014, 2:16pm UTC](https://discourse.mcneel.com/t/userdictionary/7456/2 "2014-04-11T14:16:25Z")

</div>

I think the problem is that you add the information to the NurbsSurface object. When you select the face, you get a BrepFace back. What you should do is add the surface to the document as a Brep and set the values on the Brep’s UserDictionary.

```cs
NurbsSurface srf = NurbsSurface.CreateFromPoints(point3dList, count, count, 1,1);
Brep b = srf.ToBrep();
b.SetUserDictionary("Elno", gelref1.Elno.ToString());
// and all the other properties
doc.Objects.AddBrep(b);

```

Followed by

```cs
ObjRef objRef;
var rc = Rhino.Input.RhinoGet.GetOneObject("Select Face", false, Rhino.DocObjects.ObjectType.Brep, out objref);
        if (rc != Rhino.Commands.Result.Success)
            return rc;
Brep b = objRef.Brep();
if (b.UserDictionary.ContainsKey("Elno"))
{
    RhinoApp.WriteLine("{0} = {1}", "Element number ", srf.UserDictionary["Elno"].ToString());
}

```
