I stuck, with sorting my columns

Hello,

i stuck, i think it is just a small error.


# 🎯 GET Linked Elements

collector = FilteredElementCollector(doc).OfClass(ImportInstance).ToElements()
print("\n Es sind {} dwgs im Projekt.".format(len(collector)))

# Get instance properties

cadLnk = []
cadLnkType = []
cadLnkView = []

for i in collector:
    try:
        if i.IsLinked == True:
            cadLnk.append(i)
            cadLnkType.append(i.Document.GetElement(i.GetTypeId()))
            cadLnkView.append(doc.GetElement(i.OwnerViewId))
    except:
        pass


# Sorting and displaying the table
table=[list(record) for record in zip(cadLnk, cadLnkType, cadLnkView)]
out.print_table(table, ["Id","Name","Ansicht"])


# Script Duration
out.print_md("---")
out.print_md("---")

For any reason, all my collumns remain empty. when i just simple print my variables they have the values
grafik

KR

Andreas

Since you have all the items for a row in a single loo, you can build the table variable directly:

table = []
for i in collector:
    if i.IsLinked:  # no need to use == True, it is implicit here
        table.append([i, i.Document.GetElement(i.GetTypeId()), doc.GetElement(i.OwnerViewId)])

the thing is, what do you want to output? you have a table with elements, not names or ids, and I suppose this is why you don’t see anything.
Take a look at the output.linkify method to get a clickable element link

1 Like