I am trying to make a python list with the selected elements ID's in Revit API. I've tried to collect ID's of the grids in the sample structural file and then use this list back in Visual Studio Code. I am using Revit 2020 and IronPython 2.7.7 (2.7.7.0) on .NET 4.0.30319.42000 (64-bit).
I get a list of the ID's that I want when I run the code in IronPython, but how to make a list of the printed ID's for further use back in Visual Studio Code?
My code:
from Autodesk.Revit.DB import *
import clr
import math
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
app = __revit__.Application
doc = __revit__.ActiveUIDocument.Document
transaction = Transaction(doc, "Get grids")
transaction.Start()
new_list = DB.FilteredElementCollector(doc) \
.OfCategory(DB.BuiltInCategory.OST_Grids) \
.ToElementIds()
for x in range(len(new_list)):
new_list[x]
print(new_list[x])
transaction.Commit()