I am trying to copy Floors from Linked Revit File.
I get a warning as below:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 28, in
Exception: Copying one or more elements failed.
The overall operation fails because of a few elements. Please tell me how I could ignore these exceptions as the operation runs as a set of elements to be copied.
from Autodesk.Revit.DB import *
from System.Collections.Generic import List
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
current document
doc = DocumentManager.Instance.CurrentDBDocument
input link document
linkdoc = UnwrapElement(IN[0])
#collect levels from the link document
collector = FilteredElementCollector(linkdoc).OfClass(Floor).ToElements()
Certain Elements are not being copied and hence the whole command fails, is there a method I could use to filter out the elements that cannot be copied and the copy/paste happens for the elements that could be copied.
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
#Preparing input from dynamo to revit
LinkDoc = UnwrapElement(IN[0])
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
floors = FilteredElementCollector(LinkDoc[0]).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType().ToElementIds()
copied = ElementTransformUtils.CopyElements(LinkDoc[0],floors,doc,None,CopyPasteOptions())
TransactionManager.Instance.TransactionTaskDone()
OUT = floors,copied
I agree with you, the instances that you are trying to copy does not have any errors.
As you can read the Exception as below that I am facing: "Exception: Copying one or more elements failed."
It does copy the elements, but it fails as a set as in some cases it may have errors.
Is there or might be way to weed out these failed elements and let the copy/paste function happen.
I am having the same problem as you had. How did you overcome this? My case is a little different as I try to copy Views from linked file to host file.