Copying Views and details

Hi @attarshahid3 , would you mind explaining how you linked the file via the dyanmo script?

Kindest,
LL

Can anybody please put the dynamo script he used?

Steam nodes are getting quite long in the tooth
Here is some python to copy filtered views from a single link document
Requires IronPython due to sub-classing to stop duplicate type warnings

import clr

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from System.Collections.Generic import List


class SuppressDuplicateTypeNames(IDuplicateTypeNamesHandler):
    def OnDuplicateTypeNamesFound(self, args):
        return DuplicateTypeAction.UseDestinationTypes


# ** Use IronPython **

doc = DocumentManager.Instance.CurrentDBDocument

link_doc = IN[0]
name_contains = IN[1]
copy_views = IN[2]

# Collect views
views = (
    FilteredElementCollector(link_doc)
    .OfCategory(BuiltInCategory.OST_Views)
    .ToElements()
)

# Filter views
views = list(filter(lambda v: name_contains in v.Name, views))
view_ids = List[ElementId](map(lambda e: e.Id, views))

# Copy views
if copy_views:
    options = CopyPasteOptions()
    options.SetDuplicateTypeNamesHandler(SuppressDuplicateTypeNames())

    TransactionManager.Instance.EnsureInTransaction(doc)

    views = ElementTransformUtils.CopyElements(link_doc, view_ids, doc, None, options)

    TransactionManager.Instance.TransactionTaskDone()

    OUT = [doc.GetElement(vid) for vid in views], views

else:
    OUT = views, view_ids
2 Likes

thanks a lot mike , i just cant find the node select.GetDocuments from archilab . can you post the dynamo file .dyn would help me alot

Check you have the correct year version of achilab installed for you version of Revit & Dynamo
R2024 shown here


copy_views.dyn (12.5 KB)

1 Like

Thanks a lot again mike :))) it worked perfectly , one last question please , do you know how can i copy all the detail elements also from the linked file ?

Thank you for posting the graph , will it copy the view with the dimensions, tags, and all other annotations , or it will copy only the view?

Just the view. The forum has plenty of posts on coping from one view to another, however as dimensions and tags are typically hosted on model elements they will loose the association on copy / re-creation. Elements like text, detail lines and filled regions are fairly straight forward to copy.

I would start a new topic if you get stuck trying to copy annotations

hmmm in 2024 it dosn’t want to copy elevation views too?

This thread has covered many different options over multiple years at this point. It’s best to start a new thread with a specific case so that the appropriate information gets shared.

4 Likes

Have to get the elevation marker of the view for it to work

Now that’s a fun one. I went through this task a while ago and I don’t think there’s a method for that.

But… you can get all views from all pointers associated to each marker, then work back through their Ids to find the view’s marker. Fun stuff.

1 Like

Haha I found a post from you mentioning that to figure it out

1 Like