Confusion about rs.MirrorObject()

Hello, I’m really new to Rhino Python scripting, but not new to Python. I am trying to create a box and then mirror that box. If I run my script with the front view selected, everything works as expected. If I run my script from the perspective layer, box draws, but doesn’t mirror as expected. I’m really confused as to why this is happening and how to correctly resolve this so that my mirroring happens correctly no matter which view I have selected. Thanks!

import rhinoscriptsyntax as rs
from System.Drawing import Color

width = rs.GetInteger("Total Width", 24, 0, 48)
height = rs.GetInteger("Total Height", 36, 0, 48)
depth = rs.GetInteger("Total Depth", 48, 0, 48)

left_wall = rs.AddBox([
    (0,0,0),
    (2,0,0),
    (2,0,height),
    (0,0,height),
    (0,depth,0),
    (2,depth,0),
    (2,depth,height),
    (0,depth,height)])

# now mirror it
rs.MirrorObject(left_wall, [width/2, 0, 0], [width/2, 0, height], True)

I actually just figured this out. I needed to set rs.CurrentView("Front") before drawing. I’m not sure why, but at least it works now.

Well, if you look at the Help for mirror object, it shows that it wants two points to determine the mirror plane. The problem is, it takes 3 points to determine a plane. So what happens is in this case rhinoscriptsyntax is using the current active viewport’s CPlane to determine the third point - as if you drew a mirror line in that viewport.

If you want this to work with rhinoscriptsyntax, you either have to set the viewport that has the CPlane you want first before running the mirror, or instead, to have it work the same in any viewport, create a mirror transform that uses an actual plane determined by a point and a normal vector, then apply the transform with rs.TransformObject()

Thank you, it makes sense when you think about it.