Getting document user strings with OpenNurbs and C#


#1

Hi,
New to Rhino and OpenNURBS.
I am trying to get the document strings that are displayed with GetDocumentUserText in the Rhino application as shown below.

Command: GetDocumentUserText
Document text key :
6 document user strings.
Description> This is a Rhino 3dm file.
DocNumber> 0001.
Stone> Diamond, Ruby.
ProductType> Ring.
FileName> TestAdept.3dm.
chkdockey> chkdoctext.

I am using the sample program Rhino3dmIO3dmFileDump as a starting point.

I can get user data for other objects but not the documentuserText

This works for getting user text I have added with the SetUserText

	Rhino.FileIO.File3dm model = Rhino.FileIO.File3dm.Read(filename);

	Rhino.FileIO.File3dmObjectTable ObjectTable = model.Objects; 

        foreach (Rhino.FileIO.File3dmObject File3Object in ObjectTable)
        {
            string objectName = File3Object.Name;
           
            Rhino.DocObjects.ObjectAttributes ObjectAttr = File3Object.Attributes;
           
            NameValueCollection NameValueCol = ObjectAttr.GetUserStrings();

            string[] allkeys = NameValueCol.AllKeys;
            int Count = NameValueCol.Count;
            
            int  i=0;
            while (i<Count)
            {
                string keyvalue= NameValueCol.Get(i++);
            }

        }

So how do I get the document object so I can get the document user text?
This is for a stand alone application using openNURBS and not a PlugIn in Rhino

Thanks


(Dale Fugier) #2

Hi Chris,

The ability to read and write document user text is not currently available in the open source version of Rhino3dmIO that is available on GitHub. It is, however, on the to-do list for Rhino 6:

https://mcneel.myjetbrains.com/youtrack/issue/RH-38134

I should add you can read and write document user text from the C++ version of openNURBS. Thus, if you were skilled creating P/Invoke type functions, you could add this ability to Rhino3dmIO yourself.

– Dale


(Dale Fugier) #3

@chris_k, this ability has been added to RhinoCommon for the Rhino WIP. When we make the Rhino3dmIO toolkit available for Rhino 6, it too will have this ability.

– Dale