Not sure my title is proper, but it's the best I can come up under the circumstances.
I've been moving to addins and vb.net and have been doing OK. I've been using the paper 'Taking the step from VBA to Inventor Add-ins' as a bit of a guideline.
Based on that, in your StandardAddInServer.vb file, there will be a line:
m_inventorApplication = addInSiteObject.Application
From there, i add my buttons/panels/ribbons/etc....culminating in the OnExecute event.
Private Sub myButton1_OnExecute(byVal Context as Inventor.NameValueMap)
myFunction1(m_inventorApplication)
end Sub
Then in myModule.vb i have the code
Private Sub myFunction1(ThisApplication as Inventor.Application)
To my understand this sends the Inventor Application to the function. And this part works just fine.
My problem seems to be that myFunction1 calls myFunction2 which also needs ThisApplication.
Private Sub myFunction1(ThisApplication as Inventor.Application)
{Bunch of stuff happens here}
myFunction2("Text")
end sub
Private Sub myFunction2(dType as string)
uses ThisApplication
{Stuff happens here differently depending on the string sent}
end sub
How do i go about sending the Inventor application to function2, along with the string? I've tried a few things, but can't get it to work. Apparently m_inventorApplication HAS to be in the OnExecute on the myFunction1 line - myFunction1(m_inventorApplication) - Any attempt are removing that fails.
Any help/explanation would be appreciated as i have a couple other functions to translate at somepoint that go 3-4 levels deep.
Solved! Go to Solution.
Solved by alewer. Go to Solution.
If I correctly understand your problem, the following should work. I don't know what you're trying to accomplish, but this will use two functions to give a messagebox of Inventor's caption and the text "ABC."
Public Class myModule Private Sub mySub1(ByVal InventorApp As Inventor.Application) mySub2(InventorApp, "ABC") End Sub Private Sub mySub2(ByVal InventorApp As Inventor.Application, ByVal Text As String) MsgBox(InventorApp.Caption & Text) End Sub End Class
If that doesn't work, post your entire myModule.vb and I'll give it another try.
That works! Thanks 🙂
I also found turning it into a global variable works too, but only after replacing all instances the original m_inventerApplicatoin.