Message 1 of 4

Not applicable
06-20-2018
01:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am using Revit 2015. I wanted to create a simple macro which would change the value of 3 parameters in every family type. Unfortunately it is not working as it should, and instead only changes the value of the first parameter on the list. The while loop of the code iterates through all the types in the set, but changes only the values of the first one.
I am quite new to the Revit API, so I ask for your kind help in resolving my problem or guiding me to possible solution. Thank you very much in advance.
public void ParameterChange() { Document doc = this.Document; using(Transaction tr = new Transaction (doc, "RenameParameter")){ tr.Start(); string types = "Types:"; FamilyManager familyManager = doc.FamilyManager; FamilyTypeSet familyTypes = familyManager.Types; FamilyTypeSetIterator familyTypesItor = familyTypes.ForwardIterator(); familyTypesItor.Reset(); while(familyTypesItor.MoveNext()){ FamilyType familyType = familyTypesItor.Current as FamilyType; FamilyParameter par1 = familyManager.get_Parameter("Param1"); FamilyParameter par2 = familyManager.get_Parameter("Param2"); FamilyParameter par3 = familyManager.get_Parameter("Param3"); familyManager.Set(par1, "value1"); familyManager.Set(par2, "value2"); familyManager.Set(par3, 10); types += "\n" + familyType.Name; } tr.Commit(); TaskDialog.Show("Revit",types); } }
Solved! Go to Solution.