Revit .net Issue

Revit .net Issue

Anonymous
Not applicable
709 Views
3 Replies
Message 1 of 4

Revit .net Issue

Anonymous
Not applicable

My Issue is: I need to replace the Dormer opening with Vertical opening "Dormer opening cause error by area definitions in combinations with RoomComputationHeight"

 

  Level level = commandData.Application.ActiveUIDocument.Document.ActiveView.GenLevel;

            ICollection<Opening> DormerOpeningsList = new List<Opening>();

 

            ElementLevelFilter filterElementsOnLevel = new ElementLevelFilter(level.Id);

            FilteredElementCollector collector = new FilteredElementCollector(doc);

            collector.OfCategory(BuiltInCategory.OST_Roofs).WherePasses(filterElementsOnLevel);

            foreach (Element element in collector)

            {

 

                RoofBase roof = element as RoofBase;

                ElementId id = roof.Id;

                BuiltInCategory bic = BuiltInCategory.OST_RoofOpening;

                FilteredElementCollector Opening_collector = new FilteredElementCollector(doc);

                Opening_collector.OfClass(typeof(Opening));

                Opening_collector.OfCategory(bic);

                List<Element> openings = new List<Element>();

                if (Opening_collector != null)

                {

                    foreach (Opening e in Opening_collector)

                    {

                        if (e.Host.Id.Equals(id))

                        {

                            Opening myOpening = e as Opening;

                            Boolean a = myOpening.IsRectBoundary;

 

                            if (myOpening.Name == "Dormer Opening")

                            {

                                DormerOpeningsList.Add(myOpening);

                            }

                        }

                    }

                }

 

            } // foreach (Element element in collector)

 

            if (DormerOpeningsList.Count > 0)

            {

                foreach (Opening DormerOpening in DormerOpeningsList)

                {

                    CurveArray profile = new CurveArray();

                    profile = DormerOpening.BoundaryCurves;

                    Element hostElement = DormerOpening.Host;

                    FootPrintRoof roof = hostElement as FootPrintRoof;

                    doc.Delete(DormerOpening.Id);

                    doc.Create.NewOpening(roof, profile, true);

                }

            }

 

This does not work!   doc.Create.NewOpening(roof, profile, true); !?

I would be very grateful if you could give me some feedback for my Issue.

Have a Nice Day.

0 Likes
710 Views
3 Replies
Replies (3)
Message 2 of 4

Aaron.Lu
Autodesk
Autodesk
dear, what do you mean by not working?

did you add transaction to the procedures that modifying revit model?

e.g.
using (Transaction transaction = new Transaction(doc))
{
transaction.Start("re-create opening");
foreach (Opening DormerOpening in DormerOpeningsList)
{
CurveArray profile = new CurveArray();
profile = DormerOpening.BoundaryCurves;
Element hostElement = DormerOpening.Host;
FootPrintRoof roof = hostElement as FootPrintRoof;
doc.Delete(DormerOpening.Id);
doc.Create.NewOpening(roof, profile, true);
}
transaction.Commit();
}


Aaron Lu
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 3 of 4

Anonymous
Not applicable

Dear Aaron,

thanks for your reply , yes of course i add transaction already in the beginning of the class, any way the error is same  

 

 

124.png

As far as I understood we need to create new opening hostElement(I have it), curveArray for the opening (I have it).

 

But create new opening in Roof does not work While with floor work as it should be.

Thanks for your cooperation in advance.

 

0 Likes
Message 4 of 4

Aaron.Lu
Autodesk
Autodesk
Dear, thanks for the update.
After confirmation, I fouond It is an issue.
logged in our system.
(REVIT-70803) NewOpening throws InvalidOperationException: The hostElement is not a floor, ceiling or roof.

thanks for reporting it!


Aaron Lu
Developer Technical Services
Autodesk Developer Network