Cut Geometry via the API

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a series of FamilyInstances based on the Generic Model template, positioned in the drawing. Currently they overlap / clash (deliberately).
If I select Cut Geometry from the ribbon, select one (say, the sloping rail) and then the other (an upright), it correctly cuts the upright clean through the rail, so they no longer clash. So it seems my elements as they stand qualify for this type of operation.
However, I am unable to get this to work through code.
I tried SolidSolidCutUtils but it threw an exception, stating that they didn't qualify (possibly because I did not extract solids from the geometry?). I passed the Element representing the FamilyInstance as a whole.
I also tried using InstanceVoidCutUtils. Although that didn't throw an exception, it didn't do anything either. My family is not marked as 'Cut with voids on load' - but if that were necessary, surely Cut Geometry from the ribbon would not work?
Any suggestions on how to do this? BooleanOperationUtils does not seem to be of any use because one method returns an in-memory solid and I have no known way of setting that result as the new solid for the element (it specifically says it cannot be added to the database), and the other that modifies directly says it can't be a solid directly from an element.
If extracting the solids from the geometry (I saw a sample on how) is the right way to use SolidSolidCutUtils, how can I get the resulting solids back into the element to update it to the 'cut' version?
The attached image shows the arrangement of elements, and the one on the right is one cut by me via Revit's interface. That's what I want to do through code.