José Alberto Torres Jaraute has been working on an add-in tool to protect the intellectual property built into a complex hierarchy of nested family instances by replacing them with a flatter and simpler hierarchy, yet retaining all the relevant non-confidential custom data.
Basically, his tool also enables location of overlapping elements and duplicates elimination.
In the course of this work, Alberto raised a number of questions in the Revit API discussion forum:
These discussions led to a fruitful conclusion, and Alberto now very kindly reports on the successful project completion:
I use the term SET
to denote all the FamilyInstance
children of a FamilyInstance
with multiple sub-instances.
I implemented the following procedure to deal with a SET
:
SET
.SET
: Phases, Manufacturer, custom data, etc.FamilyInstance
daughters with GetSubComponentIds
to a collection of element ids.FamilyInstance
.GeometryInstance
and extract the insertion point and BasisX
to determine its rotation.SketchPlane
using this data and the normal vector it defines.FamilySymbol
, Mirrored
and FacingFlipped
properties.FamilyInstance
into the new SketchPlane
taking the insertion point and rotation of the original family into account:doc.Create.NewFamilyInstance( point, symbol, xvec, sketchPlane, StructuralType.NonStructural );
Mirrored
or FacingFlipped
set.true
, calculate and apply the corresponding mirroring, calculating it from the work plane, the reference plane or the corresponding reference line.SET
and recreate them as DirectShape
elements, using the name of the family instance with an auto-numbering suffix.Group
with the name of the SET
plus an auto-numbering suffix.I also implemented an event to cancel the warnings displayed when inserting a new family instance at a point where another one already exists. It is removed again after terminating this process.
Unfortunately, I cannot share the complete code for confidentiality reasons.
Thank you very much for the fruitful discussions!
Many thanks to Alberto for sharing his experience and workflow!
By the way, in case you are interested in flattening and simplifying, you might also want to check out the more radical approach
of flattening all elements to DirectShape
.