Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

get the right inventor instance

1 REPLY 1
Reply
Message 1 of 2
Burnit87
455 Views, 1 Reply

get the right inventor instance

i'm building a DXF generator, and succeeded

the problem i now have that is always targerts the first inventor instance

i've been able to count the number of inventors running but i need to be able to choose the right one

so i made a list box where all the inventors are displayed and it returns the value of the one i selected

the get active object targets the first one, so i need to use something else or make the selected inventor the first one

i'm using inventor 2014 and visual basic 2010 express

any help would be appreciated

Björn

 

 

here's my code so far:

 

InitializeComponent()

 

 

Dim myProcesses() AsProcess

myProcesses = Process.GetProcessesByName("Inventor")

 

Dim invcounter AsInteger = 0

 

Dim oProcess AsProcess

ForEach oProcess In myProcesses

invcounter = invcounter + 1

Next

 

 

 

SelectCase invcounter

CaseIs = 0

MessageBox.Show("Open Inventor")

Me.Close()

 

CaseIs = 1

Try

m_InvApp = Marshal.GetActiveObject("Inventor.Application")

Catch ex AsException

MsgBox("Unable to get Inventor")

Return

EndTry

 

 

CaseIs > 1

Form2.invsel = Nothing

Me.Visible = False

Dim invpro AsProcess

ForEach invpro In myProcesses

Form2.ListBox1.Items.Add(invpro.MainWindowTitle)

Next

Form2.ShowDialog()

 

ForEach invpro In myProcesses

If invpro.MainWindowTitle = Form2.invsel.ToString Then

'need to do something here so vb.net targets the right inventor

Try

m_InvApp = Marshal.GetActiveObject("Inventor.Application")

 

MsgBox(m_InvApp.Caption.ToString)

Catch ex AsException

MsgBox("Unable to get Inventor 2")

Return

EndTry

Exit For

 

EndIf

Next

 

 

BP
1 REPLY 1
Message 2 of 2
adam.nagy
in reply to: Burnit87

Hi Björn,

 

You cannot make the selected instance the first one - in the sence that GetActiveObject() would return it.

The function always returns the oldest instance of the product. It's nothing Inventor specific - you'll find the same in case of other products as well: AutoCAD, MS Excel, Word, etc

 

You might be able to get back the object of a specific instance through the Running Objects Table (ROT), but I don't have much experience with that, and looking around it seems you might run into issue with that:

http://adndevblog.typepad.com/autocad/2013/12/accessing-com-applications-from-the-running-object-tab...

 

Maybe you could do what you want inside a temporary Inventor instance, or depending what exactly you are trying to export to DXF, from Inventor Apprentice as well.

 

Cheers, 



Adam Nagy
Autodesk Platform Services

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

Post to forums  

Autodesk Design & Make Report