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: 

How to Create a opened floor without using doc.Create.NewOpening method.

2 REPLIES 2
Reply
Message 1 of 3
genosyde
347 Views, 2 Replies

How to Create a opened floor without using doc.Create.NewOpening method.

genosyde
Advocate
Advocate

I tried to create a floor with openings.

genosyde_0-1676355802630.png

 


Instead of creating an opening(used by doc.Create.NewOpening method) when creating a floor,
I want to create a floor with an opening only with a curve through a 'profile'.

I tried to create it with below code,
The creation fails with the error 'The curves do not form a closed contiguous loop'.

Is there a separate order in which the outer curve and the opening curve should be added to the CurveArray?
Or are there other rules?

I wonder if there is a way to create a floor with an opening without using doc.Create.NewOpening method.

 

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {

            var uiApp = commandData.Application;
            var uiDoc = uiApp.ActiveUIDocument;
            var doc = uiDoc.Document;

            var pts = new XYZ[]
            {
                    new XYZ(0, 400, 0),
                    new XYZ(400, 400, 0),
                    new XYZ(400, 0 ,0),
                    new XYZ(0, 0, 0)
            };

            var openingPts = new XYZ[]
            {
                    new XYZ(100, 300, 0),
                    new XYZ(300, 300, 0),
                    new XYZ(300, 100 ,0),
                    new XYZ(100, 100, 0)
            };


            Curve curve = null;
            var curves = new CurveArray();
            curves.Append(Line.CreateBound(pts[1], pts[0]));
            curves.Append(Line.CreateBound(pts[0], pts[3]));
            curves.Append(Line.CreateBound(pts[3], pts[2]));
            curves.Append(Line.CreateBound(pts[2], pts[1]));

            curves.Append(Line.CreateBound(openingPts[3], openingPts[2]));
            curves.Append(Line.CreateBound(openingPts[2], openingPts[1]));
            curves.Append(Line.CreateBound(openingPts[1], openingPts[0]));
            curves.Append(Line.CreateBound(openingPts[0], openingPts[3]));

            using (var tr = new Transaction(doc, "Starting Floor Create"))
            {
                try
                {
                    tr.Start();
                    doc.Create.NewFloor(curves, false);
                    tr.Commit();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return Result.Succeeded;
        }

 

0 Likes

How to Create a opened floor without using doc.Create.NewOpening method.

I tried to create a floor with openings.

genosyde_0-1676355802630.png

 


Instead of creating an opening(used by doc.Create.NewOpening method) when creating a floor,
I want to create a floor with an opening only with a curve through a 'profile'.

I tried to create it with below code,
The creation fails with the error 'The curves do not form a closed contiguous loop'.

Is there a separate order in which the outer curve and the opening curve should be added to the CurveArray?
Or are there other rules?

I wonder if there is a way to create a floor with an opening without using doc.Create.NewOpening method.

 

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {

            var uiApp = commandData.Application;
            var uiDoc = uiApp.ActiveUIDocument;
            var doc = uiDoc.Document;

            var pts = new XYZ[]
            {
                    new XYZ(0, 400, 0),
                    new XYZ(400, 400, 0),
                    new XYZ(400, 0 ,0),
                    new XYZ(0, 0, 0)
            };

            var openingPts = new XYZ[]
            {
                    new XYZ(100, 300, 0),
                    new XYZ(300, 300, 0),
                    new XYZ(300, 100 ,0),
                    new XYZ(100, 100, 0)
            };


            Curve curve = null;
            var curves = new CurveArray();
            curves.Append(Line.CreateBound(pts[1], pts[0]));
            curves.Append(Line.CreateBound(pts[0], pts[3]));
            curves.Append(Line.CreateBound(pts[3], pts[2]));
            curves.Append(Line.CreateBound(pts[2], pts[1]));

            curves.Append(Line.CreateBound(openingPts[3], openingPts[2]));
            curves.Append(Line.CreateBound(openingPts[2], openingPts[1]));
            curves.Append(Line.CreateBound(openingPts[1], openingPts[0]));
            curves.Append(Line.CreateBound(openingPts[0], openingPts[3]));

            using (var tr = new Transaction(doc, "Starting Floor Create"))
            {
                try
                {
                    tr.Start();
                    doc.Create.NewFloor(curves, false);
                    tr.Commit();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return Result.Succeeded;
        }

 

2 REPLIES 2
Message 2 of 3
jeremy_tammik
in reply to: genosyde

jeremy_tammik
Autodesk
Autodesk

Here is one discussion from 2013 that discusses a similar issue and indicates that it was not so easy to achieve back then:

  

https://thebuildingcoder.typepad.com/blog/2013/07/create-a-floor-with-an-opening-or-complex-boundary...

  

That is a long time ago, though, so things may have changed since.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

Here is one discussion from 2013 that discusses a similar issue and indicates that it was not so easy to achieve back then:

  

https://thebuildingcoder.typepad.com/blog/2013/07/create-a-floor-with-an-opening-or-complex-boundary...

  

That is a long time ago, though, so things may have changed since.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 3
jeremy_tammik
in reply to: genosyde

jeremy_tammik
Autodesk
Autodesk

Here is the explanation of the new floor creation API:

 

  

I am pretty sure that the IList<CurveLoop> profile argument enables creation of a floor with holes.

  

Maybe you do need to revert the negative hole area loop orientations, just as you suggest.

  

Have you searched the Revit SDK samples for Floor.Create? I did, and see 26 matches across 6 files. Maybe one of them will help?

  

Please let us know how you end up solving this.

  

Thank you!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

Here is the explanation of the new floor creation API:

 

  

I am pretty sure that the IList<CurveLoop> profile argument enables creation of a floor with holes.

  

Maybe you do need to revert the negative hole area loop orientations, just as you suggest.

  

Have you searched the Revit SDK samples for Floor.Create? I did, and see 26 matches across 6 files. Maybe one of them will help?

  

Please let us know how you end up solving this.

  

Thank you!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open

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

Post to forums  

Autodesk Design & Make Report