- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I'm a bit out of my comfort zone here. I am creating an addin which involves creating a mass for each instance of room. I cobbled together the code below from examples on other blogs / sites (mostly here). This works but only if the room hasn't got any internal boundaries (holes, islands, etc). If a room has an internal boundary the actual NewExtrution line fails with the error "One of the conditions for the inputs was not satisfied. Consult the documentation for requirements for each argument.". I'm guessing this is because the profile array has more than one profile (like internal boundaries in this case). The boundaries don't overlap though, just some are entirely consumed by others.
Anyone know of a better approach here? Or how to amend the code below to deal with the internal boundaries (holes) in the room?
// Create family doc from template
Autodesk.Revit.DB.Document familyDoc = app.NewFamilyDocument(@"C:\ProgramData\Autodesk\RVT 2013\Family Templates\English\Metric Generic Model.rft");
// Save the new Family - room is Room Element not defined in this sample code
string fileName = @"C:\Temp\" + room.UniqueId.ToString() + ".rfa";
familyDoc.SaveAs(fileName);
Transaction transaction = new Transaction(familyDoc, "RoomToMass");
transaction.Start();
// Get the room boundary
SpatialElementBoundaryOptions opt = new SpatialElementBoundaryOptions();
IList<IList<Autodesk.Revit.DB.BoundarySegment>> segArray = room.GetBoundarySegments(opt);
CurveArray curveArray = new CurveArray();
// Iterate to gather the curve objects
foreach (IList<Autodesk.Revit.DB.BoundarySegment> bSegments in segArray)
{
foreach (Autodesk.Revit.DB.BoundarySegment bSegment in bSegments)
{
curveArray.Append(bSegment.Curve);
}
}
// Origin point and normal point that gives the extrusion direction
XYZ ptOrigin = new XYZ(0, 0, 0);
XYZ ptNormal = new XYZ(0, 0, 1);
// The plane to extrude the mass from
Plane plane = app.Create.NewPlane(ptNormal, ptOrigin);
SketchPlane sketchPlane = familyDoc.FamilyCreate.NewSketchPlane(plane);
// Add the CurveArray to a CurveArrArray
CurveArrArray curveArrArray = new CurveArrArray();
curveArrArray.Append(curveArray);
// Extrude the form 10 feet as test
Extrusion extrusion = familyDoc.FamilyCreate.NewExtrusion(true, curveArrArray, sketchPlane, 10);
transaction.Commit();
familyDoc.Save();
// now need to place the family...
Solved! Go to Solution.
