Hi Everyone,
i’m working on a script that transfer grids from a linked model to the current one.
It has been working fine all day during my itesting and itterating but all of a sudden it only works when i open dynamo… ( not even a dynamo project, just dynamo home screen is already enough).
Anybody has any idea what’s happen here?
I run the script trough pyrevit
It seems like the script can’t find the Active Document when dynamo is closed.
script.py (1.4 KB)
## IMPORT LEVEL & GRIDS ##
#IMPORTS
import sys
import System
from itertools import compress
from Autodesk.Revit.UI import *
from Autodesk.Revit.DB import *
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *
#Document information
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
docs = app.Documents
#docs & docnames
titles,documents = [],[]
for dc in docs:
if dc.Title != doc.Title:
documents.Add(dc)
titles.Add(dc.Title)
else:
docu=dc
titl=dc.Title
documents = [docu]+documents
titles = [titl]+titles
#filter doc for linked files
docmask = []
for i in titles:
docmask.Add(i == doc.Title)
docmask = [not i for i in docmask]
_linkDoc = list(compress(documents,docmask))
#retrieve grids from Linked model
try:
grids = FilteredElementCollector(_linkDoc[0]).OfCategory(BuiltInCategory.OST_Grids).WhereElementIsNotElementType().ToElements()
except:
print("No Grids Where found in the Linked model")
print ("----------")
#retrieve gridsCurves
curves,gridnames = [],[]
for i in grids:
curves.Add(Grid.Curve)
gridnames.Add(Grid.Name)
print(curves)
print("-------NAMES-----")
print(gridnames)