Unable to stretch with the grip a fabricarea done with the API in GUI without editing the sketch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I have a small issue when I want to create a fabricarea with the API.
The curves of the sketch are not detected as joined so I can't stretch it with the grip I have the error message the loop is not closed. I tried many stuffs without any success
Find a simple example below with a 2 feet square from the hit point of the selected floor
thanks for your help
// Comon statements
UIApplication uiApp = commandData.Application;
UIDocument uiDoc = uiApp.ActiveUIDocument;
Document doc = uiDoc.Document;
Reference reference;
try
{
reference = uiDoc.Selection.PickObject(ObjectType.Element, new CatSelectionFilter(BuiltInCategory.OST_Floors, doc));
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
return Autodesk.Revit.UI.Result.Cancelled;
}
XYZ xyz = reference.GlobalPoint;
XYZ xyz0 = new XYZ(xyz.X, xyz.Y, 0);
Floor floor = doc.GetElement(reference) as Floor;
CurveLoop curveLoop = new CurveLoop();
Line curve1 = Line.CreateBound(xyz0, xyz0 + new XYZ(0, 2, 0));
curveLoop.Append(curve1);
Line curve2 = Line.CreateBound(xyz0 + new XYZ(0, 2, 0), xyz0 + new XYZ(2, 2, 0));
curveLoop.Append(curve2);
Line curve3 = Line.CreateBound(xyz0 + new XYZ(2, 2, 0), xyz0 + new XYZ(2, 0, 0));
curveLoop.Append(curve3);
Line curve4 = Line.CreateBound(xyz0 + new XYZ(2, 0, 0), xyz0);
curveLoop.Append(curve4);
IList<CurveLoop> loop = new List<CurveLoop>();
loop.Add(curveLoop);
IList<FabricAreaType> listOfFabricAreaType = new FilteredElementCollector(doc)
.OfClass(typeof(FabricAreaType)).Cast<FabricAreaType>()
.ToList();
IList<Element> listOfFabricSheetType = new FilteredElementCollector(doc)
.OfClass(typeof(FabricSheetType))
.ToList();
FabricArea fabricarea;
using (Transaction ts = new Transaction(doc, "create fabricsheetarea"))
{
ts.Start();
fabricarea = FabricArea.Create(doc, floor, loop, XYZ.BasisY, xyz0, listOfFabricAreaType.First().Id, listOfFabricSheetType.First().Id);
ts.Commit();
}
return Result.Succeeded;