I’m using a script to draw some solids using faces and push-pull. It appears there is a strange and un-expected corner case behavior. A positive push-pull distance is normally drawn in a positive Z direction (for faces in a plane parallel to the XY plane). But, when the faces is actually in the XY plane (Z=0), that
direction is reversed. I’m guessing the face and back face are swapped.
The following code file demonstrates the behavior. Simply open the Ruby console and load the code from a file. The red cylinder shows the “problem”. Is this intentional ? Does it make sense for some reason ?
=begin rdoc ================================================================ SketchUp strange behavior (from Ruby API). A cylinder can be drawn by drawing a circlular face, then performing a push/pull to a specific height. This can all be done from a Ruby script. But there seems to be an odd corner case in the way the API works. The direction of the face seems to depend upon the Z coordinate of its origin. If this coordinate is 0, the direction is reversed. ================================================================ =end =begin rdoc ================================================================ Method: cylinder Creates an empty group in the entities for the active model, then adds cylinder entities to that group. The cyliinder has a vertical axis. Arguments: * origin 3dPoint at center of bottom face of cyliner * radius radius of the cylinder * height height of the cylinder * material color of the cylinder ================================================================ =end def cylinder( origin, radius, height, material ) group = Sketchup.active_model.entities.add_group entities = group.entities up = Geom::Vector3d.new(0,0,1) # Call methods on the group's entities collection to draw a # circle perpendicular to the specified axis circle = entities.add_circle origin, up, radius face = entities.add_face( circle ) face.material = material face.back_material = material face.pushpull height # return end # method =begin rdoc ================================================================ Main 3 identical cylinders are drawn to show how the direction of the push/pull differs when the face is at Z=0. The Red cylinder is the oddball. ================================================================ =end # # 3 cylinders will be drawn. They are parametrically identical # radius = 10 # radius of all cylinders height = 50 # height of all cylinders # # The cylinders are spaced out in the XY plane (they all have # vertical axes). The only difference is the polarity of the # Z coordinate of the origin. # spacing = 4 * radius # XY spacing between cylinders center =  center = Geom::Point3d.new(1*spacing,1*spacing,-10) center = Geom::Point3d.new(2*spacing,2*spacing, 0) center = Geom::Point3d.new(3*spacing,3*spacing, 10) # # Draw the 3 cylinders # cylinder( center, radius, height, "Green" ) cylinder( center, radius, height, "Red" ) cylinder( center, radius, height, "Green" )