Closed mostaphaRoudsari closed 9 years ago
@ksobon What do you think about adding units to each geometry before you pass it to Dynamo? You can read it back in Dynamo.
import scriptcontext as sc
x.SetUserString("units", sc.doc.ModelUnitSystem.ToString())
yes, this sounds good. I will get that in there... thanks!
Mhmmmm while reading Rhino (3dm) files I can just get ModelUnitsSystem from the file and pass it along from there to every geometry conversion node.
units = rhModel.Settings.ModelUnitSystem
create a conversion factor from there:
def toDSUnits(_units):
if _units == rc.UnitSystem.Millimeters:
return 0.001
elif _units == rc.UnitSystem.Centimeters:
return 0.01
elif _units == rc.UnitSystem.Decimeters:
return 0.1
elif _units == rc.UnitSystem.Meters:
return 1
elif _units == rc.UnitSystem.Inches:
return 0.0254
elif _units == rc.UnitSystem.Feet:
return 0.3048
elif _units == rc.UnitSystem.Yards:
return 0.9144
so this works for reading 3dm files. Reading a serialized GH file will require that I write that information to geometry. For that we can use UserStrings or since new Mantis Shrimp can send data I can just send over a simple data pocket with every export that will contain UnitsSystem name.
OK, I just added units to DY>GH>DY transfers. For some reason it slowed down my graph execution in GH. I will test that further to make sure that it doesn't compromise speed too much. PS. On transfers between DY and GH i am assuming that DY side is always operating in Meters (DY uses meters internally) so I am only adjusting units to and from Meters.
@ksobon looks like there is no check for units from the source document. It is probably a good idea to add one.