Message 1 of 3
Push Walltype to doors
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been working on this macro for a while, we are looking for a way to have our door schedule to include the wall type(Type Mark parameter). I have attached where I am at. I had no issues with pulling an instance parameter in the wall to the instance parameter in the door, but I was not having much luck with the type parameter in the wall. The only area I am unsure of is if I am accessing the type parameters from the wall correctly.
public void WalltoDoor2()
{
Document doc = this.ActiveUIDocument.Document;
ElementCategoryFilter hostFilter = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
ElementCategoryFilter hostedFilter = new ElementCategoryFilter(BuiltInCategory.OST_Doors);
string parameterName = "Type Mark";
string parameterName2 = "Wall Type";
using (Transaction t = new Transaction(doc, "Set hosted parameters"))
{
try
{
t.Start();
foreach (Element host in new FilteredElementCollector(doc).WherePasses(hostFilter))
{
if(host !=null)
{
Element hostT=host.Document.GetElement(host.GetTypeId());
Parameter paramHost = hostT.LookupParameter(parameterName);
foreach (Element hosted in new FilteredElementCollector(doc)
.WherePasses(hostedFilter).OfClass(typeof(FamilyInstance))
.Cast<FamilyInstance>().Where(q => q.Host.Id == host.Id))
{
if(hosted !=null)
{
hosted.LookupParameter(parameterName2).Set(paramHost.AsString());
}
}
}
}
t.Commit();
}
catch(Exception)
{
}
}
}