Hello,
I use the below to get a bounding box of a titleblock schedule on a sheet. This particular bit drastically slows down my script. If I hard code XYZ coordinates, then the script runs no more than 10 seconds. If I use the below, it takes around 5-6 minutes. Please advise if this is what it is or there is an efficient way of getting bounding box or coordinates of a titleblock schedule.
bounding_box = schedule_instance_element.get_BoundingBox(picked_sheet)
Solved! Go to Solution.
Solved by vitalij.marcukov2BP2F. Go to Solution.
Solved by TripleM-Dev.net. Go to Solution.
Hi @vitalij.marcukov2BP2F,
The get_BoundingBox() can be slow if the sheet contains a lot of data because Revit keeps recalculating the bounding box for the element every time get_BoundingBox() is called.
Is it possible to store the bounding box values in a cache and use them where necessary?
Example, if you get the minPoint and maxPoint as below, you can save them in a cache to re-use later.
XYZ minPoint = schedule_instance_element.get_BoundingBox(picked_sheet).Min;
XYZ maxPoint = schedule_instance_element.get_BoundingBox(picked_sheet).Max;
Hello @moturi.magati.george,
Thank you for the reply.
So basically, the script is: Revit user pick revision (only 1 allowed), then picks sheets where the revision need to be set to. The script applies revision to sheets and also places generic annotation family based on titleblock schedule max coordinates. So I need to call get_BoundingBox for each schedule/picked sheet if that makes sense. So not sure how I can store it in a caches...
Are you refering to the Revision Schedule that's inside the TitleBlock?
Maybe get the point of the ScheduleSheetInstance, and calculate width/height from the TableSectionData ?
https://www.revitapidocs.com/2023/a7d3080d-811d-4c71-d15a-1a466de68df0.htm
https://www.revitapidocs.com/2023/e067f2c7-f809-89d4-5b61-a93004e3710d.htm
https://www.revitapidocs.com/2023/f83926e3-44de-82f4-250e-254d087001de.htm
Etc.
- Michel
as something to try, once user selects the sheet, set it as the active view, then your code becomes:
bounding_box = schedule_instance_element.get_BoundingBox(activeview)
no guarantees it will be any faster, but its something ive done with no noticeable slowdown.
Hello @TripleM-Dev.net,
I have done a quick test and your advice has solved the problem. I will do my best to finalize the script this weekend and provide a full feedback / mark your advice as solved. Thank you.
Uhm, yes this is it. The function triggers a refresh so if the sheet has large views on it it will definitly slow it down.
So a second time (if nothing changed) it should run faster?
Hello @TripleM-Dev.net,
Thank you for your help. Your advice steered me towards the right direction.
I used Point property to get the placement point of revision schedule within the sheet coordinates and then used GetScheduleHeightsOnSheet().GetBodyRowHeights() to get the row heights as per the code below. It takes seconds to execute the code rather than minutes.
schedule_origin = schedule_instance_element.Point
ip_x, ip_y, ip_z = schedule_origin[0], schedule_origin[1], schedule_origin[2]
view_schedule_height = sum(view_schedule_element.GetScheduleHeightsOnSheet().GetBodyRowHeights())
insertion_point = XYZ(ip_x, (ip_y + view_schedule_height + 0.01572111827428), ip_z)
return insertion_point
Can't find what you're looking for? Ask the community or share your knowledge.