More Reasons Why iLogic is Not Intuitive, And Plain Old Silly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Practice for the reader:
1) Make a BOM Customization File (one that set the column order/view displays)
2) Insert that file path in the rule below over top of the current one.
3) Write a simple external rule
4) Paste that path over top of the "Sort Browser" rule in both of it's locations.
The fun part:
5) Run the rule using the native iLogicvb.RunExternalRule line and the Call Run iLogic line commented out
6) Take notes.
7) Rune the rule using the "Call Run iLogic" line, and the iLogicvb.RunExternalRule commented out.
8) Note differences.
9) Report back.
Seems pretty silly how even with the rest of it coded as close to native iLogic as it can be, the native iLogic calls still break apart and throw random errors seemingly without any explanation - or documentation - whereas using the fully coded method returns expected results.
Sub Main() Dim oDoc As Document = ThisDoc.Document Dim i = 0 For Each oSubDoc in oDoc.AllReferencedDocuments If i > 3 Then Exit Sub If oSubDoc.IsModifiable = False Then Continue For If oSubDoc.DocumentType = kAssemblyDocumentObject i = i+1 oSubDoc = ThisApplication.Documents.Open(oSubDoc.FullFileName, True) oSubDoc.Activate Call StandardizeBOM(oSubDoc) MsgBox("Hurrr") Call RuniLogic (oSubDoc, "Z:\iLogic\Sort Browser.txt") 'iLogicVb.RunExternalRule(oSubDoc, "Z:\iLogic\Sort Browser.txt") oSubDoc.ReleaseReference End If Next End Sub Sub StandardizeBOM(invDoc As Document) On Error Resume Next Dim oBOM As BOM oBOM = invDoc.ComponentDefinition.BOM Call oBOM.ImportBOMCustomization("Z:\iLogic\BOM_Style.xml") oBOM.StructuredViewFirstLevelOnly = False oBOM.StructuredViewEnabled = True oBOM.PartsOnlyViewEnabled = True Dim oStructuredBOMView oStructuredBOMView = oBOM.BOMViews.Item("Structured") Call oStructuredBOMView.Sort("Part Number", True) Call oStructuredBOMView.Renumber(1,1,) End Sub Private Sub RuniLogic(oDoc As Document, ByVal RuleName As String) Dim iLogicAuto As Object If oDoc Is Nothing Then MsgBox("Missing Inventor Document") Exit Sub End If iLogicAuto = GetiLogicAddin(ThisApplication) If (iLogicAuto Is Nothing) Then Exit Sub iLogicAuto.RunExternalRule(oDoc, RuleName) End Sub Private Function GetiLogicAddin(oApplication As Inventor.Application) As Object Dim addIn As ApplicationAddIn On Error Goto NotFound addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}") If (addIn Is Nothing) Then Exit Function addIn.Activate GetiLogicAddin = addIn.Automation Exit Function NotFound: End Function
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization
iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread
Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects
Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help
Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type