add-in and button execution problem

add-in and button execution problem

Anonymous
Not applicable
493 Views
4 Replies
Message 1 of 5

add-in and button execution problem

Anonymous
Not applicable

I have an add-in utilizing the following code. The
problem I am having is that after exeuting the button and loading the form a new
instance of the same form opens everytime I hit the spacebar. Does anyone know
how to ensure only 1 instance of the form can be loaded at a time. Thanks in
advance for any help.

 


Private
color=#0000ff size=2>Sub
oButtonProps_OnExecute(
color=#0000ff size=2>ByVal
Context
color=#0000ff size=2>As
Inventor.NameValueMap)
color=#0000ff size=2>Handles
oButtonProps.OnExecute


On
color=#0000ff size=2>Error

size=2>GoTo
err_oButtonProps


Dim oDoc
color=#0000ff size=2>As
Document


On
color=#0000ff size=2>Error

size=2>Resume

size=2>Next


oDoc = Inv.ActiveDocument


If Err.Number
Then


Exit
color=#0000ff size=2>Sub


End
color=#0000ff size=2>If


' Check if File is read only and see if
user wants to check out


Dim RO
color=#0000ff size=2>As

size=2>String


RO = ROnly(oDoc.FullDocumentName)


If RO = 0
color=#0000ff size=2>Or
RO = 2
size=2>Or
RO = 32
size=2>Or
RO = 34
size=2>Then


Else


Check_Out()


End
color=#0000ff size=2>If


mIV_Properties =

New
IV_Properties


mIV_Properties.Visible =


size=2>True


mIV_Properties.Show()


mIV_Properties =

Nothing


size=2>

err_oButtonProps:


End
color=#0000ff size=2>Sub


Scott A.
McCoy

0 Likes
494 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Pressing the space bar executes the previous command again, in this case
it's your command. Is this also happening when entering a space while
typing data into your form? If that's the case then you need to make sure
that you set Inventor as the parent of your dialog. This will also make
sure that your dialog displays on top of Inventor and if Invntor is
minimized it will be minimized too.

Even with correctly setting the parenting you can still have the problem if
the user executes your command again, either using space or another method.
The correct thing to do is to wrap your command with an InteractionEvents
object. Typically this is used to handle selections and some other command
related things. However an important component of the InteractionEvents
object is that it gives your command correct command behavior. That is if
another command is executed, yours will be terminated. This is how all of
Inventor's commands behave.
--
Brian Ekins
Autodesk Inventor API
0 Likes
Message 3 of 5

etckerry
Enthusiast
Enthusiast
I am having the same problem (typing in a text box in the form, and when I hit space bar another form opens). I am not setting my form's parent property to Inventor. How do I do this? When I set Parent = InventorApp (InventorApp has type Inventor.Appliation) I get an exception because I'm trying to assign an System.___COMObject to a System.Windows.Form.Control. I understand why I am getting this error, but I can't find a way to extract Inventor's form from the Inventor.Application object. I am sure someone has run into this problem before...

Thanks,

Kerry
0 Likes
Message 4 of 5

Anonymous
Not applicable

It's not as easy as you would expect using
.Net.  The attached txt file has some sample code that demonstrates
this.
--
Brian Ekins
Autodesk Inventor API

href="http://blogs.autodesk.com/modthemachine">http://blogs.autodesk.com/modthemachine

 
0 Likes
Message 5 of 5

martin_mmj
Enthusiast
Enthusiast
This is very important information for me too.

Thanks for sample Brian, works fine.

Martin
0 Likes