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) { } } }
Using the Built In parameter checker, it looks like the Type Mark is called "ALL_MODEL_TYPE_MARK" for a wall.
Try using:
hostT.LookupParameter("ALL_MODEL_TYPE_MARK");
Dear Wwydock,
Thank you for your query and very many thanks to Steve for answering your question.
I'll just jump in and add two further suggestions to clean up your code:
Encapsulating a transaction in a `using` statement automagically disposes of it and rolls back if needed:
Never catch all exceptions, only the ones that you really can handle:
Are you really ready to handle the exceptions 'computer on fire', 'building collapsed', and 'fire!'?
If you catch all exceptions, you are preventing the really competent instances from even seeing them.
Cutting the phone lines to the fire brigade and police, so to speak.
You may be endangering your computer and your valued person.
I hope this helps.
Best regards,
Jeremy
Can't find what you're looking for? Ask the community or share your knowledge.