I have one problem with InputPoint.face method in Sketchup Ruby API.
When i import one image object and then draw 5-edges polygon on this image. I used InputPoint.face for getting number of edges in the polygon after clicking on it. I think the output is 5, but actually, the output is 4
If i remove the image , result will be 5.
I don't understand why the output is like that, and what can i do to get output 5?
This is my code
# The onLButtonDOwn method is called when the user presses the left mouse button.
def onLButtonDown(flags, x, y, view)
@ip = view.inputpoint x,y
@f = @ip.face
aEdges = @f.edges
puts aEdges.length
end
Thanks you
So you have drawn pentagon faces on the Image
entity you imported? And when you use InputPoint
to click on one of the pentagons you get a face with four edges?
What happens here is probably that you are getting the Face
inside the Image
entity. Under the hood an Image
entity is a special component instance. You can in fact find the definition for the Image
entity in model.definitions
.
For more details on SketchUp and Components, Groups and Images read this article: http://www.thomthom.net/thoughts/2012/02/definitions-and-instances-in-sketchup/
InputPoint
and PickHelper
seem to let you pick the face inside the Image
entity instead of stopping when it hits the Image
entity.
You will probably want to filter out your results before using them and you probably wantto use the PickHelper
class instead of InputPoint
.
http://www.sketchup.com/intl/en/developer/docs/ourdoc/pickhelper.php
http://www.thomthom.net/thoughts/2013/01/pickhelper-a-visual-guide/
InputPoint
is more for getting 3d points for inference, while PickHelper
is best to use to pick and select entities.
You can check the Face
entity you get from InputPoint
and it's parent to verify which face it is and what context it belongs to.