Publish Coordinates Transactions

That shouldn’t be a problem.
The custom node first checks whether the Project Location name exists.

OK, let me give it a try :slight_smile:

There are still issues, unfortunattely :frowning: Locations are still not shared and I also see wrong site names in the links:

Edit: There are wrong locations also:

Hi, @Alban_de_Chasteigner

I used your code as a basis and simplified it a bit. I only used parts of it to create sites in linked instances and then used the previous version of your node to publish coordinates. I think there was a little issue with sorting and that was causing the problem, but I will check this further later on. Here’s the code:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

rvtLinkInstances = UnwrapElement(IN[0])
linkNames = UnwrapElement(IN[1])

i = 0

for rvtLinkInstance in rvtLinkInstances:
	linkDoc = rvtLinkInstance.GetLinkDocument()
	filepath = linkDoc.PathName
	linkType = doc.GetElement(rvtLinkInstance.GetTypeId())
	linkType.Unload(None)
	linkDoc2 = app.OpenDocumentFile( ModelPathUtils.ConvertUserVisiblePathToModelPath(filepath), OpenOptions())
	t = Transaction(linkDoc2, "Create Project Location")
	t.Start()
	linkLocationId = linkDoc2.ActiveProjectLocation.Duplicate(linkNames[i]).Id
	t.Commit()	
	linkDoc2.Close(True)
	linkType.Reload()
	i += 1

OUT = "whatever"

Of course, currently it would only work in case there is identical number of instances and site names and none of the sites is created already, but that’s easy to fix. What’s important is now we didn’t have to do these thousands of clicks :stuck_out_tongue:

Thx for your support, Cheers!

2 Likes