Draw cpoint on face
-
Hello,
I was wandering how to draw a point on a face like this?
My strategy would be:
1: Find outer_loop.vertices for the face.
2: Use outer_loop.vertices[0] as a starting-point to place the desired point by trial and error, while using the classify_point method for the face.The problem of this method is that near the vertices there could be holes of
which the script is not aware.Best regards,
Liquid
-
Well where do you want the point?
You also have face.plane and face.bounds to play with.
From bounds you can find the center etc..Might be more useful if you wanna find a position in a hole..
-
This might be usefull:
-
You can easily find an arbitrary point on the
face.plane
- for example:
face.outer_loop.vertices[0].position
face.bounds.center
etcThen API's
face.classify_point(point)
returns various codes depending on the state of that point.
See http://sketchup.com/intl/en/developer/docs/ourdoc/face.php#classify_point0: Sketchup::Face::PointUnknown (indicates an error), 1: Sketchup::Face::PointInside (point is on the face, not in a hole), 2: Sketchup::Face::PointOnVertex (point touches a vertex), 4: Sketchup::Face::PointOnEdge (point is on an edge), 16: Sketchup::Face::PointOutside (point outside the face or in a hole), 32: Sketchup::Face::PointNotOnPlane (point off the face's plane).
It is important that return value comparisons be made against the symbolic constants (i.e. Sketchup::Face::PointUnknown, Sketchup::Face::PointInside, Sketchup::Face::PointOnVertex etc) rather than the absolute integer values, as these values may change from one release to the next.
Once you have a point you know is on the face.plane, then you can 'nudge' it using
point.offset!(vector)
, where the vector has a small length and is predetermined to run along theface.plane
- you know theface.normal
vector already... Then you retest the point for its classification on the face... Iterate until the point is on [or off?] the face as you want it to be...To add the cpoint is straightforward...
face.parent.entities.add_cpoint(point)
-
TIG,
Thanx for your answer, it completely elucidates my question.
Advertisement