Hi,
I want to convert from Sketchup selected length unit to meter.
Lets say I have a coordinate p = [a,b,c]
I want to convert the coordinate units to meter.
What i have tried
UNITS = [0.0254, 0.3048, 0.001, 0.01, 1]
unit_options = Sketchup.active_model.options["UnitsOptions"]
units_index = unit_options["LengthUnit"]
coordinates = "#{p.x * UNITS[units_index]}|#{p.y * UNITS[units_index]}|#{p.z * UNITS[units_index]}"
What i’ m doing wrong here ?
pt = Geom::Point3d.new(100,200,300)
pt.x.to_m
john
(1) Internally, Length
class is always inches no matter what the user has chosen for the display units .
(2) You do not show us what UNITS
is. We have to guess it is an array or hash.
(3) Did you look at the conversion methods that the SketchUp API adds to the Numeric
class ?
John has shown an example of using one of these API conversion methods.
(4) Also become aware of these module methods …
(5) I also recommend reading Thomas Thomassen ’s blog article …
system
Closed
April 26, 2018, 11:45pm
5
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.