First, I’ll admit that I’m not a Rhino user. Having said that, I’ve been tasked with renaming a number of Point objects in a series of 3dm files. Using Rhino3dmIO, I have been able to open and read the files. I can get the names of the Point objects within the file. But, I can’t rename them.
Here’s what I’m doing:
At this point, filelist has already been populated with a series of FileInfo objects representing the 3dm files. OLD_Names[] contains the list of existing names, and NEW_names[] contains the list of new names.
int numObjects;
string name;
bool fileChanged;
foreach (FileInfo fi in filelist)
{
fileChanged = false;
File3dm rhinofile = File3dm.Read(fi.FullName);
numObjects = rhinofile.Objects.Count();
for (int i=0; i<numObjects; i++)
{
name = rhinofile.Objects.ElementAt(i).Name;
for (int j =0;j<OLD_Names.Count(); j++)
{
if (name == OLD_Names[j])
{
fileChanged = true;
rhinofile.Objects.ElementAt(i).Name = NEW_Names[j];
}
}
}
if (fileChanged)
{
rhinofile.Write(fi.FullName, rhinofile.Revision);
}
}
The code doesn’t crash, no errors are thrown. The new name just isn’t accepted. I know that RhinoCommon has a CommitChanges method and a ModifyObjectAttributes method. However, Rhino3dmIO seems to lacking those.
I’m using Visual Studio 2015, and I downloaded the Rhino3dmIO library from NuGet, I did not compile it from source.
Thanks for any suggestions.
Don