Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: tjvz85

Hello tjvz85,

 

I'm not sure if I understand your request. Can you give me more detail as to what you are looking to do?

 

The code that you have there will create a new sheet using the "C Size, 4 View" sheet format. It will use the block.ipt as the model for the sheet format. So when it first starts, there is no model yet. It's a blank sheet therefore this is no model path to retrieve.  Then it will look for the block.ipt in C:\temp and use that as the model for the sheet format. The block.ipt is hard coded into the rule. Are you asking if you can be prompted for the model? If so, you can do something like this. Hopefully that's what you are looking for. If not, repost and let's try again.

 

Dan

' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

'Set a reference to the sheet format named "C size, 4 view"
Dim oFormat As SheetFormat
Try
	oFormat = oDrawDoc.SheetFormats.Item("C size, 4 view")
Catch
	MessageBox.Show("Error: C size, 4 view might not exist.", "iLogic")
	Return
End Try

Dim openfiledia As New OpenFileDialog()
Dim strModelFile As String

With openfiledia
	.Filter = "Autodesk Inventor Part|*.ipt|Autodesk Inventor Assembly|*.iam"
	.Multiselect = False
	'if user cancelled, exit this subroutine
	If .ShowDialog() = DialogResult.Cancel Then
		Exit Sub
	End If
	
	strModelFile = .FileName
End With

'Open the model document invisible
Dim oModel As Document
oModel = ThisApplication.Documents.Open(strModelFile, False)

'Create a new sheet based on the sheet format using the specified model
Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets.AddUsingSheetFormat(oFormat, oModel)