Slow performance when running ilogic in drawing with 50+ sheets

Slow performance when running ilogic in drawing with 50+ sheets

tbishop00
Contributor Contributor
367 Views
4 Replies
Message 1 of 5

Slow performance when running ilogic in drawing with 50+ sheets

tbishop00
Contributor
Contributor

I have an iLogic form that I created to handle iProperties and Parameters for our titleblock, as well as execute iLogic rules in our drawing files. I've noticed that performance starts to severely slow down when drawing files have more than 50 sheets. Even seemingly basic tasks, such as changing the value of an iProperty can take over a minute when changed in the iLogic form, whereas it is instant when changed in the iProperties window.

 

Is there any way I can improve performance when using the form and iLogic in general?

0 Likes
368 Views
4 Replies
Replies (4)
Message 2 of 5

d_eckel
Contributor
Contributor

Hi @tbishop00 

Without any code it's hard to help. I don't know any special settings etc to make the code run faster. But:

 

I have an idea how you can look for slow lins / commands in your code.

Try something like:

Logger.Info("SOME_KIND_OF_NAME_OF_THE_LINE: " & Now)

between each line or each paragraph with different names.  Then you can check in the protocoll the times. Maye you can see where it takes longer.

 

David

0 Likes
Message 3 of 5

bradeneuropeArthur
Mentor
Mentor

Do you consequently release the objects you declare like:

 

Dim _prop as property = Thisdoc.document.propertysets.item(3).item(1)
_prop = nothing

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 5

tbishop00
Contributor
Contributor
Sub Main()
	Dim oProgressbar As ProgressBar
	
	oPath = ThisDoc.Path
	oFileName = ThisDoc.FileName(False) 'without extension
	oRevNum = iProperties.Value("Project", "Revision Number")
	oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
	oDocument = ThisApplication.ActiveDocument
	oContext = ThisApplication.TransientObjects.CreateTranslationContext
	oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
	oOptions = ThisApplication.TransientObjects.CreateNameValueMap
	oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
	Dim oSheet As Sheet
	Dim sSheetName As String
	Dim iSheetNumber As Integer
	Dim i As Integer
	
	'get PDF target folder path
	oFolder = oPath & "/PDF"
	
	'Check for the PDF folder and create it if it does not exist
	If Not System.IO.Directory.Exists(oFolder) Then
	    System.IO.Directory.CreateDirectory(oFolder)
	End If
	
	If oPDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
		'set global PDF options
		oOptions.Value("All_Color_AS_Black") = iProperties.Value("Custom", "PDF_All Colors as Black")
		oOptions.Value("Remove_Line_Weights") = iProperties.Value("Custom", "PDF_Remove Line Weights")
		oOptions.Value("Vector_Resolution") = 400

		Select Case Parameter("Print_Choice")
			Case "Separate Drawings"
				'Exports all sheets as separate PDFs
				'Assumes each sheet has a unique name.
				'Sheets with duplicate names will be overwritten and lost
				
				oProgressbar = ThisApplication.CreateProgressBar(False, oDocument.Sheets.Count, "Exporting PDFs", True)
				AddHandler oProgressbar.OnCancel, AddressOf OnCancel
				
				i = 1
				For Each oSheet In oDocument.Sheets
					If UserWantsToCancel Then
						oProgressbar.Close
						Exit For
					End If
					
					Dim SheetSuffix As String = ""
					If oSheet.Size = 9988 Then
						sSheetName = oSheet.TitleBlock.GetResultText(oSheet.TitleBlock.Definition.Sketch.TextBoxes.Item(14))
						SheetSuffix = oSheet.TitleBlock.GetResultText(oSheet.TitleBlock.Definition.Sketch.TextBoxes.Item(28))
					Else
						sSheetName = oSheet.TitleBlock.GetResultText(oSheet.TitleBlock.Definition.Sketch.TextBoxes.Item(18))
					End If
					
					If sSheetName = "" Then Continue For
					oProgressbar.Message = "Exporting " & sSheetName & SheetSuffix & " Rev" & oSheet.Revision & ".pdf"
					oProgressbar.UpdateProgress
					
					oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintSheetRange
					oOptions.Value("Custom_Begin_Sheet") = i
					oOptions.Value("Custom_End_Sheet") = i
					oDataMedium.FileName = oFolder & "\" & sSheetName & SheetSuffix & " Rev" & oSheet.Revision & ".pdf"
					oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
					i = i + 1
				Next
				oProgressbar.Close
		End Select
	End If
End Sub

Private Property UserClickedOnCancel() As Boolean = False

Function UserWantsToCancel()
	If (UserClickedOnCancel) Then
        MsgBox("Cancelling Export.")
        Return True
    End If
	
	Return False
End Function

Sub OnCancel()
	UserClickedOnCancel = True
End Sub

 

Thanks for replying,

 

I've inserted the code that is causing us the most headache, though it isn't just limited to this. I determined already that getting the result text from the sheets, as well as the code for the progress bar have no noticeable effect on performance. Unfortunately, the solution you offered of clearing the objects also had no effect on performance. The document I'm testing on has 97 sheets, and each sheet takes roughly 1min 30sec to export using the above code.

0 Likes
Message 5 of 5

tbishop00
Contributor
Contributor
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

 

I inserted the entire code below, however, this is the line that is causing the slowdown, and it only gets slower when more sheets get added to the drawing file.

0 Likes