Read 3dm files in different unit system

Hi all,

I need a little help about reading 3dm files and unit system. I will try to explain with more details.

I open Rhino project with unit system in millimeters, then export one object in the 3dm file. I guess that in the 3dm model also there are information about unit system beside geometry. Then I open project in Rhino with unit system in inches and try to read 3dm file via code, made some transformations and drawn the object in the project. When I measure the object (let’s say from one end point to another) it gives me the same value in inches and millimeters (same number, for example distance is 1000 mm and 1000 inches when I open the 3dm file in Rhino project in millimeters and inches). For test, I try Import command and Import option from Rhino to load the object and the object in imported successfully and the dimensions that I measure were OK. Is there any changes that I should made via
code to import 3dm object correctly?

I also made another test: export 3dm file only with geometry included (Save only geometry) and try to import via code and then the object dimensions was correctly.

To make correct importing of the objects in the 3dm file I also try to made some changes in the code to force unit system like this:

// read 3dm file and get the object and try to change model unit settings
const ONX_Model& model = readFile.GetONXModel(); 
ONX_Model& model1 = const_cast<ONX_Model&>(model);
model1.m_settings.m_ModelUnitsAndTolerances.m_unit_system = ON::UnitSystem(ON::inches);
model1.m_settings.m_PageUnitsAndTolerances.m_unit_system = ON::UnitSystem(ON::inches);

// try to use correct model scale
ON_Xform rotationTranform, translationTransform;
const double modelScale = ON::UnitScale(ON::millimeters, ON::inches);

Can you please tell me how I should export objects in 3dm model or how to made correct conversion between unit systems via code ( I want my 3dm files to be independed from the unit system). I still work in Rhino 5 :slight_smile:

Thanks a lot,

Best regards,


Hi Dale,

I divide one big model into small peace of objects and save them in 3dm files. Then I read 3dm files and with simple transformations I merge then into one big object and draw in the Rhino. I think that the main problem is when I export the 3dm model in mm (beside geometry, plane and origin point is save in the file in mm) and when I try to made conversion from mm to inch there is problem and cannot merge the object correctly neither draw correct scale of the models. Do you have any idea how can I transform and draw objects from 3dm model via “code” ?

Thanks a lot,
Best regards,

Hi @Ivi,

Attached is a sample command that imports meshes from 3dm files. It also scales the imported geometry if needed.

cmdTestImportMeshes.cpp (3.7 KB)

I don’t have the Rhino 5 C++ SDK installed (sorry). Hopefully this will be enough to help you move forward.

– Dale

1 Like

Hi Dale,

Thanks a lot. This was very helpful!

Best regards,