Hello, I am currently creating a prototype chatbot safe revit that answers simple questions such as how many wall, how many fixtures etc for the uninitiated. The problem is that I can't get the roof edge information, it tells me there is no roof edge whereas I have one in the capture below. Here the capture is in French the selection is marked "bord de toiture" but roof edges in EN
And I also saw that in revit dsk tools roof edges in BuiltInCategories is "OST_Fascia" so I modified my code accordingly, but nothing helped.
Thanks in advance for your help !
public static class RoofEdgeAnalysis
{
// Initialisez la catégorie BuiltInCategory pour OST_Fascia.
public static readonly BuiltInCategory BuiltInCategories_OST_Fascia = BuiltInCategory.OST_Fascia;
public static string AnalyzeRoofEdges(Document doc)
{
List<RoofEdgeInfo> roofEdgeDetails = GetRoofEdgeDetails(doc);
if (roofEdgeDetails.Count == 0)
{
return "Il n'y a aucun bord de toit dans le projet.";
}
StringBuilder roofEdgeSummary = new StringBuilder();
roofEdgeSummary.AppendLine($"Il y a un total de {roofEdgeDetails.Count} bord(s) de toit dans le projet, réparti(s) comme suit :");
foreach (var roofEdge in roofEdgeDetails)
{
roofEdgeSummary.AppendLine($"- {roofEdge.TypeName}, longueur : {roofEdge.Length:F2} m, hauteur : {roofEdge.Height:F2} m");
}
return roofEdgeSummary.ToString();
}
private static List<RoofEdgeInfo> GetRoofEdgeDetails(Document doc)
{
List<RoofEdgeInfo> roofEdgeDetails = new List<RoofEdgeInfo>();
FilteredElementCollector collector = new FilteredElementCollector(doc)
.OfCategory(BuiltInCategories_OST_Fascia)
.OfClass(typeof(FamilyInstance));
foreach (FamilyInstance element in collector)
{
Parameter lengthParam = element.LookupParameter("Longueur");
Parameter heightParam = element.LookupParameter("Hauteur");
double length = 0;
double height = 0;
if (lengthParam != null && lengthParam.StorageType == StorageType.Double)
{
length = lengthParam.AsDouble();
// Utilisez UnitUtils pour convertir les unités internes de Revit en mètres.
length = UnitUtils.ConvertFromInternalUnits(length, UnitTypeId.Meters);
}
if (heightParam != null && heightParam.StorageType == StorageType.Double)
{
height = heightParam.AsDouble();
// Utilisez UnitUtils pour convertir les unités internes de Revit en mètres.
height = UnitUtils.ConvertFromInternalUnits(height, UnitTypeId.Meters);
}
roofEdgeDetails.Add(new RoofEdgeInfo(element.Name, length, height));
}
return roofEdgeDetails;
}
Solved! Go to Solution.
Link copied