Message 1 of 4
VB.NET - Check if Inventor is open question

Not applicable
11-14-2005
12:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In the code below, I want to check if Inventor is open, if so I will discern
if the part is a part, or referenced from an assembly. Finally, I will do a
save-as to a new filename.
Right now, oApp is nothing, wvwn when I have Inventor open. I believe this
is the problem. In .NET, I cannot use things like ThisApplication or
ThisDocument.
I do have references to Inventor and InventorApprentice in my solution
explorer for VB.NET. Because I am planning on running this code while in an
editable drawing, I believe the Inventor reference is the ont that applies.
Thanks in advance for any answers that can be provided.
Steve Anderson
' Check if Inventor is open, if so define file type in use.
Dim oApp As Inventor.Application
Dim oDoc As Inventor.Document = oApp.ActiveEditObject
oApp.ActiveDocument.Activate()
If oApp.ActiveDocumentType.kPartDocumentObject = True Then
Dim oPart As Inventor.Document = oApp.ActiveDocument
ElseIf oApp.ActiveDocumentType.kAssemblyDocumentObject = True Then
Dim oPart As Inventor.Document = oApp.ActiveEditObject
End If
if the part is a part, or referenced from an assembly. Finally, I will do a
save-as to a new filename.
Right now, oApp is nothing, wvwn when I have Inventor open. I believe this
is the problem. In .NET, I cannot use things like ThisApplication or
ThisDocument.
I do have references to Inventor and InventorApprentice in my solution
explorer for VB.NET. Because I am planning on running this code while in an
editable drawing, I believe the Inventor reference is the ont that applies.
Thanks in advance for any answers that can be provided.
Steve Anderson
' Check if Inventor is open, if so define file type in use.
Dim oApp As Inventor.Application
Dim oDoc As Inventor.Document = oApp.ActiveEditObject
oApp.ActiveDocument.Activate()
If oApp.ActiveDocumentType.kPartDocumentObject = True Then
Dim oPart As Inventor.Document = oApp.ActiveDocument
ElseIf oApp.ActiveDocumentType.kAssemblyDocumentObject = True Then
Dim oPart As Inventor.Document = oApp.ActiveEditObject
End If