Detect & Fix "broken" faces

The code should not assume that the faces will always belong to the Sketchup.active_model.entities collection. As @TIG did above, you should use obj.parent.entities:

  def self.fix(faces)
    # All faces must be within same parent entities:
    return unless == 1
    vertices =
    model = vertices.first.model
    model.start_operation("Fix Faces",true)
      # Generally speaking, seek to transform vertices using bulk method
      #  to prevent face triangulation:
      faces.first.parent.entities.transform_entities(IDENTITY, vertices)
1 Like