Copy elements between documents with same Project Base Point

erron_e
Observer
Observer

Copy elements between documents with same Project Base Point

erron_e
Observer
Observer

I am trying via API to copy elements from one open document to another. They have the same project base point. However, on copying, the elements are not in the correct place. I assumed that using no Transform they would end up in the same place but it seems not. Is there a way to specify copying on Project Base Point?

 

import clr
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import BuiltInCategory as Bic
from Autodesk.Revit.DB import FilteredElementCollector as Fec
from Autodesk.Revit.DB import Transaction
import Autodesk.Revit.DB

docs = __revit__.Application.Documents
fmi = docs.ForwardIterator.__self__.GetEnumerator()
while fmi.MoveNext():
	curDoc = fmi.Current
	if (curDoc.Title.Contains("BASE")):
		destDoc = curDoc
	else:
		sourceDoc = curDoc

columns = Fec(sourceDoc).OfCategory(Bic.OST_Columns).WhereElementIsNotElementType().ToElementIds()
txSource = Transaction(sourceDoc, 'Copy Columns')
txSource.Start()

txDest = Transaction(destDoc, 'Copy Columns')
txDest.Start()

ElementTransformUtils.CopyElements(sourceDoc, columns, destDoc, Transform.Identity, CopyPasteOptions())

txSource.Commit()
txDest.Commit()

 

 I am using IronPython in RevitPythonShell. 

 

Revit 2021.1

Windows 10

0 Likes
Reply
583 Views
1 Reply
Reply (1)

sedober
Participant
Participant

The CopyElements() method uses the Revit Internal Origin as the reference for copying between documents. If you want to use the Project Base Point instead you need to supply a different Transform argument to the method. To do this I'd recommend getting the XYZ locations of the two Project Base Points and then creating an XYZ vector from the sourceDoc's Project Base Point location to destDoc's Project Base Point location. Supply that vector to the Transform.CreateTranslation() method and use that in place of Transform.Identity in the CopyElements arguments.