Broken Scaling Transform

I am using RhinoCommon to scale objects and I came across this strange behavior. I’ve extracted the important code into a command:

using Rhino;
using Rhino.Commands;
using Rhino.Geometry;
using Rhino.Input.Custom;

namespace LayupRH.Commands
{
	public class MyScaleConstant : Command
	{
		public MyScaleConstant()
		{
			Instance = this;
		}

		public static MyScaleConstant Instance { get; private set; }

		public override string EnglishName => "MyScaleConstant";

		protected override Result RunCommand(RhinoDoc doc, RunMode mode)
		{
            using GetObject gb = new();
			Brep brep;
            gb.SetCommandPrompt("Select a brep to scale");
            gb.GeometryFilter = Rhino.DocObjects.ObjectType.Brep;
            if (gb.Get() == Rhino.Input.GetResult.Cancel)
            {
                return Result.Cancel;
            }

            brep = gb.Object(0).Brep();
            Transform transform = Transform.Scale(
                new Plane(Point3d.Origin, Vector3d.ZAxis),
                0.99,
                0.99,
                0.9
            );
            brep.Transform(transform);
            brep.Repair(0.001);

            doc.Objects.Add(brep);
            
            return Result.Success;
		}
	}
}

When I call it on the big shape,


I get the small shape

which has doesn’t match on the inside edges.

Is this a bug with the transformation? If so, is there a way to detect this kind of behavior? For my purposes I need to use RhinoCommon to scale a variety of shapes.

File with the shapes:
brokenScaling.3dm (167.7 KB)
Process for replication: Use the custom command on the bigger shape and it creates the smaller shape.

Thank you,
- Russell

Hi @Russell_Emerine,

if it’s a non uniform scale transform you might try to create a copy of the brep and make it deformable before the scaling as explained here

_

c.

Thank you, using MakeDeformable before the transformation worked. Luckily there weren’t too many places in the codebase I’m working with where it needed to be added.

solved ? pleas mark clement 's post as solution. thx