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: 

AddIn - Active Document Issue

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
506 Views, 7 Replies

AddIn - Active Document Issue

I am creating an AddIn and ran across a problem I am not sure how to solve.  A text box is filled in with a code from a bar code scanner then I connect to tables to populate other information on the form based on this code.  It works correctly only if there is a document open.  It does not work if I have no documents open(Zero Doc).  My AddIn does not reference any external documents or the active document.  The text box(SCNumber) acts like it is locked when there is no document open but works as expected with an active document.  Why would it matter if there is an active document?

 

My AddIn application type is a Class Library.

 

Here is the module code:

 

Imports System
Imports Inventor
Module modMain

    Dim CreateForm As New frmCreate

    'Main function
    Public Sub CreateCrate()

        'Show form
        If CreateForm IsNot Nothing AndAlso Not CreateForm.IsDisposed Then
            CreateForm.TopMost = True
            CreateForm.Show()
            CreateForm.BringToFront()
            Exit Sub
        End If

        CreateForm.Show()
        CreateForm.BringToFront()

    End Sub

End Module

 Here is the form code:

 

Imports System
Imports System.Windows.Forms
Imports Inventor
Public Class frmCreate

    Private Sub frmCreate_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Me.SCNumber.Focus()
        Me.SCNumber.TabIndex = 0

    End Sub

End Class

 

7 REPLIES 7
Message 2 of 8
philippe.leefsma
in reply to: Anonymous

Hi,

 

I cannot tell you anything based on that description other it seems like a weird behavior... Please upload your addin project so I can have a look on my side.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 8
Anonymous
in reply to: philippe.leefsma

Philippe, I have uploaded my AddIn.  Thanks for reviewing it.

Message 4 of 8
Anonymous
in reply to: Anonymous

If I do not have a document open, the input from the bar code scanner goes to the command alias input at the bottom of the screen instead of in the textbox on the form.

 

CAI.png

 

 

Message 5 of 8
philippe.leefsma
in reply to: Anonymous

I was trying different approaches but unfortunately I cannot tell you why this is not working. The input is actually grabbed by Inventor, you can see the keys appearing in Inventor command line at the bottom, but this only happens the first time the dialog is displayed. If I close and reopen it works as expected.

 

It also seems specific to this dialog, if I use another dialog it works. My suggestion would be that you try creating another dialog and check step by step that the input works, you might be able to spot what going wrong this way.

 

I recommend that you use the window wrapper interface when displaying a child dialog. You should also migrate your UI to use ribbons instead of toolbars, it's been many moons since that old UI is deprecated. See my modified code.

 

Sorry for not being more helpful at the moment.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 6 of 8
Anonymous
in reply to: philippe.leefsma

Thanks Philippe.  I will update the UI as you recommended.  I did not see this thread before but it describes the same problem.

 

http://forums.autodesk.com/t5/Inventor-Customization/Command-alias-input-cancel-load-previous-comman...

 

Changing the form to be displayed as modal seems to solve the issue.

 

CreateForm.Show (modeless) to CreateForm.ShowDialog (modal)

 

Message 7 of 8
philippe.leefsma
in reply to: Anonymous

Well, I though you had a good reason to display the form as modeless. If not, you should always display it as modal, unless you want to allow user interaction with Inventor at the same time.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 8 of 8
Anonymous
in reply to: philippe.leefsma

I do not need user interaction with Inventor so I will display it as modal.  I just started writing AddIns so I was unaware of the difference between .Show and .ShowDialog.

 

Thanks again for your help.

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

Post to forums  

Autodesk Design & Make Report