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.
Solved! Go to Solution.
Solved by santoshr0114. Go to Solution.
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
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