09-15-2022
03:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-15-2022
03:39 PM
Try this one & see if you're still getting the error. I changed the name & path variables slightly because I wasn't sure what was being entered into the Sub. This will overwrite the file in the specified folder if it already exists, so you'd have to write a check if you don't want that to be the case.
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)
Dim oFileName As String = "Save Melter Model.ipt"
Dim oFilePath As String = "C:\Temp\"
'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 = oProjectMgr.ActiveDesignProject
Dim oTemplatesPath As String = oProject.TemplatesPath
Dim oDoc As PartDocument = g_inventorApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, oTemplatesPath & "/English/OC Standard.ipt", True)
Try
oDoc.SaveAs(oFilePath + oFileName, False)
Catch ex As Exception
MsgBox("Copy didn't work!.... see error message below:" & vbNewLine & ex.Message)
Exit Sub
End Try
End Sub
If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
If this helped you, please click LIKE.