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

Macro - Ilogic - Which is the best opton.

Anonymous

Macro - Ilogic - Which is the best opton.

Anonymous
Not applicable

I am have trouble switching my brain over to inventor after switching from Solidworks.

 

I need something very simple, we have 50,000 parts that will not migrate using the task scheduler so wer are manually opening up a handful than go throught the "rebuild" "save" and "close"

 

Does anyone have the cose that I could run on all open files -  Rebuild-Save and Close 

 

Some of these files go back to Beta6  :slightly_smiling_face:

 

A little Help qould be great.

 

Thanks in advance

 

and this Invenotr stuff is a little more stable than SW at the moment.

 

 

 

0 Likes
Reply
764 Views
12 Replies
Replies (12)

MechMachineMan
Advisor
Advisor

 

If you get code or make it, it will be something super easy like:

HOWEVER, this will go through every document that is visibly open. Erase '.VisibleDocuments' for it to go through all of them.

I haven't tested this, but it should work for you.

 

Dim oDoc As Document

 

For Each oDoc in ThisApplication.Documents.VisibleDocuments

If 

With oDoc

         ' .Activate

          .Rebuild

          .Save

          .Close

End with

 

Next


--------------------------------------
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
0 Likes

MechMachineMan
Advisor
Advisor
It might require a few runs by the time it works its way up to the top level as it wont necessarily start at the bottom level documents, as it is coded.

--------------------------------------
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
0 Likes

Anonymous
Not applicable
Only need it for single .ipt files. The plan was to open say 20 or 30 at a time.

Sent from my iPhone
0 Likes

MechMachineMan
Advisor
Advisor
The .visibledocuments should accomplish that.

--------------------------------------
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
0 Likes

MechMachineMan
Advisor
Advisor

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
0 Likes

Anonymous
Not applicable

Thanks for the direction,its working but it works on .ipt files only

 

 

0 Likes

MechMachineMan
Advisor
Advisor
Hmmm. Could need .Save2(True) or .Rebuild2(True) instead of their counterparts.

--------------------------------------
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
0 Likes

Anonymous
Not applicable

I have done close to 5,000 ipt files this morning, but I was given a list of assemblies too.

 

I will need something, but thanks for your input at lunch hour I am going to re-post the code her so others may use.

0 Likes

Anonymous
Not applicable

Ilogic for Rebuild and Save all .ipt Files

 

For Each oDoc in ThisApplication.Documents.VisibleDocuments

 

With oDoc

         ' .Activate

         .Rebuild

         .Save

         .Close

End With

Next

 

 

 

0 Likes

Anonymous
Not applicable

Stil cant figure out why it wont with assembly or drawing files.

 

Any clue

0 Likes

MechMachineMan
Advisor
Advisor
you could always try the below to see if it works with assemblies, and just use they keyboard shortcut to access the iTrigger.
Alt + G + J + K + T + R


trigger=iTrigger0

Dim oDoc As Document = ThisApplication.ActiveDocument
With oDoc
' .Activate
.Rebuild
.Save
.Close
End With

--------------------------------------
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
0 Likes

MechMachineMan
Advisor
Advisor

Also, Rebuild does not work on drawing files. Best you can do it .Update. Which might be what fixes the other issue for you anyways.

so

 

 

For Each oDoc in ThisApplication.Documents.VisibleDocuments

 

If oDoc.DocumentType() = kAssemblyDocumentObject Or kDrawingDocumentObject

With oDoc

         ' .Activate

         '.Rebuild

         .Update

         .Save

         .Close

End With

 

Else

With oDoc

         ' .Activate

         .Rebuild

         '.Update

         .Save

         .Close

End With

End if

Next


--------------------------------------
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
0 Likes