Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Data Standard 2015 Events

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
dvsmiller9
785 Views, 6 Replies

Data Standard 2015 Events

I'd like to be able to hook into the DetailTabs to fire an event in a new Data Standard tab to perform some ECO lookup functions. In the online Autodesk help "Use Events with the Data Standard Dialog" it mentions adding a Propertychanged event using $Prop['property'].add_PropertyChanged(......).  Is there something similar for DetailTabs?  I know if I'm creating my own tab thru the API with DetailTabs() method I can add the SelectionChanged event hook there but since the new tab is defined thru Data Standard with an XML file I am at a loss as to how to hook in.

 

There is a function OnTabContextChanged in the Default.ps1 file.  Do I need to add a section to this to check for the SelectionContext of my added tab?  I'd rather not edit this file since it could change with the next release of Vault.  It also uses the older VaultContext where the 2015 API says that was removed in 2014 and to use the newer Connection property instead.  I'd like to be able to put the event hooking code and event handler in a separate .ps1 file just for my new tab.

 

Any ideas?

 

Thanks

6 REPLIES 6
Message 2 of 7

I'm not exactly sure what you mean with event. However, you are correct, the default.ps1 might be subject to changes in future releases, so it's better to keep your code in separate ps1 files. The OnTabContextChanged is called every time you position the cursor on a new record, so it's identical to the SelectionChanged in the regular Vault API. 

The best thing is to create your own PS1 file, create a function called myOnTabContextChanged, or however you feel more apprpriate, and call your function from within the OnTabContextChanged in the default.ps1. Of course the default.ps1 could be overwritten in with the next release, but's just 1 line that you have to take car of.

 

Now, the OnTabContextChange is executed one time for the current selected VDS tab. If there is no VDS tab active, then the function does not get called. In order to know which tab is currently active, the $xamlFile contains the Xaml file name of the currently active tab. Have a look to the OnTabContextChanged in the default.ps1.

 

Within the PowerShell runspace, there are some variable that are quite handy. The $vualt contains all the Websrives, as the WebserviceManager does in the Vault API. The $VaultConnection contains the VDF, so the complere API of the Vault Developer Framework in troduced with 2014. The $vaultContext contains the information of the currently selected element in Vault, like for the regular API. So, basically, the Vault API is passed transparently into the PowerShell runnspace and you can then write your code as you would be in Visual Studio with C#

 

here a sample:

function myOnTabContextChanged
{
	$dsDiag.Inspect()
}

 

this code is simply showing up the "Inspector" at the very moment when you select a VDS tab or change the record in the top view. The Inspecto shows you all the variables set at this very moment. You will find in the Inspector the variables mentiones above and all other available at this time. The code stands still until you

don't close the inspector.

 

have a try. copy. the code in a new PS1 file. place the PS1 nearby the other PS1 files, such as the default.ps1 and edit the OnTabContextChanged by adding your function, like this:

function OnTabContextChanged
{
	$xamlFile = [System.IO.Path]::GetFileName($VaultContext.UserControl.XamlFile)
	
....
..
...

	myOnTabContextChanged
}

 

have fun!

ciao

marco

 

 

 

coolOrange
www.coolorange.com
Message 3 of 7

Marco,

That really helps a lot. Especially the $VaultConnection and $VaultContext objects clarification. Thanks!

 

The events I was referring to would be the SelectionChanged event when you are in the new VDS tab I want to create and you pick on a different Change Order in the Main detail grid pane as well as if you are on a different tab and select the new custom VDS tab.  In the second case is there another event I can hook into?

I might also need to fire an event if I open the standalone dialog for editing or viewing a change order (as when I RMC Edit or View and Respond) and also when I click on the new VDS tab in that dialog.

 

Basically I'm trying to retrieve info about the Change Order and present it differently but I need a trigger to retrieve that info from the server.

 

It's too bad I still need to edit the Default.ps1 file but at least it's a manageable edit (as long as I don't need a bunch of changes for other customizations in the future).

 

Thanks

Message 4 of 7

i'm still not 100% if i got what you like to achieve, however i hope i can give you a bit more insights. With Data Standard you can configure the tabs for Change Ordersm, but you cannot interact with the native Change Order Dialog. In order to do that, you have to use the full Vault API, however, even then you can only hook the change event, but you cannot change the CO dialog.

 

however, on the VDS side, you can create a tab for Change Order. Actually, there is already one called "Datasheet". It basically shows a summary of the Change Order properties. The tab refreshes automatically when:

- it gets activated/loaded, so when you switch from one tab to the Datasheet tab. however, once the tab is loaded, it does not refresh again

- the selected element in the grid changes and the tab is active, so for instance, when you select another CO in the list

 

if the tab is activa and you select a new element, then the tab gets notified and updates (OnTabContextChanged is fired). If you have another tab selected and you change records, then noting happens in you VDS tab, unless you set it again as active (again the OnTabContextChanged gets fired).

 

now, within the XAML file you can bind your TextBox or Label to all the current available properties of your current selected object. so, if you have selected a file and have a tab for the file, you can bind your controls to the file properties, just like this ...={Binding Prop[PropName].Value}. The same is for Change Order.

However, you may want to show some related information in your tab. The you have to collect such information via the Vault API and then set the according controls inside the XAML file.

For instance, we made a custom tab for Change Order that collects all the change orders "in the tree". To be more specific, one change order is liked to a file or item. such file or item has parents and children. Such children might be linked to other change orders. So, the customer was willing to have a one place overview of all the change order related to the assembly. We created a custom tab, where we started with the selected Change Order, collected parent and child items/files, looked for related change orders, and showed them finally in the special tab. Something like this is possible but requires few lines of code (Vault API). I hope you get the idea.

In the $vaultContext.SelectedObject.Id, you have the ID of the selected object, which you can use in combination with the Vault API in order to collect all data you need.

 

if you can articulate a bit more precise what exactly you like to do, i may give you more precise guidance.

 

ciao

marco

coolOrange
www.coolorange.com
Message 5 of 7

Hi Marco,

 

Thanks for the clarification.  Specifically, I'd like to create a tab for the ECO environment where I can show and edit the Item link properties on the change order (the per item ECO custom properties I've defined).  The main grid does not show multiline text with returns and I'd like to add controls that support multiline to a new tab with a samll set of properties.  I'd also like to be able to edit them and have them saved back to the server.  If this tab is on the Edit CO dialog will it hook to the Save method there or do I have to write my own function to call web service methods?

 

I also want the fields to update if that tab gets focus or the selected ECO changes.  If another ECO is selected while my tab does not have focus I want the fields in my tab to update to the new selected ECO properties when my tab does get focus.

 

Does this better explain what I want to do?

Message 6 of 7

yes, thanks! If I got ir right, then you like to add custom tabs in the standard ECO edit dialog, right? That is not possible. From what i know it's even not possibile with regular API. Only the lower tab frame of Vault, the one under the data grid, can be extended, either with Data Standard or the Vault API.

 

so in order to sho your data, you could create a custom tab. Now, editing information in the tab is tricky, as the user can at any time select another record and so your editing is lost. For editing purpose, a modal dialog is better, as it keeps the Vault "frozen" while the dialog is open.

 

For doing such a thing, you could create a custom tab that shows your preferred data. You could add a button to the tab which open a custom dialog where you can perform the edit. such dialog would then be modal.

 

now, if i recollect correctly what you like to achive, which is doable but related to some development, the question is then if you are able to achive such customization your selfe, or if you need assistance?

 

ciao

marco

 

coolOrange
www.coolorange.com
Message 7 of 7

Thanks much Marco.  I'll give it a try.  If I find it's beyond me I'll let you know.

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

Post to forums  

Autodesk Design & Make Report