some buddy
2013-05-17, 07:02 PM
Hi,
I am faced with two situations described below.
I have a project where I need to click on an element (family) inserted in a Revit legend (the family could or could not be used (inserted/instantiated) in the project (model), and then list the parameters attached to that element.
I know how to retrieve FamilyInstance, FamilySymbol and Family parameters from a family which is used (inserted/instantiated) in the project (model):
ElementClassFilter FamilyInstanceFilter = new ElementClassFilter(typeof(FamilyInstance));
FilteredElementCollector FamilyInstanceCollector = new FilteredElementCollector(dbDoc);
ICollection<Element> AllFamilyInstances = FamilyInstanceCollector.WherePasses(FamilyInstanceFilter).ToElements();
// Iterate through all FamilyInstances
foreach (FamilyInstance FamInst in AllFamilyInstances)
{
Fam = FamInst.Family;
FamSymb = FamInst.Symbol;
// Family parameters from Family
foreach (Parameter FamParam in Fam.Parameters)
{
string ParamName = FamParam.Definition.Name;
}
// Symbol parameters from the inserted symbol
foreach (Parameter SymbParam in FamSymb.Parameters)
{
string ParamName = SymbParam.Definition.Name;
}
// Instance parameters from FamilyInstance
foreach (Parameter FamInstParam in FamInst.Parameters)
{
string ParamName = FamInstParam.Definition.Name;
}
}
On the other hand, I know that it IS possible to assign instance parameters to a family in edit mode, and even if the family is not used in the project afterwards, these instance parameters "live" in that family, but I don't know how to retrieve these instance parameters from a family which is NOT used (inserted/instantiated) in the project:
Autodesk.Revit.DB.FilteredElementCollector FilteredCollector = new Autodesk.Revit.DB.FilteredElementCollector(dbDoc);
ICollection<Autodesk.Revit.DB.Element> FamilyCollection = FilteredCollector.OfClass(typeof(Autodesk.Revit.DB.Family)).ToElements();
// Iterate through all loaded Families
foreach (Family ColFam in FamilyCollection)
// Family parameters from Family
foreach (Parameter FamParam in ColFam.Parameters)
string ParamName = FamParam.Definition.Name;
}
// Iterate through all family symbols of the curent family (because no one is inserted in the project)
// They should have all the same parameters, but I parse all of them just for the sake of it.
foreach (FamilySymbol FamSymb in ColFam.Symbols)
{
FamilySymbol NewSymbol = FamSymb;
// Symbol parameters of the currently iterated symbol
foreach (Parameter SymbParam in NewSymbol.Parameters)
{
string ParamName = SymbParam.Definition.Name;
}
}
// Instance parameters from Family
// I want to access the instance parameters defined in the
// family editor, I kow they are there, I've created them, but...
// ==================================
// ### I DON'T KNOW HOW TO DO IT! ###
// ==================================
}
Could somebody help, please ?
TIA
Budy :?
I am faced with two situations described below.
I have a project where I need to click on an element (family) inserted in a Revit legend (the family could or could not be used (inserted/instantiated) in the project (model), and then list the parameters attached to that element.
I know how to retrieve FamilyInstance, FamilySymbol and Family parameters from a family which is used (inserted/instantiated) in the project (model):
ElementClassFilter FamilyInstanceFilter = new ElementClassFilter(typeof(FamilyInstance));
FilteredElementCollector FamilyInstanceCollector = new FilteredElementCollector(dbDoc);
ICollection<Element> AllFamilyInstances = FamilyInstanceCollector.WherePasses(FamilyInstanceFilter).ToElements();
// Iterate through all FamilyInstances
foreach (FamilyInstance FamInst in AllFamilyInstances)
{
Fam = FamInst.Family;
FamSymb = FamInst.Symbol;
// Family parameters from Family
foreach (Parameter FamParam in Fam.Parameters)
{
string ParamName = FamParam.Definition.Name;
}
// Symbol parameters from the inserted symbol
foreach (Parameter SymbParam in FamSymb.Parameters)
{
string ParamName = SymbParam.Definition.Name;
}
// Instance parameters from FamilyInstance
foreach (Parameter FamInstParam in FamInst.Parameters)
{
string ParamName = FamInstParam.Definition.Name;
}
}
On the other hand, I know that it IS possible to assign instance parameters to a family in edit mode, and even if the family is not used in the project afterwards, these instance parameters "live" in that family, but I don't know how to retrieve these instance parameters from a family which is NOT used (inserted/instantiated) in the project:
Autodesk.Revit.DB.FilteredElementCollector FilteredCollector = new Autodesk.Revit.DB.FilteredElementCollector(dbDoc);
ICollection<Autodesk.Revit.DB.Element> FamilyCollection = FilteredCollector.OfClass(typeof(Autodesk.Revit.DB.Family)).ToElements();
// Iterate through all loaded Families
foreach (Family ColFam in FamilyCollection)
// Family parameters from Family
foreach (Parameter FamParam in ColFam.Parameters)
string ParamName = FamParam.Definition.Name;
}
// Iterate through all family symbols of the curent family (because no one is inserted in the project)
// They should have all the same parameters, but I parse all of them just for the sake of it.
foreach (FamilySymbol FamSymb in ColFam.Symbols)
{
FamilySymbol NewSymbol = FamSymb;
// Symbol parameters of the currently iterated symbol
foreach (Parameter SymbParam in NewSymbol.Parameters)
{
string ParamName = SymbParam.Definition.Name;
}
}
// Instance parameters from Family
// I want to access the instance parameters defined in the
// family editor, I kow they are there, I've created them, but...
// ==================================
// ### I DON'T KNOW HOW TO DO IT! ###
// ==================================
}
Could somebody help, please ?
TIA
Budy :?