07-07-2016
11:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
07-07-2016
11:00 AM
There was a problem with the mentioned line in your code. You have mentioned it as ThisDrawing that leads to the error because the opened document was not a drawing document.
modelFullFileName = ThisDrawing.ModelDocument.FullFileName
I hope the modified code will be helpful.
Dim oDoc As Document
oDoc = ThisDoc.Document
Dim oDocType As Inventor.DocumentTypeEnum
oDocType = oDoc.DocumentType
Dim drwquestion As String
Dim modelFullFileName As String
If oDocType = kPartDocumentObject Then
If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
MessageBox.Show("You have a sketch active in a part file.", "iLogic")
Else
MessageBox.Show("This is a part file.", "iLogic")
End If
Else If oDocType = kAssemblyDocumentObject Then
If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
MessageBox.Show("You have a sketch active in an assembly file.", "iLogic")
Else
MessageBox.Show("This is an assembly file.", "iLogic")
End If
Else If oDocType = kDrawingDocumentObject Then
drwquestion = MessageBox.Show("This is a drawing file, Do you want to open the file?","Ilogic", MessageBoxButtons.YesNo,MessageBoxIcon.Question)
'set condition based on answer
If drwquestion = vbYes Then
' 'Try
modelFullFileName = oDoc.FullFileName
' 'Catch
' 'End Try
ThisApplication.Documents.Open(modelFullFileName, True)
ElseIf drwquestion = vbNo Then
End If
' Return
End IfIf you find this was helpful please accept this as solution / press the kudos button ![]()
Cheers,
SK.