Search code examples
rubysketchup

what is returned when calling distance_to_line Sketchup Ruby API


Hi all

I am trying to get the distance from one 3D point object to a line. This is my code:

line_x = [Geom::Point3d.new(0,0,0), Geom::Vector3d.new(1,0,0)]
a = [10,11,0]
distance_x = a.distance_to_line line_x
puts distance_x

This is output in Sketchup ruby console.

11"

11"

I try distance_x.typename , but it got error :undefined method `typename' for 11.0:Length

I think output of distance_to_line is a number. Why i got double of result while i just call puts in one time.
Please help me, thanks


Solution

  • Array.distance_to_line returns a Length.

    line_x = [Geom::Point3d.new(0,0,0), Geom::Vector3d.new(1,0,0)]
    [Point3d(0, 0, 0), Vector3d(1, 0, 0)]
    a = [10,11,0]
    [10, 11, 0]
    distance_x = a.distance_to_line line_x
    11.0
    distance_x.class
    Length
    

    Yes, the docs aren't very clear on the return type.