Missing Connection Between Nested Shared Families And Their Hosts Inside Projects

Missing Connection Between Nested Shared Families And Their Hosts Inside Projects

floretti
Advocate Advocate
326 Views
7 Replies
Message 1 of 8

Missing Connection Between Nested Shared Families And Their Hosts Inside Projects

floretti
Advocate
Advocate

Hi all, I created a purge command which doesn't delete unused family types and instead only deletes entirely unused families. One side effect of my command is that it is deleting nested shared families from unused family types, which cannot happen. The family types themselves are not deleted though, just specific nested families they rely on, which render those family types unusable.

 

Example: an office chair which has a type A (without armrests) and a type B (with armrests as nested shared families). If I only use type A in my project, my command will purge the armrests family from the project, which is not something I'd like to happen.

 

I'm struggling to find a connection between these unused shared families and their used hosts inside projects. I've tried to use GetSubcomponentIds() but I need FamilyInstances to be able to use it, which is not the case if the families were never placed.

 

I've also seen this post but opening every family in the project to collect all the nested parts would take too long.

 

Any suggestions and ideas would be greatly appreciated. Thanks for reading.

0 Likes
327 Views
7 Replies
Replies (7)
Message 2 of 8

jeremy_tammik
Alumni
Alumni

Is your difficulty possibly related to this recent discussion?

 

https://forums.autodesk.com/t5/revit-api-forum/nested-revit-linkinstance-get-parent-or-children/m-p/...

 

The Revit development team just identified a missing piece on the API coverage there...

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 8

jeremy_tammik
Alumni
Alumni

By the way, talking about the purge command, The Building Coder published something on that a month back:

 

https://thebuildingcoder.typepad.com/blog/2022/02/purge-unused-and-etransmit-for-da4r.html

 

In a comment on that, Emiliano Capasso pointed out his successful use of the built-in Revit eTransmit assembly to call its purge functionality:

 

https://www.linkedin.com/pulse/why-revit-purge-command-act-love-via-api-emiliano-capasso

 

Maybe that will be of use in your case as well?

   

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 4 of 8

floretti
Advocate
Advocate

It's similar but on a family level and not exactly related to links but to loaded shared nested families.

0 Likes
Message 5 of 8

floretti
Advocate
Advocate

Thanks, @jeremy_tammik. I can definitely use that PurgeUnused() method but it wouldn't achieve what I'm trying to accomplish here. In our business it's bad practice to delete unused family types when other types inside the same families are in use.

0 Likes
Message 6 of 8

mhannonQ65N2
Collaborator
Collaborator

Have you tried using GetDependentElements()? You can even browse its results directly within Revit Lookup.

0 Likes
Message 7 of 8

floretti
Advocate
Advocate

@mhannonQ65N2 Great point, I haven't but I'll definitely give it a go. Thank you.

0 Likes
Message 8 of 8

floretti
Advocate
Advocate

I tried the below but it only returned itself. I'm not sure I'm using the right filter though.

 

var allElem = new FilteredElementCollector(doc).
					OfClass(typeof(Family)).
					WhereElementIsViewIndependent().
					ToElements();

foreach (var elem in allElem)
{
	if (elem.Name == "CC_ServiceDesk_3Express_V3")
	{
		var dependentIds = elem.GetDependentElements(new ElementClassFilter(typeof(Family)));
		console.ShowMessage(dependentIds.Count.ToString());

		foreach (var depId in dependentIds)
		{
			console.ShowMessage(doc.GetElement(depId).Name);
		}
	}
}

 

The screenshot below shows what I have inside the family, which I'd love to get from the project as dependent elements. Note that apart from the annotation symbols, only one of them is not shared and won't come up in the project.

 

FabioLorettiOliveira_0-1647994374008.png

 

0 Likes