Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Making iLogic faster and more efficient

3 REPLIES 3
Reply
Message 1 of 4
ad64
1625 Views, 3 Replies

Making iLogic faster and more efficient

What are the best ways for speeding up iLogic routines? Can Inventor updating or re-calculation be suppressed while the iLogic code is running? Does ScreenUpdating = False accomplish this?

 

What other tips do users have for improving their iLogic code efficiency and speed?

 

Thanks,

Steve

3 REPLIES 3
Message 2 of 4
bretrick30
in reply to: ad64

One thing you can do to speed up a rule is to turn on Defer Updates in the beginning of the rule, and then turn it back off at the end of the rule.  This will make it so Inventor will not try to update anything until after the rule is run.  The only problem is if you are already using defer updates in the file, then you will get an error.

 

Here is the code.

 

Beginning of Rule

ThisApplication.AssemblyOptions.DeferUpdate = True

 

 

End of rule

ThisApplication.AssemblyOptions.DeferUpdate = False

 

 

 

Message 3 of 4
mrattray
in reply to: bretrick30

iLogic already waits until the rule is finished before updating anything, except in certain instances.
There are many ways to garner efficiency from code depending on the application. Can you post the rule that is performing poorly for you? Perhaps myself or others can provide suggestions.
Mike (not Matt) Rattray

Message 4 of 4
jezavala
in reply to: mrattray

Good morning!

I´m trying to get a pdf file for each sheet in my inventor drawing using this code in iLogic, I know it can works better but I´m not that good at programing, I make my code changing other codes I saw in the forum and this code actually works fine but I would like to make it faster, (maybe using codes from de pdfcreator) If you can help me making it faster and if is possible open the drawing model and run a macro in the assembly document referenced I would really apreciate it.

 

My rule runs after changing my user parameter called RELEASE from NO to YES and my code is :

 

'start of ilogic rule

Try
    
If RELEASE="YES" Then
ThisApplication.AssemblyOptions.DeferUpdate = True
ThisApplication.ScreenUpdating = False

WorkSpacePath = ThisDoc.WorkspacePath()
conextension = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
modelName = Left(conextension, Len(conextension) - 3)

System.IO.Directory.CreateDirectory( WorkSpacePath & "\4.0_RELEASE INFO\" & modelName & "\PDF")
PDFPath= WorkSpacePath  & "\4.0_RELEASE INFO\" & modelName & "\PDF"

System.IO.Directory.CreateDirectory( WorkSpacePath & "\4.0_RELEASE INFO\" & modelName & "\DWG")
DWGPath = WorkSpacePath  & "\4.0_RELEASE INFO\" & modelName & "\DWG"


COMODIN = ThisDoc.FileName(False) 'without extension
G = Len(ThisDoc.FileName)

SC=50
ThisDoc.Document.SaveAs( DWGPath & "\"  & (".dwg"), True)


For Each oSheet In ThisApplication.ActiveDocument.Sheets  
    ActiveSheet = ThisDrawing.Sheet(oSheet.Name)
    A = ActiveSheet.Name
    B = Right(A,1)
    C = Val(B)
    H = Len(ActiveSheet.Name)
    J = H-G

   If C=1 And SC=50 Then 'ES EL KS NO LLEVA NUMERO FINAL
   ThisDoc.Document.SaveAs(PDFPath & "\" & COMODIN & (".pdf"), True)
   SC = SC + 1
   ElseIf J > 7 Then 'ES UN OPP POR LO TANTO OCUPA 2 CIFRAS
  ThisDoc.Document.SaveAs(PDFPath & "\" & COMODIN & "-" & UNIT & SC & "-" & UNIT & SC+1 & (".pdf"), True)
   SC = SC + 2
   Else
   ThisDoc.Document.SaveAs(PDFPath & "\" & COMODIN & "-" & UNIT & SC & (".pdf"), True)
   SC = SC + 1
   End If
    
Next
ThisApplication.ActiveDocument.Sheets.Item(1).Activate
ThisApplication.ScreenUpdating = True
InventorVb.DocumentUpdate()
RELEASE = "NO"
MessageBox.Show("RELEASE COMPLETED", "NOTIFICATION")

End If
ThisApplication.AssemblyOptions.DeferUpdate = False


Catch ex As Exception
      'if some error occurs then this code will be executed
      ThisApplication.ScreenUpdating = True
      ThisApplication.UserInterfaceManager.UserInteractionDisabled = False
      Beep()
      MsgBox("Error info: " & vbNewLine & ex.ToString)
    End Try

 

'end of ilogic rule

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report