Can't create floor with hole

Can't create floor with hole

Sydra7
Contributor Contributor
1,253 Views
2 Replies
Message 1 of 3

Can't create floor with hole

Sydra7
Contributor
Contributor

If i draw curves  (with mouse/hand) for floor with hole in revit, the program can make the floor from them. The NewFloor api function can't make the same ... why?

Sample code:

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
try
{
var document = commandData.Application.ActiveUIDocument.Document;

 

Transaction transaction = new Transaction(document, "Create Floor");
transaction.Start();

 

var points1 = new List<XYZ>() //for outer contour
{
new XYZ(8.0, 0.0, 0.0),
new XYZ(0.0, 8.0, 0.0),
new XYZ(0.0, 0.0, 0.0)
};

var curves = new CurveArray();
curves.Insert(document.Application.Create.NewLine(points1[0], points1[1], true), 0);
curves.Insert(document.Application.Create.NewLine(points1[1], points1[2], true), 1);
curves.Insert(document.Application.Create.NewLine(points1[2], points1[0], true), 2);

 

var points2 = new List<XYZ>() //for hole
{
new XYZ(4.0, 1.5, 0.0),
new XYZ(1.5, 4.0, 0.0),
new XYZ(1.5, 1.5, 0.0)
};

curves.Insert(document.Application.Create.NewLine(points2[0], points2[1], true), 3);
curves.Insert(document.Application.Create.NewLine(points2[1], points2[2], true), 4);
curves.Insert(document.Application.Create.NewLine(points2[2], points2[0], true), 5);

 

var floorTypes = new FilteredElementCollector(document).OfClass(typeof(FloorType));
var floorType = floorTypes.ToList()[0] as FloorType;

 

var levels = new FilteredElementCollector(document).OfClass(typeof(Level));
var level = levels.ToList()[0] as Level;

 

var floor = document.Create.NewFloor(curves, floorType, level, true);

 

transaction.Commit();
}
catch
{
return Result.Failed;
}

return Result.Succeeded;
}

Error message:
"Can't make Extrusion."

How can i create floor with holes?

(I use Revit 2013 API)

Regards
David Schmidt

0 Likes
Accepted solutions (1)
1,254 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear David,

 

Yes, that is a known  issue.

 

Please see the following discussions on The Building Coder:

 

http://thebuildingcoder.typepad.com/blog/2009/05/hole-in-a-floor.html

 

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

 

As you see, it can be worked around. Sorry that it is not more straighforward, as you had initially hoped.

 

Cheers,

 

Jeremy



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

0 Likes
Message 3 of 3

Sydra7
Contributor
Contributor

Thanks for that! 🙂

Have a nice day!

0 Likes