Cleaner way of adding/deleting objects to doc.Objects

Hey everyone!

I have a question about clean way of adding/deleting objects from doc, that were selected by the user. I got a list of breps that the user is picking themselves using a command and then the code goes as follows:

        foreach (var obj in go.Objects())
            var brep = obj.Brep();
            if (null == brep) return Result.Failure;

        foreach (Brep brep in breps)
            Brep newBrep = brep.DuplicateBrep();
            double targetHeight = optionInteger1.CurrentValue;
            BoundingBox bBox = newBrep.GetBoundingBox(true);
            double currentHeight = GetHeight(newBrep);
            Point3d pointOrigin = new Point3d(bBox.Center.X, bBox.Center.Y, bBox.Min.Z);
            Transform transformationMatrix = Transform.Scale(new Plane(pointOrigin, Vector3d.ZAxis), 1, 1, targetHeight / currentHeight);


        return Result.Success;

First I change it from extrusions to breps, then scale, add to doc and delete the previous objects. I am thinking, is there a more “clean” way to do so? Like one line method?

You could start by using doc.Objects.Transform
Not a one-liner, you still need to calculate the transform, but still…

1 Like