Rhino3dm User Text

Hi @dale, any update on this issue?

I have hit same problem in my script. Trying to generate some .3dm file within an excel. Everything works fine (geometry, layers, object names, groups) but user strings do not.

I have tried created simple console app to replicate the problem. User string is not written in the .3dm file.

I have also tried to add user strings to File3dmObject directly, via ObjectAttribute class and also to the geometry itself. Everything with the same result.

using System;

using Rhino.DocObjects;
using Rhino.Geometry;

namespace File3dm
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Rhino.FileIO.File3dm file3Dm = new Rhino.FileIO.File3dm();
                Rhino.FileIO.File3dmWriteOptions options = new Rhino.FileIO.File3dmWriteOptions();
                options.Version = 2;

                Plane basePlane = new Plane(new Point3d(0, 0, 0), Vector3d.ZAxis);
                PlaneSurface waterLevelSurface = new PlaneSurface(basePlane, new Interval(-2, 2), new Interval(-2, 2));

                ObjectAttributes attributes = new ObjectAttributes();
                attributes.Name = "Water Level";
                attributes.SetUserString("AAAA", "BBBB");

                Guid objectGuid = file3Dm.Objects.AddSurface(waterLevelSurface, attributes);

                file3Dm.Write("C:\\Users\\A408201\\Desktop\\WaterLevel.3dm", options);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

        }
    }
}

Do I missing something or it is Rhino3dm library issue?

Thanks for your time and reply

Ondřej

Rather than reopening a 7-year old topic, I’ve started a new one.

Hi @janotaondrej91,

The attached seems to work.

TestUserText.zip (2.7 KB)

– Dale

1 Like

Thank you @dale, the only difference was in options.Version value which I
sett to 2 (and thought it is last version). With 80 it does work.

Thanks for help.

Best Ondřej

1 Like