Pyrevit: out.print_table takes too much runtime

Created on 14 Feb 2021  路  4Comments  路  Source: eirannejad/pyRevit

The out.print_table() takes too much runtime when I have more than 100 rows of Items.
Example -as below:
I am trying to pull out information\elements in a particular Workset.
The script runs fine, but when I have more than 100 elements to display, the runtime is about 5 mins for 300 items.

Please suggest, how I could speed up this command, or a walkaround.

*out.print_table Example*


for items in collector_of_workset_element_by_level:
            out.print_table(table_data = items, title = 'Elements in the Workset- {}'.format(userInputcategory_lvl),\
                        columns = ['Level','Category', 'Name','Element Id'], formats = ['','','',''])  
Question

All 4 comments

Is it intentional that you are printing 300 individual tables instead of One table with 300 rows?

Its one table with 300 Row.
image

Put all the 300 rows in the table_data and run out.print_table only once

I did try that but since there is more than 1000 items, it did reduce the time, but I found it impractical to display 20000 items as Output, so I went ahead and I am directly exporting the data to Excel, which is much faster.

Alternatively for cases where I need to highlight elements and their ids with errors, i have highlighting the elements 200 at a time. Please find as below:

`check_arch_wall_multistorey_fail = []
arch_walls_failed_in_top_constraint_check_Name_200 = arch_walls_failed_in_top_constraint_check_Name[:200]
arch_walls_failed_in_top_constraint_check_base_level_200 = arch_walls_failed_in_top_constraint_check_base_level[:200]
arch_walls_failed_in_top_constraint_check_top_level_200 = arch_walls_failed_in_top_constraint_check_top_level[:200]
arch_walls_failed_in_top_constraint_check_Id_200 = arch_walls_failed_in_top_constraint_check_Id[:200]    

if len(arch_walls_failed_in_top_constraint_check_Name) == 0:
    print('\n2.All Architecture Walls have their Top Constraints defined to Single Storey.')
    temp_sw = 'Pass'
else:
    if len(arch_walls_failed_in_top_constraint_check_Name) > 200:
        print('\n1.There are more than 200 Walls that have thier Top Constraints as Multi-Storeyed.Please check the Top Constraints and Design intent.Displaying 200 Walls.')

        summary_of_arch_walls_with_top_constraints_failure = [zip(arch_walls_failed_in_top_constraint_check_Name_200, arch_walls_failed_in_top_constraint_check_base_level_200,\
                                                                     arch_walls_failed_in_top_constraint_check_top_level_200,arch_walls_failed_in_top_constraint_check_Id_200)]
        for report in summary_of_arch_walls_with_top_constraints_failure:
            out.print_table(table_data = report, title = '2.Architecture Walls with Top Constraints as Multi-Storeyed', columns = ['Architecture Walls', 'Base Constraint','Top Constraint', 'Element Id'], formats = ['','','',''])   

    else:
        print('\n2.The following Architecture Walls have their Top Constraints as Multi-Storeyed. Please check the Top Constraints and Design intent. ')
        summary_of_arch_walls_with_top_constraints_failure = [zip(arch_walls_failed_in_top_constraint_check_Name, arch_walls_failed_in_top_constraint_check_base_level,\
                                                                     arch_walls_failed_in_top_constraint_check_top_level,arch_walls_failed_in_top_constraint_check_Id)]
        for report in summary_of_arch_walls_with_top_constraints_failure:
            out.print_table(table_data = report, title = '2.Architecture Walls with Top Constraints as Multi-Storeyed', columns = ['Architecture Walls', 'Base Constraint','Top Constraint', 'Element Id'], formats = ['','','',''])   
        temp_sw = 'Fail'
    check_arch_wall_multistorey_fail.append(temp_sw)        

print(check_arch_wall_multistorey_fail)`
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jmcouffin picture jmcouffin  路  5Comments

pihglez picture pihglez  路  4Comments

Arsany123 picture Arsany123  路  4Comments

jkcameron picture jkcameron  路  5Comments

AlexVilaOrtega picture AlexVilaOrtega  路  3Comments