Hello,
i have a dictionay with collected Revit IDs (of rooms)
room_from_lights_Id = [int(str(i.Id)) for i in room_from_lights]
how can i convert them back to revitIds
lights_in_rooms = [doc.GetElement(i) for i in room_from_lights_Id]
this does not work i wants a reference(?)
so what is the difference between Reference, Element and Integers
Hi Andreas,
What is the reason for converting the Id’s to stings and then to ints in the first place? Can you not skip these steps and just keep the Element Ids?
But anyways, maybe you can use this? Link
1 Like
@MartinSpence
when i converted directly to Int i got the error it has to be a string. so i followed the instruction.
my problem is now in the second snipped, i can`t use the Integer values to get the element…
1 Like
you can use the property of ElementId and the Constructor
import clr
import sys
import System
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
app = uiapp.Application
sdkNumber = int(app.VersionNumber)
room_from_lights_Id = [getattr(i.Id, "IntegerValue" if sdkNumber < 2024 else "Value") for i in room_from_lights]
lights_in_rooms = [doc.GetElement(ElementId(i)) for i in room_from_lights_Id]
3 Likes