@dan rathbun said:
Notice this console error:
pointonline = [10,10,10].project_to_line [0,0,0] %(#008000)[Error: #<ArgumentError: (eval):0:in
project_to_line': Cannot convert argument to Sketchup::Point3d>]`What that tells you is that internally, the
project_to_line()
method, calls the constructor methods for you onArray
arguments.
Like:
pt1 = Geom::Point3d.new(args[0]) if args[0].is_a?(Array) pt2 = Geom::Vector3d.new(args[1]) if args[1].is_a?(Array)
.. etc ...
- And the error message itself has a typo. The class is within the
Geom
module, not theSketchup
module. (This bug has been reported.)
What that tells me mostly, with all due respect, is that you cannot define a line with a single point as witness that from the ruby console:
[20,10,30].project_to_line [0,1,1], [5,1,1]
[25.5555555555556, 6.11111111111111, 6.11111111111111]
Doesn't generate an error (yes it takes the second array as a vector)
So I don't know whether it calls a constructor method or any such fine and advanced details, all I know is that I can define a line such as [0,1,1], [5,1,1] as in entities.add_line [0,1,1], [5,1,1] and it works, and takes the second array as being a point. Please note too that the line definition can interpret the second array as a point or a vector too, and it defaults to point apparently (but I have a method in array (vector_to) that allows me to easily specify such array as being a vector, not so for a point.
Yet when I use that line definition, which is accepted and stated as a line definition, into the line argument for the project_to_line method, it just doesn't take it as such.
I may still be wrong, but it still seems to me that it's not as originally intended, and stated. And that a statement of raised exception may help.
- And the typo is that it should be "cannot convert argument to line" I think, whatever a line is (it's not in the class list, but yet is used as valid object, and there is a geometric one (drawn), and a mathematical one.) I quote from the Geom module:
@unknownuser said:
The methods in this module take lines and planes as arguments. There is no special class for representing lines or planes. Arrays are used for both.
A line can be represented as either an Array of a point and a vector, or as an Array of two points.
NOTE: Lines and Planes are infinite.
and from the add_line method:
@unknownuser said:
The add_line method is used to add an edge to the collection of entities. This is not to be confused with the concept of a "line" from a geometric sense, which is an invisible object represented by an Array of a point and a vector. (See the Array class for more information on geometric lines in SketchUp.)