Hi @ABHUT_9090. There are likely multiple ways to do what you want, but I have something that may work for you. This iLogic rule, when ran, should first check to make sure a DrawingDocument is 'active', then show a Open dialog, which will allow you to browse to a file and select it. Then, it will check to make sure something was returned from that dialog. Then it will copy the full file name of that chosen file to something similar to Inventor's clipboard. Then it will execute a command for creating a base drawing view. It should pick up on the file name we sent into Inventor's clipboard as which file/model to create the view for, so you won't have to re-specify something.
Sub Main
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule to work. Exiting.", vbCritical, "iLogic")
Exit Sub
End If
oFile = GetFile
If String.IsNullOrEmpty(oFile) Then Exit Sub 'or Return
'The following line sends the file name to Inventor's Clipboard, this can be used to automatically
'fill in a dialog that would normally pop-up asking for what model you want to place into your drawing.
ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, oFile)
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingBaseViewCmd").Execute
End Sub
Function GetFile() As String
Dim oFileName As String = ""
Dim oDoc As Inventor.Document
Dim oFileDialog As Inventor.FileDialog
ThisApplication.CreateFileDialog(oFileDialog)
oFileDialog.DialogTitle = "Select A File To Create A Drawing View For."
oFileDialog.InitialDirectory = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
oFileDialog.Filter = "Autodesk Inventor Files (*.iam;*.ipt:*.ipn;*.ide) | *.iam;*ipt;*.ipn;*.ide | All files (*.*)|*.*"
oFileDialog.MultiSelectEnabled = False
oFileDialog.OptionsEnabled = False
oFileDialog.CancelError = True
oFileDialog.InsertMode = False
On Error Resume Next
oFileDialog.ShowOpen
If Err.Number <> 0 Then
'something went wrong, return empty String, and exit Function
Return oFileName
Else
oFileName = oFileDialog.FileName
Return oFileName
End If
End Function
However, that is not everything needed. With your target Template drawing open, you will need to place the iLogic rule that you put this code into, within the Event Triggers dialog (make sure it is on the 'This Document' tab), under the After Open Document event. Then save the template file. Now, every time you 'open' (not click New) it will run that rule. However, if you want it to run when you are using the New command, then choosing this template, you will want this rule under the 'New Document' event instead.

Another simpler approach, that wouldn't require any code, would be to start from the model file you want to create the drawing of, then use this technique:
Right click on the top browser node (on the Model browser of the open model document), then choose 'Create Drawing View' from that right click menu. It will still want you to select a template, if you have more than one, but it will already know what model to place a view of.

Wesley Crihfield

(Not an Autodesk Employee)