Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Simply reading things usually goes a long way in programming; 

 

Ran that code.

 

The error stack that came back:

 

Error on Line 2 : 'If' must end with a matching 'End If'.
Error on Line 2 : Expression expected.

 Oh heyyyy. Look, the code doesn't have a matching End If/ The If that is there is useless, so delete it.

 

For Each oDoc in ThisApplication.Documents.VisibleDocuments

With oDoc
         ' .Activate
          .Rebuild
          .Save
          .Close
End With
 
Next

 And then....

 

 

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at Inventor.AttributeSet.get_Name()
   at iLogic.RuleStorage.RuleInDocumentForEqualsTest.GetHashCode()
   at System.Collections.Generic.ObjectEqualityComparer`1.GetHashCode(T obj)
   at System.Collections.Generic.HashSet`1.InternalGetHashCode(T item)
   at System.Collections.Generic.HashSet`1.Remove(T item)
   at iLogic.RuleAndTriggeredEval.EvalRule()
   at iLogic.RuleEditAndRun.RuleEvaluate(RuleEvalContainer ruleEvalCont)
   at iLogic.EditRuleRunner.RuleModifyAndEval(ILmiRule ruleNodeDef, Boolean& cancelled)

 So yeah something bigger actually is wrong. But it still runs the rebuild/save part. It just doesn't like closing files.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
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