Updating text in tables does a graphics refresh with each change. Disabling the IModelView's graphics while updating the table could make a big difference. Use the EnableGraphicsUpdate property of the ModelView to disable before your loop, then enable after it's done.
Get ModelView from ModelDoc2.ActiveView
Use ModelView.EnableGraphicsUpdate(False) to disable
Hide your table while you update it. More information here: 2016 SOLIDWORKS API Help - Text Property (ITableAnnotation)
The interesting part:
You might experience decreased performance when updating the text in multiple cells in large tables because the table is rebuilt after changing the text in a cell. To increase performance while updating the text in large tables:
- Set IAnnotation::Visible to false. (The table is not rebuilt while the table is hidden.)
- Update the text in the table cells.
- Set IAnnotation::Visible to true.
Of course, this has its limitations. At a certain size, SOLIDWORKS's BOMs are useless.http://www.cadsharp.com/
Michael Spens : Have you experienced performance gains by disabling graphics on the active view model. I think that's reserved for selections in the 3D space?
Thank you Amen,
Easy change and makes all the difference!
Set swAnn = swTable.GetAnnotation
swAnn.Visible = swAnnotationVisibilityState_e.swAnnotationHidden
Time (Basic) = 74.46289 s
Time (EnableGraphicsUpdate) = 67.85938 s
Time (Table Annotation Change w/Visible State) = 0.890625 s