Geometry.Transform() no longer returns false on failed transformation

When running Rhino.Geometry.GeometryBase.Transform(xform) where the input is an invalid brep object the transformation is not applied, an exception is not thrown and true is returned. I cannot put my finger on exactly when this change occurred, but I think this is something that changed between build …20… and …26…

I have included an example file which contains invalid polysurfaces for testing.
InvalidPolysurface.3dm (569.0 KB)

Below is the method I have been using to transform objects which is no longer throwing exceptions when Geometry.Transform returns false.


        /// <summary>
        /// Apply a transformation to an array of object guids.
        /// </summary>
        /// <param name="doc">The currently open rhion document.</param>
        /// <param name="objectIds">Ids of objects to be moved.</param>
        /// <param name="transform">4x4 transformation to be applied.</param>
        /// <param name="copy">If true a new object will be added otherwise the existing object will be moved.</param>
        /// <returns>Array of objects that were transformed.</returns>
        /// <exception cref="BadModelingException">If geometry was unable to be transformed.</exception>
        public static Guid[] TransformObjects(RhinoDoc doc, Guid[] objectIds, Transform transform, bool copy = false)
        {
            // create empty list to hold object ids//
            var ids = new List<Guid>();
            foreach (var id in objectIds)
            {
                // get object associated with given guid
                Rhino.DocObjects.RhinoObject obj = doc.Objects.Find(id);
                if (obj == null)
                {
                    continue;
                }

                if (!obj.Geometry.Transform(transform))
                {
                    string valid = obj.Geometry.IsValid ? "Valid" : "Invalid";
                    throw new BadModelingException($"Unable to transform {valid}-{obj.Geometry.ObjectType} id:{obj.Id}");
                }

                if (copy)
                {
                    ids.Add(doc.Objects.Add(obj.Geometry));
                }
                else
                {
                    doc.Objects.Replace(id, obj.Geometry, true);
                    ids.Add(id);
                }
            }

            return ids.ToArray();
        }

Please let me know if there is another method I should be calling that will preform the intended function or when this method will be corrected to return false upon failing to transform a geometry.
Thanks,

Hi @5chmidt,

This Python script seems to work. Perhaps there is something here you can take away?

import Rhino
import scriptcontext as sc

def test():
    filter = Rhino.DocObjects.ObjectType.PolysrfFilter
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select polysurface to transform", False, filter)
    if not objref or rc != Rhino.Commands.Result.Success: 
        return
    
    brep = objref.Brep()
    if not brep:
        return
        
    if not brep.IsValid:
        print("Brep is invalid")
    else:
        print("Brep is valid")
        
    dir = Rhino.Geometry.Vector3d.XAxis * 10.0
    xform = Rhino.Geometry.Transform.Translation(dir)
        
    bcopy = brep.DuplicateBrep()
    if not bcopy.Transform(xform):
        print("Unable to transform Brep")
        return
    
    sc.doc.Objects.Replace(objref, bcopy)
    sc.doc.Views.Redraw()
    
if __name__ == "__main__":
    test()

– Dale