VBA Excel and Inventor

VBA Excel and Inventor

Anonymous
Not applicable
753 Views
4 Replies
Message 1 of 5

VBA Excel and Inventor

Anonymous
Not applicable

Hello there,

 

i have a crazy question 🙂

 

do someone know how can i open a Inventor file, update my file (run a iLogic rule), open the idw from that part, a save it as dwg, and than close the inventor parts.

 

All that should run Hidden.

 

I would bie thankful!

 

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

MechMachineMan
Advisor
Advisor
Here is vb.net that accesses inventor for you. Unfortunately it actually probably isn't of much us due to the quirks with vba that are different that much of this method. But I think the idea is somewhat there.
Option Compare Text
'If used outside of inventor, must add reference to Inventor Object Library

Imports System
Imports System.Type
Imports System.Activator
Imports Inventor
Imports System.Runtime.InteropServices

	Sub Main()
		Dim oInv_App As New CL_InventorApp
		Dim oDoc As Document = oInv_App.ActiveDoc
		
		Dim oTransActmanager As TransactionManager = oInv_App.InventorInstance.TransactionManager
		Dim oTransaction As Transaction = oTransActmanager.StartTransaction(oDoc, "Bulk Add Revision Row")
		
                'Functional Code here
' Transactions are not essential and can be removed, but add undo abilities during the instance

oTransaction.End End Sub Public Class CL_InventorApp Dim Public InventorInstance As Inventor.Application Dim Public ActiveDoc As Inventor.Document Dim _started As Boolean Public Sub New() Try InventorInstance = Marshal.GetActiveObject("Inventor.Application") ActiveDoc = InventorInstance.ActiveDocument Catch ex As Exception Try Dim invAppType As Type = GetTypeFromProgID("Inventor.Application") InventorInstance = CreateInstance(invAppType) InventorInstance.Visible = True ActiveDoc = InventorInstance.ActiveDocument _started = True Catch ex2 As Exception MsgBox(ex2.ToString()) MsgBox("Unable to get or start Inventor") Exit Sub End Try End Try End Sub End Class

--------------------------------------
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
Message 3 of 5

Anonymous
Not applicable

Thank you for the replay

i dont have VB 

i just try to run the macro in excel VBA and it doesen work 😞

0 Likes
Message 4 of 5

MechMachineMan
Advisor
Advisor
Yes, the idea is there, but you will need to convert it to vba.

--------------------------------------
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
Message 5 of 5

Anonymous
Not applicable

Hello

 

i just installed the vb studio on my computer.

 

Now, i what to make a exe to open the inventor file, make update, run rule (rule1), open idw from that part, run update und save the idw as dwg on my destom.

An that schould run hidden.

Can you tell me, how can I make it to work? 

0 Likes