Saveas on open file in .NET 2003 / Inventor 9

Saveas on open file in .NET 2003 / Inventor 9

Anonymous
Not applicable
184 Views
1 Reply
Message 1 of 2

Saveas on open file in .NET 2003 / Inventor 9

Anonymous
Not applicable



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. 


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.


color=#000000>
 

I would greatly
appreciate any help that's out there!


color=#000000>
 

Thank
you,


color=#000000>
 

Steve
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)

0 Likes
185 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable


maybe:


oPart.SaveAs PartToSave,
False


?



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">




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.


size=2>

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. 


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.


color=#000000>
 

I would greatly
appreciate any help that's out there!


color=#000000>
 

Thank
you,


color=#000000>
 

Steve
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)

0 Likes