Here is the code. The line for running the rule in the drawing document is the second to last line in the code. I even added a message box that says "loaded" before the runrule line so that I could give time for the drawing document to open up.
And yes I already have the rule in my drawing document for creating the specific views.
SyntaxEditor Code Snippet
'define the active document
oDoc = ThisApplication.ActiveDocument
'create a file dialog box
Dim oFileDlg As inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
'check file type and set dialog filter
If oDoc.DocumentType = kPartDocumentObject Then
oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt"
Else If oDoc.DocumentType = kAssemblyDocumentObject Then
oFileDlg.Filter = "Autodesk Inventor Assembly Files (*.iam)|*.iam"
Else If oDoc.DocumentType = kDrawingDocumentObject Then
oFileDlg.Filter = "Autodesk Inventor Drawing Files (*.idw)|*.idw"
End If
'set the directory to open the dialog at
oFileDlg.InitialDirectory = ThisDoc.WorkspacePath()
'set the file name string to use in the input box
oFileDlg.FileName = iProperties.Value("Project", "Part Number")
'work with an error created by the user backing out of the save
oFileDlg.CancelError = True
On Error Resume Next
'specify the file dialog as a save dialog (rather than a open dialog)
oFileDlg.ShowSave()
'catch an empty string in the imput
If Err.Number <> 0 Then
MessageBox.Show("No File Saved. You must save the file before creating a drawing", "Error")
ElseIf oFileDlg.FileName <> "" Then
MyFile = oFileDlg.FileName
'save the file
oDoc.SaveAs(MyFile, False) 'True = Save As Copy & False = Save As
MessageBox.Show(ThisDoc.Path & "\" & oDoc.DisplayName," ")
ThisApplication.documents.add(kDrawingDocumentObject, "C:\Users\Public\Documents\Autodesk\Inventor 2014\Templates\STSH Standard 2015.idw", True)
MessageBox.Show("Loaded")
iLogicVb.RunRule(ThisApplication.Documents.Item(ThisApplication.Documents.Count), "CREATE DRAWING")
End If