Loop through elements and set parameter

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
i wanna loop through elements of a chosen Family and set parameters
i have following code, but i get error i can't explain.
Can please somebody help? Thank in advanced.
//Get application and document objects
UIApplication uiApp = commandData.Application;
Document doc = uiApp.ActiveUIDocument.Document;
//Create collector with the filter Family
FilteredElementCollector collector = new FilteredElementCollector(doc);
collector = collector.OfClass(typeof(Family));
//Get ID from te family with linq-code
var query = from element in collector where element.Name.StartsWith("300_32_ISR_wandopening_houten_binnenkozijn_60WBDBO") select element;
List<Element> fams = query.ToList<Element>();
ElementId famId = fams[0].Id;
//Create FamilySymbolFilter by FamilyID
FamilySymbolFilter filter = new FamilySymbolFilter(famId);
//Create collector filtered by FamilyID and put familysymbols in ICollection : dus alle familytypen in collector plaatsen.
collector = new FilteredElementCollector(doc);
ICollection<Element> Familysymbols = collector.WherePasses(filter).ToElements();
//Create string for testing results
string prompt = "alle deurtypes van familiy 300_32_ISR_wandopening_houten_binnenkozijn_60WBDBO: ";
//Create list to put in FamilySymbol-ID's : dus lijst creeren om alle ID's van de familytypen erin te plaatsen.
List<ElementId> lstFamilySymbolIDs = new List<ElementId>();
//---> Get all FamilySymbol-ID's and put them in a list. : dus alle ID's in de lijst stoppen.
foreach (Element el in Familysymbols)
{
prompt += "\n";
prompt += el.Name + "\n";
prompt += el.Id + "\n";
lstFamilySymbolIDs.Add(el.Id);
Parameter p = el.LookupParameter("Finish");
p.Set("test-waarde");
//el.LookupParameter("MyParam").Set("TestValue");
el.get_Parameter("Finish").Set("test-waarde");