# Wrong bounding box after scaling

**URL:** <https://discourse.mcneel.com/t/wrong-bounding-box-after-scaling/69020>\
**Category:** Scripting\
**Created:** [August 17, 2018, 2:33pm UTC](https://discourse.mcneel.com/t/wrong-bounding-box-after-scaling/69020 "2018-08-17T14:33:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tabellini](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/tabellini/32/111755_2.png) [@tabellini](https://discourse.mcneel.com/u/tabellini)\
**Post date:** [August 17, 2018, 2:33pm UTC](https://discourse.mcneel.com/t/wrong-bounding-box-after-scaling/69020/1 "2018-08-17T14:33:30Z")

</div>

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.

 ![bbx_bug_rhino_](https://global.discourse-cdn.com/mcneel/original/3X/e/c/ec54dc75cbdce4cc8ff0b03dc480b79338af5fb1.jpeg)

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

[WrongBoundingBoxAfterScaling.py](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/d/a/da222b39ffafc708595fdeadb48317f9b57b99ac.py) (1009 Bytes)

best,  
Gianluca

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [August 17, 2018, 7:04pm UTC](https://discourse.mcneel.com/t/wrong-bounding-box-after-scaling/69020/2 "2018-08-17T19:04:57Z")

</div>

Hi @tabellini,

Try this:

```auto
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

---

<div class="post-metadata">

**Author:** ![tabellini](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/tabellini/32/111755_2.png) [@tabellini](https://discourse.mcneel.com/u/tabellini)\
**Post date:** [August 20, 2018, 8:30am UTC](https://discourse.mcneel.com/t/wrong-bounding-box-after-scaling/69020/3 "2018-08-20T08:30:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [August 20, 2018, 7:25pm UTC](https://discourse.mcneel.com/t/wrong-bounding-box-after-scaling/69020/4 "2018-08-20T19:25:44Z")

</div>

> [@tabellini](#):
>
> Does it mean that every Geometry “found” from GUID is document-controlled?

Yep.

> [@tabellini](#):
>
> Duplicating the object before applying the transformation solve the problem.

👍

– Dale
