I am trying to push the project location of my host file to all the Revit links that are in that file.
I have been able to create a project location within the host file.
However, trying to do the same with linked Revit documents has been unsuccessful.
The empty lists in my debugging output lead me to believe that this is an issue with the collector, as the only document that shows is the current one although there are two revit links in the project.
# 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 #TransactionManager.Instance.EnsureInTransaction(doc) collector = Autodesk.Revit.DB.FilteredElementCollector(doc) siteLoc = collector.OfClass(Autodesk.Revit.DB.SiteLocation) #I may get this id from a specific site location later siteLocId = siteLoc.FirstElementId() linkInstances = collector.OfClass(Autodesk.Revit.DB.RevitLinkInstance) linkDocs =  for i in linkInstances: linkDocs.append(i.GetLinkDocument()) #temporary for testing linkDocs.append(doc) newLocs =  z = 0 for i in linkDocs: TransactionManager.Instance.EnsureInTransaction(i) newLocs.append(Autodesk.Revit.DB.ProjectLocation.Create(i, siteLocId, "Master Shared Site (DO NOT UNCLIP, MODIFY OR DUPLICATE)Test1")) z = z +1 #TransactionManager.Instance.TransactionTaskDone() #Assign your output to the OUT variable. #janky debug tool :) (uncomment '#debug = true' to change state) debug = False debug = True if debug: OUT = (['doc', 'collector', 'siteLoc', 'siteLocId', 'linkInstances', 'linkDocs', 'newLocs'],[doc, collector, siteLoc, siteLocId, linkInstances, linkDocs, newLocs]) else: OUT = (newLocs)
UpdateSharedSitePython.dyn (6.5 KB)
P.S. I know an enumerate would work better than my z variable on my for loop, however I come from C# and I’m still working on learning python, I would like to see how it is done though