Best place to reference the Inventor api from vb.net
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm writing my first vb.net program for Inventor and I would appreciate any advice on placing my reference to the Inventor api.
For example, I created a form and I placed the code as shown below when the Form loads.
I also capture some properties and display one value in a label and another in a text box.
' Get the Inventor Application object.
Dim invApp As Inventor.Application
invApp = GetObject(, "Inventor.Application")
' Get the active document.
Dim odoc As Inventor.Document
odoc = invApp.ActiveDocument
Dim oDocName As String
oDocName = odoc.DisplayName
'Display the Assembly Name in Form
lblAssyName.Text = oDocName
' Get the "Design Tracking Properties" property set.
Dim designTrackPropSet As Inventor.PropertySet
designTrackPropSet = odoc.PropertySets.Item("Design Tracking Properties")
' Get the "Project" property from the property set.
Dim descAssyProject As Inventor.Property
descAssyProject = designTrackPropSet.Item("Project")
' Display Project Number on Form
TxtProjectNumber.Text = descAssyProject.Value
However, Visual Studio shows the variable is not declared in the following sub program.
Private Sub BtnOK_Click(sender As Object, e As EventArgs) Handles BtnOK.Click
If TxtProjectNumber.Text = "" Then
MsgBox("Assembly Project Number cannot be blank")
TxtProjectNumber.Focus()
Else
AssyProjectNumber = TxtProjectNumber.Text
' Set the value of the property using the current value of the text box.
descAssyProject.value = TxtProjectNumber.Text
End If
End Sub