Set structural floor span direction using c#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I’m working on a C# script to replace the sketch profile of a structural floor element by another Sketch profile by removing all curve elments in the old sketch profile then add new curves as a new sketch profile for the floor. The problem is a warning appears indicating “Structural floor span direction not specified” upon attempting to set the new sketch profile to the floor element. can any one help how can I set the floor span direction programmatically?
Here's below the method I'm using
public static void updateRevitFloors(UIDocument uidoc, Document revitDoc, ForgeTypeId targetUnitConvertor, List<Area2> rhinoAreas)
{
FilteredElementCollector collector = new FilteredElementCollector(revitDoc);
ICollection<Element> revitFloorElements = collector.OfClass(typeof(Floor)).ToElements();
foreach (var rhinoArea in rhinoAreas)
{
Element FloorElment = revitFloorElements.FirstOrDefault(x => x.Id.ToString() == rhinoArea.ID);
if (FloorElment != null)
{
Floor fl = FloorElment as Floor;
Element sketchElement = revitDoc.GetElement(fl.SketchId);
if (sketchElement != null)
{
Sketch sketch = sketchElement as Sketch;
#region get old Profile Curves To be Removed
// Get sketch elements
var sketchEleIds = sketch.GetAllElements();
var oldProfileCurves = new List<ElementId>();
foreach (var i in sketchEleIds)
{
oldProfileCurves.Add(i);
}
#endregion
SketchEditScope sketchEditScope = new SketchEditScope(revitDoc, "Edit Sketch");
sketchEditScope.Start(sketch.Id);
using (Transaction transaction = new Transaction(revitDoc, "Modify sketch"))
{
transaction.Start();
// Delete curves from the current sketch
foreach (var curve in oldProfileCurves)
{
revitDoc.Delete(curve as ElementId);
}
List<Rhino.Geometry.Curve[]> crvList = new List<Rhino.Geometry.Curve[]>();
foreach (Curve i in rhinoArea.outerCurves)
{
crvList.Add(i.DuplicateSegments());
}
foreach (Curve i in rhinoArea.innerCurves)
{
crvList.Add(i.DuplicateSegments());
}
IEnumerable<Rhino.Geometry.Curve> flatCrvList = crvList.SelectMany(x => x);
foreach (var rhinoCrv in flatCrvList)
{
Autodesk.Revit.DB.Curve c = RhinoInside.Revit.Convert.Geometry.GeometryEncoder.ToCurve(rhinoCrv);
revitDoc.Create.NewModelCurve(c, sketch.SketchPlane);
}
fl.SpanDirectionAngle = 90 * Math.PI / 180;
transaction.Commit();
}
sketchEditScope.Commit(new RoomWarningSwallower());
}
}
}
}
Developer Advocacy and Support +