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

Hello @Alban_de_Chasteigner
I have a very similar task as Danail had in this conversation, there are a bunch of villas and I need to save their positions with a name. At the moment I’m running a test only with a simplistic revit file (4 walls).
I have placed 5 instances of the same link

I have used the Publish Coordinates node to save location. What happening is locations are created in the link, all 5 of them but their coordinates are the same, this case the same as the last item in the list.
2023-07-04 10_08_41-1 031 560 722 - AnyDesk

So if in the example I change the location of all 5 link they will be on top of each other:

Do you have any idea about this?

Hi,

Not sure about this but try to set the the longest lacing on the Publish Cordinates node.

Hi,
There was a typo in the python script.

linkLocationId = [linkLocation for linkLocation in linkLocations if linkLocation.Name == linkProjLocNams[p]][0].Id

last variable should be linkProjLocNames

This caused all the named position to have the same location.
Btw thank you for the script it has saved a lot of time for me I had to save 500 named positions. It was still running for a day as it opened the file 500 times. Not sure if you can save the positions by opening the file once.

2 Likes