I tried to create a floor with openings.
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;
}
I tried to create a floor with openings.
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;
}
Here is one discussion from 2013 that discusses a similar issue and indicates that it was not so easy to achieve back then:
That is a long time ago, though, so things may have changed since.
Here is one discussion from 2013 that discusses a similar issue and indicates that it was not so easy to achieve back then:
That is a long time ago, though, so things may have changed since.
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!
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!
Can't find what you're looking for? Ask the community or share your knowledge.