I reposition the code located in the other thread.
The error was in that you generated a new file instead of opening an existing one, and then you wanted to place a view of this file without saving, that's why you got that error.
This code I have tried and it has worked for me. I hope it helps your final code
regards
Sub CreateDrawing()
DirTemplate = "C:\Users\Public\Documents\Autodesk\Inventor 2020\Templates\en-US\Metric\ISO.idw"
PartDir = "E:\Inventor\Planos en Inventor\550.05.06 Ch6.4.ipt"
'Declare invDoc, which is the drawing being generated
Dim invDoc As DrawingDocument
'Set up drawing to use Gear Standard drawing template
Set invDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, DirTemplate)
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Open(PartDir, False)
Dim oSheet As Sheet
Set oSheet = invDoc.Sheets.Item(1)
Dim point1 As Point2d
Set point1 = ThisApplication.TransientGeometry.CreatePoint2d(1, 1)
Dim oBaseView As DrawingView
Set oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc, ThisApplication.TransientGeometry.CreatePoint2d(12, 15), 0.5, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, "Default")
oPartDoc.Close
'Message box to indicate successful creation
MsgBox "Created " & invDoc.DisplayName
End Sub
Please accept as solution and give likes if applicable.
I am attaching my Upwork profile for specific queries.
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn