-
Archiving Details
I'm looking for a way to archive details for re-use. This would likely involve somehow exporting all drafting views from a project that have been placed on sheets. Whether they are exported to files, families, or a "holding" project is undetermined at this time. They would need to retain the Sheet/Number combination so the architects could find them easily by referring to printed sheets of past projects. Perhaps this info could be held in a database or perhaps it could be part of a file name or a view name.
This the early stages of my idea and I'm unsure of the API and it's capabilities.
Is it possible for the API to read and import from another file similar to the "Insert from File" function? Does the file need to be open?
Is it possible export a drafting view to a file using API?
Has anyone tackled this problem yet?
-mjm
-
Re: Archiving Details
I haven't had a chance to explore it myself, but 2014 introduced a new Copy/Paste API that sounds well suited to your purposes.
As far as I know, it mimics the functionality of "Insert from File" quite closely.
More info here: http://thebuildingcoder.typepad.com/...assertion.html
-
Re: Archiving Details
Good idea! That is perfect for drafting views. I need to figure out how to rename them but that seems trivial. The next hurdle is detail views. Our practice is to use detail views and draft lines and components over the top. Then we turn the model portion off. So. All i need are the lines, text and detail components. I don't think I can copy those views with this new function. I'm looking for a way to copy all the elements I want into a temporary drafting view and then copy that to the "archive" file. Struggling. Still so new to Revit API and dotNET.
-
Re: Archiving Details
Hope you've made some progress in the last month, but I've got a few more suggestions.
If you want to retrieve elements from a view, you can use a FilteredElementCollector as follows:
Code:
Document doc; //the document you're dealing with
View view; //assuming you've already retrieved the detail view that you're dealing with
ElementMulticategoryFilter filter = new ElementMulticategoryFilter(new List<BuiltInCategory>{BuiltInCategory.OST_Curves, BuiltInCategory.OST_TextNotes, BuiltInCategory.OST_DetailComponents});
FilteredElementCollector coll = new FilteredElementCollector(doc, view.Id).WherePasses(filter);
//Access the elements or the element IDs, you shouldn't need both
var elements = coll.ToElements();
var elementIds = coll.ToElementIds();
Tweak the categories in the ElementMulticategoryFilter to suit your needs.
Once you have retrieved all of the elements that you want, you should be able to use the copy/paste API to copy these to a new view. You can also create the view programmatically if it doesn't already exist. Read the API docs for more info on how to do this.