Hello,
i tried to find some stuff, but it never matches with my collecter. so how do i get Elements from linked files f.e. walls ?
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
linkedDoc = FilteredElementCollector(doc).OfClass(RevitLinkInstance)
elelist = UnwrapElement(linkedDoc)
outlist=[]
for ele in elelist:
type_id = ele.GetTypeId()
ele_type = doc.GetElement(type_id)
ele_fam = ele_type.Family
ele_name = ele_fam.Name
outlist.append(ele_name)
OUT = outlist
KR
Andreas
Have you tried:
linkedDoc = FilteredElementCollector(doc).OfClass(RevitLinkInstance).ToElements()
1 Like
@leonard.moelders ,
does not work
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
linkedDoc = FilteredElementCollector(doc).OfClass(RevitLinkInstance).ToElements()
elelist = UnwrapElement(linkedDoc)
outlist=[]
for ele in elelist:
type_id = ele.GetTypeId()
ele_type = doc.GetElement(type_id)
ele_fam = ele_type.Family
ele_name = ele_fam.Name
outlist.append(ele_name)
OUT = outlist
Hi,
an example
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
lst_rvt_link_inst = FilteredElementCollector(doc).OfClass(RevitLinkInstance)
outlist=[]
for inst in lst_rvt_link_inst:
if RevitLinkType.IsLoaded(doc, inst.GetTypeId()):
lnkdoc = inst.GetLinkDocument()
elelist = FilteredElementCollector(lnkdoc).OfClass(FamilyInstance)
for ele in elelist:
type_id = ele.GetTypeId()
ele_type = lnkdoc.GetElement(type_id)
ele_fam = ele_type.Family
ele_name = ele_fam.Name
outlist.append(ele_name)
OUT = outlist
2 Likes
@Draxl_Andreas I know it got solved, but what would happen if you use .FamilyName
as the property instead of .Family
as it doesn’t exist for RevitLinkType
in your old code:
1 Like
@leonard.moelders ,
i modived it a little to my disieres…
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
lst_rvt_link_inst = FilteredElementCollector(doc).OfClass(RevitLinkInstance)
walls=[]
outlist = []
for inst in lst_rvt_link_inst:
if RevitLinkType.IsLoaded(doc, inst.GetTypeId()):
lnkdoc = inst.GetLinkDocument()
elelist = FilteredElementCollector(lnkdoc).OfCategory(BuiltInCategory.OST_Walls)
for e in elelist:
outlist.append(e)
OUT = outlist
@Draxl_Andreas I meant more like this:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
linkedDoc = FilteredElementCollector(doc).OfClass(RevitLinkInstance)
elelist = UnwrapElement(linkedDoc)
outlist=[]
for ele in elelist:
type_id = ele.GetTypeId()
ele_type = doc.GetElement(type_id)
ele_famname = ele_type.FamilyName
outlist.append(ele_famname)
OUT = outlist