Inventor Add in - reference active document in form button

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I've created an add-in using Inventor 2017 addin template with a basic form. The addin loads fine and I'm getting the form to appear. I'm going to have various buttons on the form that each add a custom iProperty. How do I declare the active document and custom prop set globally to use in each buttons sub.
I thought this would work but it not...
Imports Inventor
Public Class Form1
Dim oDoc As Document = g_inventorApplication.ActiveDocument
Dim oCustomPropertySet As PropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")
Dim prop As Inventor.Property
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Try
prop = oCustomPropertySet.Item("SAW")
Catch
oCustomPropertySet.Add("5", "SAW")
End Try
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Try
prop = oCustomPropertySet.Item("PUNCH")
Catch
oCustomPropertySet.Add("10", "PUNCH")
End Try
End Sub
End Class