Addins - Showing a form from a ribbon button click

Addins - Showing a form from a ribbon button click

SteveLainson6531
Contributor Contributor
819 Views
2 Replies
Message 1 of 3

Addins - Showing a form from a ribbon button click

SteveLainson6531
Contributor
Contributor

Well the process of turning a very simple Inventor macro into a registry free addin has been a painfully slow and complicated process but I've finally got the Addin to load through an StandardAddInServer.vb file.

 

Now Im stuck at what I thought would be simple:

 

My OnExecute sub associated with my ribbon button is running and I can sucessfully test it with a Msgbox ("Hooray"), but I cannot simply now load my form (called FrmPointsHarvest) with FrmPointsHarvest.Show or anything like it.

 

 

My form is a seperate FrmPointsHarvest.vb file containing basic code and with a header like this :

 

Public Class FrmPointsHarvest
    Private InvApp As Inventor.Application

    Dim oDoc As Document

    Dim oPartDoc As PartDocument
    Dim oDef As PartComponentDefinition


    Dim oAssyDoc As AssemblyDocument
    Dim oAsmDef As AssemblyComponentDefinition
    Dim oLeafOccs As ComponentOccurrencesEnumerator
    Dim Part_Type As String


    Dim oExcelApplication As Excel.Application 'Create a new Excel instance
    Dim oBook As Excel.Workbook    'An excel workbook object
    Dim oSheet As Excel.Worksheet 'An Excel worksheet object

    Dim OutputFile As String 'name of Excel File

    Public debugAddIn As PointsHarvester.StandardAddInServer



    Public Sub New(InvApp As Inventor.Application)
        ' Этот вызов является обязательным для конструктора.
        InitializeComponent()
        Me.InvApp = InvApp

        Dim Doc As Inventor.Document = InvApp.ActiveDocument

        Select Case Doc.DocumentType
            Case Inventor.DocumentTypeEnum.kPartDocumentObject
                Dim PartDoc As Inventor.PartDocument = DirectCast(Doc, Inventor.PartDocument)

            Case Inventor.DocumentTypeEnum.kAssemblyDocumentObject
                Dim AssDoc As Inventor.AssemblyDocument = DirectCast(Doc, Inventor.AssemblyDocument)

        End Select

    End Sub

    Private Sub FrmPointsHarvest_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        LblDetails.Text = ""
        ' Set a reference to the active document. This assumes a document is open.
        oDoc = InvApp.ActiveDocument  '.activedocument

        'if a part or assembly
        Select Case oDoc.DocumentType
            Case 12290
                Part_Type = "IPT"
                oPartDoc = oDoc
                BtnHarvest.Enabled = True
            Case 12291
                Part_Type = "IAM"
                oAssyDoc = oDoc
                BtnHarvest.Enabled = True
            Case Else
                Part_Type = "Other"
                BtnHarvest.Enabled = False
                MsgBox(oDoc.DocumentType & " is Open. You must open an Inventor Part (.IPT) or Assembly (.IAM) file.", vbOKOnly, "FORTIS 3D Point Harvester")
                Me.Close()
        End Select

        LblDetails.Text = oDoc.DisplayName & " (" & Part_Type & ")" & " is Open with " & oDoc.ReferencedDocuments.Count & " References"

    End Sub

'....etc.etc

How on earth do I get this form to load?

 

Thanks

 

0 Likes
Accepted solutions (1)
820 Views
2 Replies
Replies (2)
Message 2 of 3

rjay75
Collaborator
Collaborator
Accepted solution

You need to create a new instance of the form and show it.

 

Dim frm As New FrmPointsHarvest(invApp)

frm.Show()

 

0 Likes
Message 3 of 3

SteveLainson6531
Contributor
Contributor

Thanks Rodney........

 

Seems obvious now !

 

S

0 Likes