Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Circular Wall Openinings

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
2487 Views, 4 Replies

Circular Wall Openinings

Dear Members ,

 

Rectangular wall openings can be created by using doc.Create.NewOpening(wall,point1,point2) but is there a way where a circular opening can be created.

Thanks & Regards

Sanjay Pandey

 

4 REPLIES 4
Message 2 of 5
jeremytammik
in reply to: Anonymous

Looking at these previous discussions, it seems to me that you can also use a curve array or a family instance to define the opening shape.

 

 

Cheers,

 

Jeremy

 

 

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 5
Omar_Amen
in reply to: jeremytammik

Is this mean that I can make an wall opening by set of curves using 

NewOpening(Element, CurveArray, Boolean) ?
Is there any updates to make a circular hole in wall using some curves ?? 

Message 4 of 5
RPTHOMAS108
in reply to: Omar_Amen

Prior to 2022 I would say you can't add sketched circular openings or other openings based on sketched curves to a wall face because the only UI feature that can do this (Walls > Edit Profile) wasn't supported by the API. The various sketch based methods were for floors / ceilings / roofs / family instances such as beams etc. You could have also created in the UI a rectangular wall opening by two points (which is equivalent to the API function).

 

However now you have Wall.CreateProfileSketch which can be used with SketchEditScope. Since you can create openings of any nature in the UI this way I would assume similar can be created with the API. I've not tested this so assume there is no extra criteria for the sketch done via the API that doesn't exist for the UI.

 

I still favour hosted void families for all kinds of openings on all kinds of elements because these are the only types of openings that can be scheduled and phased. It's generally not a good idea or very BIM to use sketch based openings.

 

210802a.PNG

Message 5 of 5
reylorente1
in reply to: Anonymous

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);
}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report