Error when saving new part file in API

Error when saving new part file in API

cstephens58F4Q
Contributor Contributor
140 Views
1 Reply
Message 1 of 2

Error when saving new part file in API

cstephens58F4Q
Contributor
Contributor

Any ideas on fixing the error code im getting below when running this portion of code. Im trying to save as the part file i just created to a previously set directory.  Here is the line the error being created on and below that is the error im getting.

 

oDoc.SaveFileAs(oPath & loc)

 

error:

System.MissingMemberException: 'Public member 'SaveFileAs' on type '_DocumentClass' not found.'

 

Issue area:

    Public Sub CreateStandardPart(x_length As Double, y_length As Double, z_length As Double, loc As String, oPath As String)

        MsgBox("here with x length = " & x_length)


        'Create a new part with your desired part template
        'Dim oApp As Class = g_inventorApplication

        Dim oProjectMgr As DesignProjectManager = g_inventorApplication.DesignProjectManager

        Dim oProject As DesignProject
        oProject = oProjectMgr.ActiveDesignProject

        Dim oTemplatesPath As String
        oTemplatesPath = oProject.TemplatesPath

        Dim oDoc As PartDocument = g_inventorApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, oTemplatesPath & "/English/OC Standard.ipt", True)

        oDoc.Activate()

        oDoc.SaveFileAs(oPath & loc)



    End Sub

 

Here is how I am calling out oPath:

SaveFileDialog1.Filter = "Assembly|*.iam"
        SaveFileDialog1.InitialDirectory = "C:\Temp"
        SaveFileDialog1.Title = "Save Melter Model"
        SaveFileDialog1.ShowDialog()

        If SaveFileDialog1.FileName IsNot "" Then

            SaveFileDialog1.OpenFile()

            oFile = SaveFileDialog1.FileName




        End If

        '''''
        ''Sets directory for future use
        '''''

        Dim oPath_ As String = oFile

        Dim oPat As Integer = InStrRev(oPath_, "\")

        Dim oPath As String = Mid(oPath_, 1, oPat)

 

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

A.Acheson
Mentor
Mentor

First think I notice. How are you bringing in "g_inventorApplication" into the sub routine "CreateStandardPart"

 

Have you set the inventor application object earlier? 

 

Also I don't think  "SaveAsFile" method exists, it should be 

Syntax

Document.SaveAsFileName As String, SaveCopyAs As Boolean )

 

oDoc.SaveAs(oPath & loc)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes