Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

collecting Instance parameters of a Family

7 REPLIES 7
Reply
Message 1 of 8
stingers80-cgarchitect
440 Views, 7 Replies

collecting Instance parameters of a Family

Hi everybody!

 

I understand from some of the threads here that using FiteredElementCollector with "TYPEOF(FAMILYINSTANCE)" will

collect instance parameters of family ONLY if they are present in the model.

I need to collect these properties for Families that are present in Project but I haven't used them in the model.

 

this code(part of a method that receives a Family f) returns nothing because there are no instances of family in the model yet:

 

ElementClassFilter instancecollector = new ElementClassFilter(typeof(FamilyInstance));
            FilteredElementCollector familyinstance = new FilteredElementCollector(doc);
            List<FamilyInstance> finstance = familyinstance.WherePasses(instancecollector)
                .Cast<FamilyInstance>()
                .Where(x => x.Symbol.Family.Name.Equals(f.Name))
                .ToList();

 

This is part of a cleanup I am doing on office's families.

How can I achieve this?

 

7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: stingers80-cgarchitect

Hi there,

Actually this is correct. FamilyInstance means there is an INSTANCE of family in the project. If you have specified FamilyType of FamilySymbol loaded in the project, you will not get collection of FamilyInstances, until you please at least one of the project.

Hope that helps,

Luki

Message 3 of 8
stingers80-cgarchitect
in reply to: Anonymous

Thanks for reply.

I'm wondering how I can collect all those parameters.

I can see all of them in 'Revit Lookup' under FamilyInstance and I am not using those families in the model.

How can Revit lookup collect them since it's an Add-in as well?

Is there another way?

Message 4 of 8

Hi @stingers80-cgarchitect ,

I think instance parameters are accessible only for the elements that are placed inside the project.

You Can't access the instance parameters before placing the element.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 5 of 8

Hi @stingers80-cgarchitect ,

This will help you to collect instance parameter.You have to open Editfamily to access the instance parameter.

 

FamilyParameterSet instanceParameter = new FamilyParameterSet();
                  FilteredElementCollector coll = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).WhereElementIsElementType();
                  foreach(Element e in coll)
                  {
                    FamilySymbol FS = e as FamilySymbol;
                    if(FS.Name.Contains("Your Family Symbol Name"))
                    {
                        Family f = FS.Family;
                        Document famdoc=doc.EditFamily(f);
                        if(famdoc!=null)
                        {
                            FamilyManager FM = famdoc.FamilyManager;
                            if(FM!=null)
                            {
                                foreach(FamilyParameter fp in FM.Parameters)
                                {
                                    if(fp.IsInstance)
                                    {
                                        string parameterName = fp.Definition.Name;
                                        instanceParameter.Insert(fp);
                                    }
                                }
                            }
                        }                     
                    }
                  }

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 6 of 8

Thanks for reply @naveen.kumar.t 

I haven't tried the code yet. But opening families one by one is my last resort. there are more than 100 of them.

then I have to reinsert them in the project after cleaning up parameters.

my question is how come Revit Lookup can collect all these parameters?

Message 7 of 8

Could you provide a little more information on what you are wanting to do with the Parameters / Families / Instances once you have them? You mention cleaning them up, but is that values only, or editing / removing the actual parameters? If it is the later, the only way to do that is in the Family editor so you would be needing to do that anyway. I think a little more information could help us get you to a solution.

Message 8 of 8

Hi @Sean_Page 

I am trying to collect all shared parameters under each family.

Somebody at our office had the bright idea that shared parameters need to be updated/recreated when going from revit 2018 to 2019.

So now, I have duplicates of shared parameters which have same name but not same GUID.

All these scattered in some families.

more than that, some of them are assigned to 'Type' and others to 'Instance' in the family.

I need to collect all shared parameters and hopefully automatically remove odd ones.

 

In a word, for now I just need to have a clear picture of all shared parameters in families.

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report