Extrusion sometimes reverses all faces
-
I am drawing mouldings for doors and sometimes the extrusion draws all faces in reverse. It appears to be random as I can draw the exact door and sometimes it is reverse and sometimes it is proper.
Any suggestions?
-
@garry k said:
I am drawing mouldings for doors and sometimes the extrusion draws all faces in reverse. It appears to be random as I can draw the exact door and sometimes it is reverse and sometimes it is proper.
Any suggestions?
If each door is a component, no transform you can apply will flip only certain faces on certain instances.
So I'm presuming you're creating each door moulding manually? Again, if its a clean (no tiny edges or shards), manifold (no edges with 1 face attached) model, you should be fine.
Its possible its a precision issue if the scale is wrong - ie the doors are tiny.
-
These doors are created with my door maker plugin. The profile of the moulding are points that create a face. I've looked at the orientation or winding of the face and it doesn't have a direct relation to whether the moulding has reversed or proper faces.
The path is a series of points and form a connected polyline where the winding is clockwise.
It appears that the face.followme(path) command sometimes extrudes reversed and sometimes extrudes properly.
I'm wondering if anyone else has experienced this and if anyone has found a solution.
-
I figured out a solution that seems to work in my case.
- I always build the door in the same plane. The door is rotated and moved after fully built.
- All the faces are either consistently reversed or all are correct.
- The majority of the faces always face outward. I may have 1 or 2 faces that face inwards.
I do the following:
flip is 1 if the moulding is on the front of the door. flip is -1 if it is on the back of the door
sum = 0.0
grp.entities.each { |ent| sum += ent.normal.dot(Y_AXIS) if (ent.kind_of? Sketchup::Face) }
grp.entities.each { |ent| ent.reverse!() if (ent.kind_of? Sketchup::Face) } if ( sum * flip > 0 ) -
Reversed faces is always a result of the ordering of the points that creates the face. And for pushpull and followme it depending on the direction of the face normal and the direction you pushpull.
One gotcha is that when creating faces on the ground plane SketchUp always force it to face down.
-
When it comes to push pull I understand that it does depend upon the winding (clockwise or counter clockwise) of the polygon. This is consistent and repeatable.
However, with an extrusion that has a closed polyline as a path it is not repeatable. I can guarantee that the points for the face are always created exactly the same way - since they come out of a txt file. I store x and y points at 1/10000 decimal inches. The z values are set as 1/2 of the height of the door panel.
I also calculate the path as x and y points which is a closed polyline. The Y values are 0.
face = group.entities().add_face(face_pts)
path = group.entities().add_curve(path_pts)
face.followme(path)If I build the door at [0,0,0] look at it and then do a ctrl_z and repeat this process, I get a results where the the extrusion is sometimes reversed and sometimes not.
It appears random - although the polyline and face are always created exactly the same way.
When I create my curved stair stringers using fill_from_mesh I store each polygon's points with a clockwise winding. So far this has proved 100% predictable and repeatable.
In the early days I used to do a lot of work with GIS and Windows GDI and create polypolygon this way. If you wanted to create a continent with a large lake that has an island that has a body of water you would have a series of 4 diminishing polygons each completely residing within each other. The outer most polygon would be clockwise (the continent) the large lake would be counter clockwise, the island would be clockwise and the body of water in the island would be counter clockwise.
I found that the sketchup works essentially the same way with meshes.
Advertisement