Hi all,
What i want:
I want to copy dvg files or the linked ojbects of these from one project to a new project.
What i currently get:
I manage to copy the cadlinks from one document to another, when i go to the manage links i can se all the dwg, but they are not in my enviroment…
Are i heading in the wrong direction here ? Or is this not possible if i dont have the acutale .dwg file
itself in a folder ?
My code:
from Autodesk.Revit import DB
from Autodesk.Revit.DB import *
import clr
clr.AddReference("System")
from System.Collections.Generic import List
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
app = __revit__.Application
#import
from pyrevit import script, revit, DB, forms
from System.Collections.Generic import List
########################################################################################################################
# Linkedobjects collector
allcadlinks = list(FilteredElementCollector(doc).
OfClass(CADLinkType).
WhereElementIsElementType().ToElements())
########################################################################################################################
#Get the doc
docTo = revit.doc
# Select background document
docFrom = forms.select_open_docs(title="Select a document", button_name="Select", width=500, multiple=False)
#Make sure the choice is suitable
if not docFrom:
script.exit()
elif docFrom.IsFamilyDocument:
forms.alert("Choose a document wich is not family document", title="Script cancelled")
script.exit()
########################################################################################################################
ids_link = [e.Id for e in allcadlinks]
id_copy_link = List[DB.ElementId](ids_link)
cp_Opt_link = DB.CopyPasteOptions()
t_iden_link = DB.Transform.Identity
with revit.Transaction("Copying the links"):
DB.ElementTransformUtils.CopyElements(docFrom, id_copy_link, docTo, t_iden_link, cp_Opt_link)
msg = str(len(ids_piping)) + " elements copied"
forms.alert(msg, title = "Script completed", warn_icon=False)