Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ThisApplication in vb.net on 3rd level

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
mslosar
384 Views, 2 Replies

ThisApplication in vb.net on 3rd level

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.

2 REPLIES 2
Message 2 of 3
alewer
in reply to: mslosar

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.

Message 3 of 3
mslosar
in reply to: alewer

That works! Thanks 🙂

 

I also found turning it into a global variable works too, but only after replacing all instances the original m_inventerApplicatoin.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report