@Jbenoit44 suggested a tool to push a param from any Host (inc. Lev. and ref pl.) to any Hosted & reverse. Doors windows face base fam Parts etc
This implementation drives parameters from Hosts to their Family Instances.
public void ParametersFromHost()
{
Document doc = this.ActiveUIDocument.Document;
ElementCategoryFilter hostFilter = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
ElementCategoryFilter hostedFilter = new ElementCategoryFilter(BuiltInCategory.OST_Doors);
string parameterName = "Rating";
using (Transaction t = new Transaction(doc, "Set hosted parameters"))
{
t.Start();
foreach (Element host in new FilteredElementCollector(doc).WherePasses(hostFilter))
{
Parameter paramHost = host.get_Parameter(parameterName);
foreach (Element hosted in new FilteredElementCollector(doc)
.WherePasses(hostedFilter)
.OfClass(typeof(FamilyInstance))
.Cast<FamilyInstance>()
.Where(q => q.Host.Id == host.Id))
{
if (paramHost.StorageType == StorageType.String)
hosted.get_Parameter(parameterName).Set(paramHost.AsString());
else if (paramHost.StorageType == StorageType.Double)
hosted.get_Parameter(parameterName).Set(paramHost.AsDouble());
else if (paramHost.StorageType == StorageType.Integer)
hosted.get_Parameter(parameterName).Set(paramHost.AsInteger());
}
}
t.Commit();
}
}
Nice feature Harry. Additionally, would it be possible to compare the rating between 2 rooms and assign the highest one to the wall in between? (supposing we address the original rating to rooms iso to the walls)
Hi Eric,
Glad you liked it. What you suggest is certainly doable.
Harry
This routine is great, I can see a lot of uses for it. I found this recently and I was looking into using this for Revit 2015. Does this routine allow you to Transfer type parameter to an instance parameter? Also I was looking to use this routine to transfer a value from a project parameter on levels to the same project parameter on views. I substituted ost_levels and ost_views for the hosting filters. I am able to build the solution, however it is not able to transfer the values. I am using the wrong method for filtering?
Hi William – Thanks for your comment. All that you suggest should be doable. Working with levels and views should be fine. Have you stepped through the code to see if you are getting the expected values and execution?