Get Shared Parameter of Family

Get Shared Parameter of Family

acarpentierNB27W
Contributor Contributor
950 Views
3 Replies
Message 1 of 4

Get Shared Parameter of Family

acarpentierNB27W
Contributor
Contributor

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!

Accepted solutions (1)
951 Views
3 Replies
Replies (3)
Message 2 of 4

Yien_Chao
Advisor
Advisor
Accepted solution

hi

 

instead of checking instances, check the type maybe.

 

 

Message 3 of 4

mhannonQ65N2
Collaborator
Collaborator

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.

0 Likes
Message 4 of 4

mtrawczynski
Explorer
Explorer

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
		}

 

 

0 Likes