Hi everyone,
I updated an already existing family and added a shared parameter to it.
Now I need to make sure that the new updated family is loaded into my projects prior to running some commands.
So to do so, my workflow is to check if the family is loaded into the project, and if it is check if the specific shared parameter exists (so that I don't try to use the old family which would cause a crash).
However, shared parameters can only be found when I snoop a family instance, and not the family itself which makes it tricky when that family is loaded but not actively in use. And I can't realistically place and delete a new family instance every time I want to check if the latest family is loaded in the project.
So how do I check the shared parameter of a family without any family instance existing in the project?
Thanks!
Solved! Go to Solution.
Solved by Yien_Chao. Go to Solution.
You could create a Version parameter as a type parameter (or repurpose an existing built-in parameter such as Description) and check that parameter on a family type.
If you don't have family instance how would you do it manually without creating an instance? You'd edit a family, open family manager and check if parameter is listed there:
public void CheckParameter()
{
Guid parameterGuid = new Guid("74faeb59-2f2b-49ca-b383-358a9b736c1e"); //search by parameter guid
Document doc = ActiveUIDocument.Document;
Family family = doc.GetElement(new ElementId(2892469)) as Family; //you need to search family/families in document yourself
Document familyDocument = doc.EditFamily(family);
FamilyManager fmgr = familyDocument.FamilyManager;
bool parameterExists = false;
foreach(FamilyParameter fp in fmgr.Parameters) if(fp.IsShared && fp.GUID == parameterGuid) parameterExists = true;
TaskDialog.Show("result", parameterExists.ToString());
familyDocument.Close(false); //remember to close family
}
Can't find what you're looking for? Ask the community or share your knowledge.