Duplicate scope box across models

4 Dec

#AU2013 Wish 1 Granted! | Boost Your BIM – making Revit even better.

Open the source file (in this case named “scope boxes.rvt”), then activate the target document and run the macro.

public void CopyScopeBoxBtwDoc()
    Document doc = this.ActiveUIDocument.Document;
    Application app = this.Application;

    string filename = "scope boxes.rvt";

    Document sourceDoc = app.Documents.Cast<Document>().FirstOrDefault(q => q.PathName.EndsWith(filename));

    if (sourceDoc == null)
        TaskDialog.Show("Error", "No open document named " + filename);

    ICollection<ElementId> elementsToCopy = new FilteredElementCollector(sourceDoc).OfCategory(BuiltInCategory.OST_VolumeOfInterest).ToElementIds();

    using (Transaction t = new Transaction(doc,"Copy Scope Box from " + filename))
        ElementTransformUtils.CopyElements(sourceDoc, elementsToCopy, doc, Transform.Identity, new CopyPasteOptions());


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: