Aunque ya lleva algún tiempo, como hacer aberturas circulares en las paredes y no sé, si Anonymous y Omar_Amen resolvieron el problema. Aquí le comparto esta solución (Métodos) empleando la recomendación de RPTHOMAS108 y el CmdEditFloor(Make Hole) de Jeremy. Espero que ayude.
Although it has been taking some time, like making circular openings in the walls and I don't know, if Anonymous and Omar_Amen solved the problem. Here I share this solution (Methods) using RPTHOMAS108's recommendation and Jeremy's CmdEditFloor(Make Hole). I hope it helps.
/// <summary>
/// Add new circle to wall
/// </summary>
public void MakeHole(Document doc,Wall wall)
{
BoundingBoxXYZ bb = wall.get_BoundingBox(doc.ActiveView);
var min = bb.Min;
var max = bb.Max;
XYZ center = Midpoint(min, max);
LocationCurve locCurve = wall.Location as LocationCurve;
Line line = locCurve.Curve as Line;
XYZ xyz = line.Direction;
var valorZ = XYZ.BasisZ;
Sketch sketch = null;
if (wall.CanHaveProfileSketch())
{
using (Transaction trans = new Transaction(doc, "Create Wall Sketch"))
{
trans.Start(); // Inicia una nueva transacción
wall.RemoveProfileSketch();
sketch = wall.CreateProfileSketch();
trans.Commit(); // Finaliza la transacción y aplica los cambios al modelo
}
}
var sketchEditScope = new SketchEditScope(doc,
"Add profile to the sketch");
sketchEditScope.Start(sketch.Id);
using (var transaction = new Transaction(doc,
"Make a hole"))
{
transaction.Start();
// Create and add an ellipse
var circle = Ellipse.CreateCurve(center,
2, 2, xyz, valorZ, 0, 2 * Math.PI);
// Model curve creation automatically puts the curve
// into the sketch, if sketch edit scope is running.
doc.Create.NewModelCurve(circle, sketch.SketchPlane);
transaction.Commit();
}
sketchEditScope.Commit(new FailuresPreprocessor());
}
public class FailuresPreprocessor : IFailuresPreprocessor
{
public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
{
IList<FailureMessageAccessor> failList = new List<FailureMessageAccessor>();
// Inside event handler, get all warnings
failList = failuresAccessor.GetFailureMessages();
foreach (FailureMessageAccessor failure in failList)
{
// check FailureDefinitionIds against ones that you want to dismiss,
FailureDefinitionId failID = failure.GetFailureDefinitionId();
// prevent Revit from showing Unenclosed room warnings
if (failID == BuiltInFailures.WallFailures.WallSettingsChanged)
{
failuresAccessor.DeleteWarning(failure);
}
}
return FailureProcessingResult.Continue;
}
}
/// <summary>
/// Return the midpoint between two points.
/// </summary>
public static XYZ Midpoint(XYZ p, XYZ q)
{
return 0.5 * (p + q);
}