Message 1 of 5
Update model when opening the drawing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
In the code below I'm using the "on open" event to identify when a drawing is opened. I'm then trying to grab the model used in the drawing and update multiple model states within it.
The only way I've found that works, is to use the document open command "oDocOpen = ThisApplication.Documents.Open(FullFileName, True)". But in order to update multiple model states I have to set visibility to "True" and physically open the model, which I would rather not have to do.
Is there a better way to accomplish this?
Private Sub m_ApplicationEvents_OnOpenDocument(ByVal DocumentObject As Inventor._Document, ByVal FullDocumentName As String,
ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_ApplicationEvents.OnOpenDocument
If BeforeOrAfter = EventTimingEnum.kAfter And DocumentObject Is ThisApplication.ActiveDocument Then
If localEventsEnabled = False Then Exit Sub
Select Case True
Case DocumentObject.DocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject
Dim oDocOpen, oDrawDocOpen As Inventor.Document
Dim FullFileName As String = Nothing
Select Case True
Case My.Computer.FileSystem.FileExists(IO.Path.ChangeExtension(FullDocumentName, "iam"))
FullFileName = IO.Path.ChangeExtension(FullDocumentName, "iam")
oDocOpen = ThisApplication.Documents.Open(FullFileName, True)
Case My.Computer.FileSystem.FileExists(IO.Path.ChangeExtension(FullDocumentName, "IAM"))
FullFileName = IO.Path.ChangeExtension(FullDocumentName, "IAM")
oDocOpen = ThisApplication.Documents.Open(FullFileName, True)
Case Else
Exit Sub
End Select
Dim inv As InventorLink = New InventorLink(oDocOpen)
Try : Dim oTest As String = inv.getParam("pane_type") : oDocOpen.Close() : Exit Sub : Catch : End Try
Try : Dim GLS_ID As Integer = inv.getParam("GLASS_ID") : Catch : oDocOpen.Close() : Exit Sub : End Try
Dim glassRule As Glass_Master_Rule = New Glass_Master_Rule
glassRule.Main(DocumentObject, oDocOpen, 1)
oDrawDocOpen = ThisApplication.Documents.Open(FullDocumentName, True)
End Select
End If
End Sub