Access Context outside CommandHandler

Access Context outside CommandHandler

GabrieleZelasco
Enthusiast Enthusiast
1,010 Views
3 Replies
Message 1 of 4

Access Context outside CommandHandler

GabrieleZelasco
Enthusiast
Enthusiast

Good morning everyone,
I try to explain as best as I can what my application does and what the problem is.


In Vault 2023 (C#) I developed a custom search form.
By this form it's possible to search for items through their UDP (I mean some internal Company classification properties). Once the search is completed, with a click on the result row, the context returns to the Vault which navigates to the selected item.
As far I have successfully used a ShowDialog to open the modal Form and retrieve the result upon closing and GOTO the item. This is all done inside the CommandHandler routine (therefore using e.Context.GoToLocation). Everything works like a charm.

 

Now the request is that this form remains available on demand, on a second monitor, in order to allow the user to use the Vault and recall the form to perform searches if necessary.


In order to reach the goal I pass the CommandItemEventArgs to the non-modal form when I instantiate and open it.
On item selection I hide the form and through the Hide event (with Close event I get a Vault crash) I retrieve the value of the selected item and try to navigate to that item in the Vault.

These operations no longer take place within the CommandHandler but rather in the FormSearchVisibleChanged routine (invoked by the Hide event).
In debug I see that the original context is intact but despite this it doesn't work.

At the moment it seems that the only way to access the context is within its CommandHandler.
Apologies for the length of the introduction.
Now the question:
Is it possible to access the context if it is passed to a routine external to the CommandHandler?

Any other ways to manage or rethink the solution?
Thank you very much in advance for your patience and kind support

0 Likes
Accepted solutions (1)
1,011 Views
3 Replies
Replies (3)
Message 2 of 4

FRFR1426
Collaborator
Collaborator

The context is only valid for the duration of the command. It's because the command has a prologue and an epilogue. There is some tasks to do before Vault can execute the command, and some other tasks to do after the command (like for instance refresh the UI if ForceRefresh is true).

 

There is no way to handle a modeless window with the API in its current state. To make it works, Autodesk should give us a way to switch to a command context to execute code, like you can do in AutoCAD or Revit.

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Message 3 of 4

Markus.Koechl
Autodesk
Autodesk
Accepted solution

I don't see a direct option either; however, @GabrieleZelasco, you could implement a workaround leveraging the Thick Client link option: create a link download file (*.acr) for the navigation target like Vault Send Link... A client configured to open *.acr files with Connectivity.VaultPro.exe as a default application will navigate to the given entity.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 4 of 4

GabrieleZelasco
Enthusiast
Enthusiast

Maxence DELANNOY you're so right, clear and relevant explanation.

Markus Koechl I will definitely try the workaround, in case I will ask you for some more hints.

Many thanks to both of you for the information and suggestions!

0 Likes