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: 

Set the document as Active Document

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
santoshr0114
2802 Views, 2 Replies

Set the document as Active Document

This is my first project in Inventor customisation

 

I am not doing this as an Autodesk Inventor Addin. I am doing this project as a Windows Application.

 

I have just created a instance of inventor and opening a file using openfiledialog and storing the path in "Filename" and checking the file extension for ".ipt & .iam". And the document is set to active active document depending upon the type of document(Part\Assembly).

 

This is some part of code where i am setting the document as Active Document

 

Dim Filename As String

If extension = ".ipt" Then
Dim oDoc As Inventor.PartDocument
oDoc = _invApp.Documents.Open(Filename, True)
oDoc = _invApp.ActiveDocument

ElseIf extension = ".iam" Then
Dim oDoc As Inventor.AssemblyDocument

oDoc = _invApp.Documents.Open(Filename, True)
oDoc = _invApp.ActiveDocument

End If

 

After this when i try the below code its giving me a warning & error

 

TreeView1.Nodes.Add(ThisApplication.ActiveDocument.DisplayName)

 

Error: 

System.NullReferenceException was unhandled
Message = Object reference not set to an instance of an object.

Warning :

A reference was created to embedded interop assembly 'stdole' because of an indirect reference to that assembly from assembly 'Microsoft.VisualBasic.Compatibility'. Consider changing the 'Embed Interop Types' property on either assembly. iPart Table

 

I am unable to proceed further due to this error. A little suggestion will be very helpful.

Regards
Santosh
2 REPLIES 2
Message 2 of 3
Mike.Wohletz
in reply to: santoshr0114

Try the following..

 

        If extension = ".ipt" Then
            Dim oDoc As Inventor.PartDocument
            oDoc = _invApp.Documents.Open(Filename, True)
            oDoc.Activate()
        ElseIf extension = ".iam" Then
            Dim oDoc As Inventor.AssemblyDocument
            oDoc = _invApp.Documents.Open(Filename, True)
            oDoc.Activate()
        End If

 

 

 

Message 3 of 3
santoshr0114
in reply to: Mike.Wohletz

No Mike.. This also does'nt work

 

Got it working by using this piece of code

oDoc = _invApp.ActiveEditObject

 

Thank You for your reply...

 

I have posted one more query can u check it out. This Is The Link

 

Regards
Santosh

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

Post to forums  

Autodesk Design & Make Report