Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
cstephens58F4Q
351 Views, 6 Replies

Issue creating a new part file in API

Im sure im overlooking something small but I am trying to get a part file created before I edit it with passed variables. The issue Im having is the line below is giving me the error "Error BC30469 Reference to a non-shared member requires an object reference. "

 

Dim oDoc As PartDocument = Documents.Add(DocumentTypeEnum.kPartDocumentObject, oTemplatesPath & "standard.ipt", False)

 

Below is this full portion of code:

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


        'Create a new part with your desired part template
        Dim oProjectMgr As DesignProjectManager

        Dim oProject As DesignProject
        oProject = oProjectMgr.ActiveDesignProject

        Dim oTemplatesPath As String
        oTemplatesPath = oProject.TemplatesPath

        Dim oDoc As PartDocument = Documents.Add(DocumentTypeEnum.kPartDocumentObject, oTemplatesPath & "standard.ipt", False)

        oDoc.OpenFile()

        oDoc.SaveAs(loc & oPath, True)

        oDoc.Close(False)

    End Sub

 Let me know if you have any ideas. Thanks