Drawing a ray or line from a vector
-
I am currently retrieving a vector from sketchup and I am trying to draw a line from that retrieved vector. Is there a way to do this?
-
http://www.sketchup.com/intl/en/developer/docs/ourdoc/entities.php#add_cline
This will give you a construction line defined by a point and a vector. If you want to draw a line segment aka edge you could get the second end point by applying a scaled transformation to your initial point.
-
A vector defines a 'direction', which essentially is not determined in its location in space.
To define an 'edge' you need a start point - let's call it 'point1'...
Then set your vector's length using:
vector.length=length
and find 'point2' for the end point:
point2=point1.offset(vector)
Now you have two points representing the start/end-points of a potential new edge.
Use
Sketchup.active_model.active_entities.add_line(point1, point2)
or
Sketchup.active_model.active_entities.add_edges([point1, point2])Don't confuse edge & line - confusing the API does when adding one edge it calls it a 'line'!
Actually a 'line' is a special geometrical construct of [point, vector], which us infinitely long passing through the point, along the vector. Lines can intersect etc...
Advertisement