Wrong bounding box after scaling

Hi all,

I would like to report a bug in RhinoCommon. I’m using Rhino Version 5 SR14 64-bit (5.14.522.8390, 5/22/2017).
After applying a scale transformation to a brep, the bounding box of the new transformed object is actually the bounding box of the NON-transformed object.

I attach a simple script which shows the problem.
Duplicating the scaled object will solve it.

WrongBoundingBoxAfterScaling.py (1009 Bytes)

best,
Gianluca

Hi @tabellini,

Try this:

def main():
    # Create sphere
    plane = rs.WorldXYPlane()
    guid = rs.AddSphere(plane, 200)

    # Get Brep geometry
    brep = doc.Objects.Find(guid).Geometry
    if not brep: return
    
    # Define transformation
    xform = Rhino.Geometry.Transform.Scale(plane.Origin, 0.5)
    
    # brep is document controlled (e.g. read-only).
    # so make a copy before transforming
    brep_copy = brep.Duplicate()
    if not brep_copy.Transform(xform): 
        print "Error scaling sphere"
        return

    # Create a Brep box
    bbox = brep_copy.GetBoundingBox(plane)
    brep_box = Rhino.Geometry.Box(plane, bbox).ToBrep()
    
    # Add results to doc
    brep_copy_id = doc.Objects.AddBrep(brep_copy)
    brep_box_id = doc.Objects.AddBrep(brep_box)
    rs.ObjectColor(brep_copy_id, Color.Red)
    rs.ObjectColor(brep_box_id, Color.Red)

main()

– Dale

Hi @dale,

Thank you for the reply.
Does it mean that every Geometry “found” from GUID is document-controlled?
The strange behavior, anyways, is that the transformation is applied, because when I bake the brep (transformed but not duplicated), I got the scaled object. It’s just the bbx operation on it that used the brep before the transformation.

Duplicating the object before applying the transformation solve the problem.

Gianluca

Yep.

:+1:

– Dale