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

 

 

        Private Sub m_AppEvents_OnActivateDocument(ByVal DocumentObject As Inventor._Document, _
                                                    ByVal BeforeOrAfter As Inventor.EventTimingEnum, _
                                                     ByVal Context As Inventor.NameValueMap, _
                                                    ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_AppEvents.OnActivateDocument
            If BeforeOrAfter <> EventTimingEnum.kAfter Then

                Exit Sub

            End If
            Dim odoc As Inventor.Document
            odoc = g_inventorApplication.ActiveEditDocument
            Dim eDocumentType As DocumentTypeEnum = odoc.DocumentType
            Dim chb As CheckBox
            Dim sDocumentType As String = "Unknown"
            Select Case eDocumentType
                Case DocumentTypeEnum.kAssemblyDocumentObject
                    For Each a As Control In oform.GroupBox1.Controls
                        If TypeOf a Is Windows.Forms.TextBox Then
                            a.Text = Nothing
                        End If
                    Next
                    Dim odef As AssemblyComponentDefinition = odoc.componentdefinition
                    Dim occ As ComponentOccurrence
                    For Each occ In odef.Occurrences
                        If TypeOf occ.Definition Is AssemblyComponentDefinition Then
                            '              oForm.ComboBox1.Items.Add(occ.Name)
                        End If
                    Next

                    oform.TextBox1.Text = odef.Parameters.UserParameters.Item("height").Value * 10
                    oform.TextBox2.Text = odef.Parameters.UserParameters.Item("width").Value * 10
                    oform.TextBox3.Text = odef.Parameters.UserParameters.Item("depth").Value * 10
                    oform.TextBox4.Text = odef.Parameters.UserParameters.Item("front_bolt_qty").Value
                    oform.TextBox5.Text = odef.Parameters.UserParameters.Item("front_bolt_distance").Value * 10
                    oform.TextBox6.Text = odef.Parameters.UserParameters.Item("top_bottom_bolt_qty").Value
                    oform.TextBox7.Text = odef.Parameters.UserParameters.Item("top_bottom_bolt_distance").Value * 10
                    oform.GroupBox1.Text = odoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value
                    For idx = 1 To oform.GroupBox1.Controls.Count
                        chb = oform.GroupBox1.Controls.Item(idx)
                        If odoc.PropertySets.Item("Inventor User Defined Properties").Item(oform.GroupBox1.Controls.Item(idx).Text).Value = "1" Then

                            chb.Checked = 1
                        Else
                            chb.Checked = 0
                        End If

                    Next

                    '  sDocumentType = "Assembly Document"
                    '      oForm.ComboBox1.Items.Clear()
                    ' oForm.TextBox1.Text = ""
              Case DocumentTypeEnum.kPartDocumentObject
                    sDocumentType = "Part Document"
                    Dim opdef As PartComponentDefinition = odoc.componentdefinition
                    For Each a As Control In oform.GroupBox1.Controls
                        If TypeOf a Is Windows.Forms.TextBox Then
                            a.Text = Nothing
                        End If
                    Next
                    oform.GroupBox1.Text = odoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value

                    For idx = 1 To oform.GroupBox1.Controls.Count
                        chb = oform.GroupBox1.Controls.Item(idx)

                        If odoc.PropertySets.Item("Inventor User Defined Properties").Item(oform.GroupBox1.Controls.Item(idx).Text).Value = "1" Then

                            chb.Checked = 1
                        Else
                            chb.Checked = 0
                        End If

                    Next
                    oform.TextBox1.Text = opdef.Parameters.UserParameters.Item("height").Value * 10
                    oform.TextBox2.Text = opdef.Parameters.UserParameters.Item("width").Value * 10
                    oform.TextBox3.Text = opdef.Parameters.UserParameters.Item("depth").Value * 10
                    oform.TextBox4.Text = opdef.Parameters.UserParameters.Item("front_bolt_qty").Value
                    oform.TextBox5.Text = opdef.Parameters.UserParameters.Item("front_bolt_distance").Value * 10
                    oform.TextBox6.Text = opdef.Parameters.UserParameters.Item("top_bottom_bolt_qty").Value
                    oform.TextBox7.Text = opdef.Parameters.UserParameters.Item("top_bottom_bolt_distance").Value * 10

            End Select
     End Sub