- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a problem where this particular piece of code takes a really long time to run on some large drawings. For example, on idw drawings that are 200MB >1000MB in filesize.
I run this code before exporting a drawing to make sure we don't get any raster views in our automated PDF export tool. The issue is that even if all of the drawing views are up to date, and i can export the PDF just fine manually, if this code runs, it takes really long to go through each view. Like 2-5 minutes per view and more. and on a drawing with 30 views this is a really long time. And i know that the drawing is very large, but it doesnt makes sense that each view takes that long to check if its up to date.
If you want to see a full example of the print code it is here
https://github.com/mattjlt/Inventor-Code-Library/blob/master/Scripts/DRG_Export_PDF%20%2B%20DXF.iLog...
The section in particular is the "Do While oView.IsUpdateComplete = False"
I think something is happening that makes it get stuck / loop unnecessarily.
Any help is be appreciated. Even if you have a more efficient way to check that the views are all up to date / not raster and ready for PDF + DXF export.
Thanks, Matt.
Function UpdateAllViews(ByRef oDoc As DrawingDocument) As Boolean
' Update application status bar for user to monitor progress
ThisApplication.StatusBarText = "Updating drawing views"
' Make sure there are no raster views, not going to use as unsure if it is efficient as checking all views separately
'oDoc.MakeAllViewsPrecise()
' Ensure all views are updated before printing, this prevents raster view printouts on large assemblies
For Each oSheet As Inventor.Sheet In oDoc.Sheets ' Iterate through all sheets
' This was on a couple of drawings where someone mistakenly selected this
' Check if sheet is excluded from count but is being printed aswell, add it back to the count to prevent export sheet number issues
If oSheet.ExcludeFromCount = True AndAlso oSheet.ExcludeFromPrinting = False Then
' Add sheet back into count
oSheet.ExcludeFromCount = False
End If
' Iterate through all drawing views
For Each oView In oSheet.DrawingViews
ThisApplication.StatusBarText = "Checking if view is raster"
If oView.IsRasterView Then ' Check if view is raster
ThisApplication.StatusBarText = "View is raster so changing to precise"
oView.IsRasterView = False ' Set view to precise / not a raster
End If
' Wait for view to update
ThisApplication.StatusBarText = "Checking if view is updated"
Do While oView.IsUpdateComplete = False
Wait_Inventor(1) ' Just wait for one second, don't do anything
ThisApplication.StatusBarText = "Updating drawing views"
Loop
Next
Next
ThisApplication.StatusBarText = "Drawing views updated"
' Succeeded, return true
Return True
End Function
Public Sub Wait_Inventor(ByVal seconds As Integer)
For i As Integer = 0 To seconds * 100
System.Threading.Thread.Sleep(10)
ThisApplication.UserInterfaceManager.DoEvents() ' Inventor do events
Next
End Sub
Solved! Go to Solution.

