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;
breps.Add(brep);
}
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);
newBrep.Transform(transformationMatrix);
doc.Objects.AddBrep(newBrep);
}
doc.Views.Redraw();
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?