I'm trying to write a tool that adds edges wherever a face in a component instance (@ci) intersects a specified X/Z or Y-Z axis "slicing plane".
Anyway, the basic procedure I'm using is:
Traverse a list of slicing planes: [1,0,0,-x1], [0,1,0,-y1], ...
Traverse @ci.definition.entities:
Bail out unless the entity is a face.
Bail out unless plane passes through the face.
Get the plane for the face.
Call Geom.intersect_plane_plane().
Bail out unless it returns a line.
Call add_line().
I'm currently stalled at the point where I call ents.add_line(). I've tried several variations:
# edge = ents.add_line(line) # H0
# edge = ents.add_line(*line) # H1
# edge = ents.add_line(line[0], line[0]) # H2
# edge = ents.add_line(line[0], line[1]) # H3
Versions H0-H2 all give me the following output:
p1 = 1, 0, 0, 2.4880390561432
line = (-2.488039", 8.362949", 0")(0.0, -0.607450107570801, -0.794357832977193)
Geom;;Point3d
Geom;;Vector3d
Error; #<ArgumentError; Cannot convert argument to Sketchup;;Point3d>
I suspect that the error message is faulty and should refer to Geom::Point3d, rather than Sketchup::Point3d. If so, the problem is that SU isn't willing to accept a line in the (Point, Vector) format that Geom.intersect_plane_plane() returns.
This is confirmed by Version H3, which doesn't complain because I'm actually handing in a pair of points (of course, the second point is bogus).
Questions
Is there an easier way to create these edges?
Am I analyzing the nastygram correctly?
How do I convert the line to an acceptable form?
See http://pastie.org/729725 for a larger code snippet...