Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone, I am a Civil Engineer who just started to learn programming and RevitAPI
I may be still a bit confused about Revit hierarchy system of Elements (Would be nice if a someone refers me a good resource to understand it)
I've made a similar plugin for Columns and it worked [Check Photo], but when I tried to do so with Walls I get errors [Check Photo of Error]
I wrote down my code
NOTE: All Application and Document is pre-defined and References attached
When I tried to debug the process the Exception appears to be in line: 20
Thank you in advance
TransactionGroup caseWall = new TransactionGroup(doc, "Renaming Wall Types");
{
caseWall.Start();
FilteredElementCollector wallCollector = new FilteredElementCollector(doc);
ElementCategoryFilter wall = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
List<Element> listofwalls = wallCollector.OfClass(typeof(Wall)).WherePasses(wall).ToList();
List<Wall> listofwallsWalls = new List<Wall>();
Transaction trnWall = new Transaction(doc, "Renaming Walls");
{
trnWall.Start();
foreach (Element wt in listofwalls)
{
try
{
if ((wt as Wall).StructuralUsage.ToString() == "Bearing" && (wt as WallType).Kind.ToString() == "Basic")
{
double width = (wt as Wall).Width * 0.30; //Convert to Meters
string actualName = wt.Name;
string newName;
newName = actualName + $"{(width)}";
}
else
{
gm.ShowTask($"WallId Failed: {(wt as Wall).Id}\n Wall Name Failed: {(wt as Wall).Name} ");
}
}
catch (Exception ex)
{
gm.ShowTask(ex.Message);
}
}
trnWall.Commit();
}
caseWall.Assimilate();
}
Solved! Go to Solution.