Displaying the Normal of a Polygon
-
I was wondering if there is a way to display the normal of a selected polygon? I have researched it a little bit and it seems like I may need to calculate the normal based on the vertex's of the polygons. Has anyone done this or have any ideas on the easiest way to accomplish this task.
-
If the polygon is a simple singple plane (which it should be if its a polygon), then you just take the face and get its normal. Let's say you have the single face selected, you can run this line of code in the ruby console:
Sketchup.active_model.selection[0].normal
And that will return the vector that represents the polygon's normal. Is that what you're looking for?
Chris
-
If by polygon you mean a face, then it's easy. If the polygon is just geometry without entities, then it needs to be calculated. But you can use creative solutions, like
normal = Geom::Vector3d.new( [Geom.fit_plane_to_points](http://sketchup.com/intl/en/developer/docs/ourdoc/geom.php#fit_plane_to_points)(points)[0...3] )
-
Thanks guys thats what I needed.
Advertisement