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: 

Get Shared Parameter of Family

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
acarpentierNB27W
375 Views, 3 Replies

Get Shared Parameter of Family

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!

3 REPLIES 3
Message 2 of 4

hi

 

instead of checking instances, check the type maybe.

 

 

Message 3 of 4

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.

Message 4 of 4

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.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community