Message 1 of 2
Saveas on open file in .NET 2003 / Inventor 9

Not applicable
11-14-2005
03:48 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
color=#000000>The code below produces the following error on
face=Arial color=#ff0000 size=2>oPart.SaveAs(PartToSave, False)
color=#000000>in the code listed below.
An unhandled exception of type
'System.NullReferenceException' occurred in vcLogic.exe
Additional information: Object reference not set
to an instance of an object.
I am trying to
save the current open file to a filename. The filename is working
great. I suspect I cannot find the current part because perhaps it is
looking for multiples or a name. I have no clue how to format this in code
to reference it. I would like to have it error out when zero or more than
one inventor files are open / current. Otherwise, it should work.
save the current open file to a filename. The filename is working
great. I suspect I cannot find the current part because perhaps it is
looking for multiples or a name. I have no clue how to format this in code
to reference it. I would like to have it error out when zero or more than
one inventor files are open / current. Otherwise, it should work.
color=#000000>
I'm not worried
about how to have it test for the error conditions, but to simply work here,
with the one file I do have open. Perhaps I am unfamiliar with the oApp
setting, though I saw an Excel example that seemed good. Perhaps I ac
missing a step in getting to defining the oPart.
about how to have it test for the error conditions, but to simply work here,
with the one file I do have open. Perhaps I am unfamiliar with the oApp
setting, though I saw an Excel example that seemed good. Perhaps I ac
missing a step in getting to defining the oPart.
color=#000000>
I would greatly
appreciate any help that's out there!
appreciate any help that's out there!
color=#000000>
Thank
you,
you,
color=#000000>
Steve
Anderson
Anderson
Dim oApp As Inventor.Application = GetObject(,
"Inventor.Application")
Dim oDoc As Inventor.Document =
oApp.ActiveEditObject
Dim oPart As Inventor.Document
If oApp.ActiveDocumentType.kPartDocumentObject = True
Then
oPart =
oDoc.ActiveDocument
ElseIf
oApp.ActiveDocumentType.kAssemblyDocumentObject = True Then
oPart =
oDoc.ActiveEditObject
End If
oPart.SaveAs(PartToSave,
False)