addin form won't open again

addin form won't open again

Anonymous
Not applicable
787 Views
8 Replies
Message 1 of 9

addin form won't open again

Anonymous
Not applicable

I've got an issue with my addin form.  It will open when clicking on the addin button on  my custom panel, but only on the first time after starting a new instance of Inventor.

 

This code is contained with the StandardAddInServer

 

Dim MyForm As New Form1

 

' Sample handler for the button.
Private Sub m_sampleButton_OnExecute(Context As NameValueMap) Handles m_sampleButton.OnExecute
DisplayForm()
End Sub

 

Private Sub DisplayForm()
MyForm.TopMost = True
MyForm.Show()
MyForm.BringToFront()

End Sub

 

This is my form code:

 

Imports Inventor

Public Class Form1

Dim newpoint As New System.Drawing.Point
Dim x, y As Integer

 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Close()
End Sub

 

Private Sub Panel1_MouseDown(sender As Object, e As Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
x = MousePosition.X - Me.Location.X
y = MousePosition.Y - Me.Location.Y
End Sub

 

Private Sub Panel1_MouseMove(sender As Object, e As Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
newpoint = MousePosition
newpoint.X -= (x)
newpoint.Y -= (y)
Me.Location = newpoint
End If
End Sub

 

 

End Class

 

It's like after I execute the Button1_Click sub, the m_sampleButton_OnExecute sub no longer works.

 

Any pointers as to where I'm going wrong?

0 Likes
Accepted solutions (1)
788 Views
8 Replies
Replies (8)
Message 2 of 9

bradeneuropeArthur
Mentor
Mentor
Accepted solution
Use my form.showdialog

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 9

Anonymous
Not applicable

That worked. Could you direct me to any examples of code that use a modeless form?

0 Likes
Message 4 of 9

bradeneuropeArthur
Mentor
Mentor

hi,

 

One method is a called showing Modal.

The other is showing not  Modal.

 

This explains the behavior.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 9

NachoShaw
Advisor
Advisor

Hi

 

 

I load in my form in my AddinServer like this

 

Public shared f As New frmMain

 

Then in my button command, I create a new instance like this:

 

AddinServer.f = New frmMain

AddinServer.f.ShowModal()

 

This allows me to create a new instance that I can dispose when I'm done while maintaining my original instance. If you close your AddinServer instance, its closed for that session.

 

In my Close event, I do this

 AddinServer.f.Close()
 AddinServer.f.Dispose()

 

 

Right or wrong, it works just fine for me 🙂

 

 

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 6 of 9

bradeneuropeArthur
Mentor
Mentor
Hi,

Do not exactly know what you are trying to say/do?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 7 of 9

NachoShaw
Advisor
Advisor

Hi

 

My solution may not be the best or 'official' method. what I am saying that I do is:

 

Initially, I created my form instance when I clicked my ribbon button. This then took a bit of time for the form to load as there is a fair amount of processing to do based on the assembly. My form would either display then hang (waiting for the processes to complete) or it wouldn't show until all of the processes were complete. Either way, it was hanging.

 

I now create a new blank instance when inventor loads and when I need it, a create a new instance of that. It may seam that I am doing exactly the same as my initial method but, it does load much quicker.

 

Failing that, what would be the official way of calling your form application with the ribbon button click without preloading it when inventor starts? Bearing in mind that I cant use a dialog because I need interaction. 

 

NOTE:

I added a Boolean check on my button click to check if my form was visible to prevent multiple instances being loaded...

I create a New instance on the ribbon button click because I found it best to dispose of the form when closing. (I had a couple of weird issues)

 

 

 

Cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 8 of 9

bradeneuropeArthur
Mentor
Mentor

I now create a new blank instance when inventor loads and when I need it, a create a new instance of that.

 

It may seam that I am doing exactly the same as my initial method but, it does load much quicker.

 

Failing that, what would be the official way of calling your form application with the ribbon button click without preloading it when inventor starts?

 

Create it when the add in is loaded. _MyForm as new MyForm

Show with showdialog on button click _MyForm.showdialog

 

Bearing in mind that I cant use a dialog because I need interaction. 

 

What do you mean with interaction?

You could pass your parameters to your form if you need it there of course!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 9 of 9

NachoShaw
Advisor
Advisor

Hi

 

In my AddinGlobalServer, I already have 

 

Dim f As New LoadForm

 

Then I can access the form events like Visible etc etc. When I load the form as I dialog, I cannot return to the Inventor environment and interact with it until I close my form. I need to interact with the inventor model while my form is visible. I already does this by not opening the form as Dialog.

 

 

Cheers

 

Nacho 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes