Set the document as Active Document

Set the document as Active Document

Anonymous
Not applicable
3,319 Views
2 Replies
Message 1 of 3

Set the document as Active Document

Anonymous
Not applicable

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.

0 Likes
Accepted solutions (1)
3,320 Views
2 Replies
Replies (2)
Message 2 of 3

Mike.Wohletz
Collaborator
Collaborator

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

 

 

 

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

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

 

0 Likes