Hello, I got some trouble in retrieving plugin data from the 3dm file using the Rhino3dmIO.
We made the plugin that saves both the object user data and the document user data to the 3dm file. In our workflow, we use the rhino to do the design with the plugin, but need to visualize the outcome using the web. So we are working on a simple standalone application for this purpose.
In Rhino, I managed to read/write the ArchivableDictionary data using BinaryArchiveReader.ReadDictionary() and RhinoObject.Attributes.UserDictionary, but with Rhino3dmIO library, none of these methods seems to return any results. The retrieved objects using Rhino3dmIO have the “null” UserDictionary.
Here is the partial code of the project, it would be much appreciated if anyone can offer suggestions on this. Thanks in advance.
public static void UpdateParamsToSM(List<File3dmObject> rhinoObjs)
{
foreach (File3dmObject obj in rhinoObjs)
{
try
{
ObjectClass objectClass;
if (obj.Attributes.UserDictionary.TryGetEnumValue<ObjectClass>("SM_ObjectClass", out objectClass))
{
SMHeadlessInterface.gWriteRead.ReadObjects(objectClass, obj);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
public static void ReadScenarioFromDoc(string filePath)
{
SMHeadlessInterface.gScenarios.Clear();
using (var file = new BinaryArchiveFile(filePath, BinaryArchiveMode.Read))
{
if (file.Open())
{
BinaryArchiveReader reader = file.Reader;
ArchivableDictionary dict = reader.ReadDictionary();
int nb = 0;
if (dict.TryGetInteger("SM_Nb_Scenarios", out nb))
{
for (int i = 1; i <= nb; i++)
{
try
{
Scenario scenario = ReadScenario((ArchivableDictionary)dict["SM_Scenario" + i]);
SMHeadlessInterface.gScenarios.Add(scenario.Id, scenario);
}
catch
{
Console.WriteLine("failed to load" + "SM_Scenario " + i.ToString());
}
}
}
}
else
{
Console.WriteLine("Not able to open the 3dm file.");
}
}
}