I have made decent progress today, I think I’m slowly getting the hang of this i have hit a snag though.
I have been able to make a function to duplicate the project location in the current document but I can’t get it to work on linked documents.
By now I’ve tried probably 95+ iterations to no avail. (transaction issues, sublist issues, various other issues that are still over my head)
# Import RevitAPI
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
input = UnwrapElement(IN[0])
linkDoc = []
for x in input:
linkDoc.append(x.GetLinkDocument())
def DupeLocation(loc):
TransactionManager.Instance.EnsureInTransaction(doc)
name = loc.Name
newPos = loc.Duplicate(name +"Dupe1")
pos = newPos.ProjectPosition[XYZ(0,0,0)]
angle = pos.Angle
ew = pos.EastWest
e = pos.Elevation
ns = pos.NorthSouth
TransactionManager.Instance.TransactionTaskDone()
return [ newPos, angle, ew, ns, e]
#locations = doc.ProjectLocations
linkLocations = linkDoc.ProjectLocations
#Assign your output to the OUT variable.
#OUT = [GetValues(x) for x in locations]
#OUT = [DupeLocation(x) for x in locations]
OUT = [DupeLocation(x) for x in linkLocations]
#OUT = [input, linkDoc]