Rebar host face numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone
In my company we make a lot of prestressed elements.
The rebars in these elements are not governed by their cover, but by the prestressed strands going through the beam which they are tied to.
Since Revit rebar is controlled by the concrete host covers we have set up some calculations on our strand patterns that can tell the user what to input as the cover on each face of the beam. (picture 1) in order to get the correct size to match the strandpattern. This workflow works great, but takes a long time for the users to perform.
if i click edit constraints on a specific rebar => click on a section of a bar => and hover my mouse over the sections constraint surface i get a face number. (picture 2 and 3)
This face number could be super useful for saving and applying cover settings, but i am unable to find the face number via the API. I can get the face reference, and set new cover types to those faces, but i am doing it all without knowing which face i am interacting with.
The ID number is just the id of the host. and i cant find the face number on the geometry object.
I tryed getting a collection of faces and then using the face number as index but that didnt work.
the code below will set all faces in the element to the cover "aggressiv" but i want to store a face number and the cover setting, and then reapply it to other beams in other projects.
Any help in finding the face number is greatly appriciated.
using System; using System.Collections.Generic; using System.Linq; using System.IO; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.DB.Structure; using EventLog = CRH.Core.EventLog.EventLog; using CRH.Functions; namespace CRH.Functions { [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] class RebarSniffer : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Document doc = commandData.Application.ActiveUIDocument.Document; if (doc.IsFamilyDocument) { TaskDialog.Show("Error", "This is a family document"); return Result.Cancelled; } FilteredElementCollector fecRebar = new FilteredElementCollector(doc) .OfCategory(BuiltInCategory.OST_Rebar) .OfClass(typeof(Rebar)); Rebar rebarInstance = (Rebar)fecRebar.FirstElement(); List<Reference> references = new List<Reference>(); ElementId host = rebarInstance.GetHostId(); FamilyInstance beam = (FamilyInstance)doc.GetElement(host); Options options = new Options(); options.ComputeReferences = true; options.IncludeNonVisibleObjects = true; GeometryElement geometryElement = beam.get_Geometry(options); foreach (GeometryObject geoObj in geometryElement) { if (geoObj is Solid) { Solid solid = (Solid)geoObj; if (solid.Faces.Size > 1) { foreach (Face face in solid.Faces) { //foreach (Face face in faceArray) { references.Add(face.Reference); } } } } } RebarHostData rebarHostData = RebarHostData.GetRebarHostData(beam); FilteredElementCollector fecCoverTypes = new FilteredElementCollector(doc) .OfCategory(BuiltInCategory.OST_CoverType); RebarCoverType cover = null; foreach (RebarCoverType rebarCoverType in fecCoverTypes) { if (rebarCoverType.Name.Equals("Aggressiv")) { cover = rebarCoverType; break; } } using (Transaction t = new Transaction(doc, "Setting rebar")) { t.Start(); string surface = ":SURFACE"; List<string> guids = new List<string>(); foreach (Reference reference in references) { //string MaybeFaceNumber = reference.ConvertToStableRepresentation(doc); //// a5ab46d4-bff6-4c2f-9545-93b69f55c39f-00150444:22:SURFACE //if (MaybeFaceNumber.EndsWith("22" + surface) || MaybeFaceNumber.EndsWith("26" + surface) || MaybeFaceNumber.EndsWith("34" + surface) || MaybeFaceNumber.EndsWith("30" + surface)) { rebarHostData.SetCoverType(reference, cover); } } t.Commit(); } return Result.Succeeded; } } }