Dear reader,
Currently I am trying to export the contents of a scope box to a new file, this gives problems concerning view-dependent elements.
The idea is: I have a file with a large amount of options for the components of a house in the center of the file. I have a GUI that allows the user to select their desired configuration and the file updates the center house by switching elements around. The now updated house is exported to a separate file. I do this by selecting everything inside the scopebox that surrounds the house.
The view-independent elements are copied over without a problem with
FilteredElementCollector allCollector = new FilteredElementCollector(doc).WhereElementIsNotElementType().WherePasses(scopeBoxFilter);
ICollection<ElementId> viewIndependentIds = allCollector.WhereElementIsViewIndependent().ToElementIds();
ElementTransformUtils.CopyElements(doc, viewIndependentIds, newDoc, Transform.Identity, copyOptions);
However, for view-dependent elements I figured I need the other version of CopyElements that copies from view to view. Therefore I seperately copy those over per view, where I first find the correct views in the main file, and in the destination file (That destination file is created through a template, which in turn was created by simply deleting all model elements from the main file, so it retains all views etc.):
ElementTransformUtils.CopyElements(view, finalIds, otherView, null, copyOptions);
I've been working on it for days but I keep getting errors there, and I feel like for example Attached Detail Groups could pose a problem here. I just really want to get things like 2d elements that show relevant information about the house in the 2d views in the new file.
My question is: am I using the right approach here to achieve my goal, or am I going about it wrong?