How to change document model units

Hi,i am trying to write a import plugin with c#.But i can’t find the way to modify the document model units before read the file.Can anyone help me?

First of all, make sure you have created a File Import plug-in. Then, in the method where you read the file, you can do the following to adjust the model unit system of the document:

protected override bool ReadFile(string filename, int index, RhinoDoc doc, FileReadOptions options)
{
    doc.AdjustModelUnitSystem(UnitSystem.Millimeters, false);
    // read stuff
    return true;
}

Thank you!but i am using Rhino.Net,not Rhinocommon.Is it the same methods?

Oh, ok. Then you need to do something along the lines of

MRhinoDoc doc; // defined elsewhere
On3dmUnitsAndTolerances unitsAndTolerances = 
    new On3dmUnitsAndTolerances(doc.Properties().ModelUnitsAndTolerances());
unitsAndTolerances.m_unit_system.m_unit_system = IOn.unit_system.millimeters;
doc.Properties().SetModelUnitsAndTolerances(unitsAndTolerances);

As you can see from the complexity of the two code snippets, I can’t encourage you enough to switch to RhinoCommon :smile:

OK,i’ll try to switch!Thanks!

I have an other question.which method can replace the “MRhinoDoc::SetTitle”?

I don’t understand the question. What are you trying to do and why?

Thanks,

– Dale

I’am trying to set the document title after reading the file.such as

And you are trying this with RhinoCommon, right?

yes!