Automating updates to drawings in the Vault

Automating updates to drawings in the Vault

Anonymous
Not applicable
618 Views
5 Replies
Message 1 of 6

Automating updates to drawings in the Vault

Anonymous
Not applicable

Hello all,

 

I have a scenario that I believe will need some knowledge of the Vault API and I'm hoping to get some direction from you all on where to go to begin my research.  We have a great deal of drawings (in the thousands) in our Vault that need to be updated.  We are shortly going to be going through the process of updating item records in our ERP database, and we would like to take those mass updates from our SQL database and push them out to the Vault to avoid forcing our Engineers to open all these drawings, perform 2-3 updates, and republish (mainly we are renaming drawings / models, maybe a few iProperty changes).  

 

As one of the resident IT guys I was asked to look into how we might automate pushing these thousands of changes to the Vault.  I have no experience with the Vault itself.  My background is in SQL Databases, VBA, some C# / java etc.  What I'm looking for is any input from you on approaches to take, API calls to learn, maybe some tutorials or tools...essentially anything that can get me started down this path.

 

Any resources or input would be greatly appreciated.

 

 

 

 

0 Likes
619 Views
5 Replies
Replies (5)
Message 2 of 6

minkd
Alumni
Alumni

A good place to start would be here.

 

-Dave



Dave Mink
Fusion Lifecycle
Autodesk, Inc.
Message 3 of 6

Anonymous
Not applicable

Thanks Dave!

 

I've been glancing over that and there is certainly a lot there.  I guess for my purposes I'm looking for how to do just a few basic tasks.  I am thinking all I need is how to reach out and update a file and some of its properties.

 

Something like

     object = OpenFile('drawing123.dwf');

     object.SetiProperty('propertyName',Value);

     object.property.DrawingName = 'NewName';

     object.Publish();

 

etc.

 

Is there a library of API calls somewhere?  I assume there is and I am just having trouble finding it for some reason.

0 Likes
Message 4 of 6

Anonymous
Not applicable

Ok,

 

So I've been doing my homework and this is what I have so far:

 

Step 1: Learn How to Login / Authenticate to the Vault:

                        Via GUI : https://www.youtube.com/watch?v=2ytpvxlED7s

                        For my purpose I am just hard coding it for now:  

                          

using VDF = Autodesk.DataManagement.Client.Framework; 

..... 

VDF.Vault.Results.LogInResult results = VDF.Vault.Library.ConnectionManager.LogIn( "serverName", "VaultName", "userName", "Password", VDF.Vault.Currency.Connections.AuthenticationFlags.Standard, null ); 


//close if failure 

if (!results.Success) return; 

VDF.Vault.Currency.Connections.Connection conn = results.Connection;

 

 

 

Step2: Learn how to get a file (given a known path)

 

            string path = "$/Test vault/test inventor projects/LIBRARY2/C2v171-XX3.idw";
            //Need array for findLatestDocuments
            string[] paths = new string[1];
            //Assign array 0 as your path
            paths[0] = path;
            //get file and load into files array
            Autodesk.Connectivity.WebServices.File[] files = conn.WebServiceManager.DocumentService.FindLatestFilesByPaths(paths);
            //dump name to textbox to test
            textBox1.Text = files[0].Name.ToString();

 

 

 

 

Step 3: Get a list of available File properties

 

 

            ////Get list of properties
            PropDefInfo[] propDefs = conn.WebServiceManager.PropertyService.GetPropertyDefinitionInfosByEntityClassId("FILE",null);

            ////dump to listbox to test
            foreach (PropDefInfo propDef in propDefs)
            {
                this.listBox1.Items.Add(propDef.PropDef.SysName.ToString() );
            }

 

 

Step 4: View current file property values / learn to access a specific properties (by sysName?)

              Struggling with this one a little.  Mosty just trying to figure out the correct syntax. I am looking at the PropertyService.GetProperties() function but I am a little confused.  It is expecting as arguments a string representing the classID, which I assume is "FILE", but the other two arguments are long[] entityIds and long[] propertyDefIds.  I'm not sure how to pass those values.  I was originally thinking it would be something like file[0].Entity or file[0].PropertyName.Entity etc... but I am way off base.

 

 

Step 5: Learn how to update the file properties.

 

               Still a WIP.  I saw this example (link) and am trying to modify that.  According to this source I need to use IExplorerUtil.UpdateFileProperties if I want to update the properties in the Vault and in the file itself.  As I understand it, IExplorerUtil.UpdateFileProperties requires a reference to Autodesk.Connectivity.Explorer.ExtensibilityTools.dll which I don't seem to have.  I did some more searching and found this source where Doug Redmond mentions I need the vault client, so I am trying to get the installation media to get that installed on my machine.  Once done I am hoping the dll will be installed and the code will be something to the tune of:

 

 

Dictionary<Autodesk.Connectivity.WebServices.PropDef,String>  dict  = new Dictionary<Autodesk.Connectivity.WebServices.PropDef,String>();

dict.Add(propDefs[5].PropDef, "New Description Value"); //etc

IExplorerUtil.UpdateFileProperties(files[0], dict);

 

 

 Summary / Questions

 

 

As you can see I'm making progress but still have issues.  If anyone has any input or advise on steps 4/5 I would greatly appreciate it.  Specifically I am trying to work out the entityIds for the GetProperties() function, and how to properly use the  IExplorerUtil.UpdateFileProperties() function.  With these steps figured out I can pull in my SQL data and loop through the files that need to be updated.

 

My apologies if this is rudamentary to any of you guys.  My background is in databases, not programming. 

 

 

 

 

0 Likes
Message 5 of 6

Anonymous
Not applicable

Final post.

 

I don't want to be spamming these boards if no one has anything they would like to add, so this will be my last update.  I figured out everything I need to make this work, but I do have one final question.  When I use the WebServiceManager.PropertyService.GetPropertiesByEntityIds() function to get a file's current properties, the array returned doesn't quite match up with the list of properties I get when I use WebServiceManager.PropertyService.GetPropertyDefinitionInfosByEntityClassId(). 

 

 

For example, on one file I am looking at "Description" is index 39 in GetPropertyDefinitionInfosByEntityClassId(), but it is index 25 in GetPropertiesByEntityIds().  Does anyone know why?

 

The reason I ask is that I am using the GetPropertyDefinitionInfosByEntityClassId() function to get a list of available file properties, and I'd like for the user to be able to click on a property in a  list and see the current / enter a new value.  Right now I was having them click on a property, and use that index # when I update the file (which seems to work), but when I try to do the same to pulll up the current value it doesn't work because the index numbers don't line up.

0 Likes
Message 6 of 6

minkd
Alumni
Alumni

Sorry. I was in a training class and then had a couple days of vacation ...

 

You are getting all possible property defs for any files, and then getting property values for specific files; but not all files will have values for every possible property def.

 

In many Vault API methods the input array of ids is in sync with the array of returned objects; but there is no correlation between different methods other than common IDs; and not all methods follow this pattern. The PropertyService.GetPropertiesByEntityIds method is one that does not.

 

The PropertyService.GetPropertiesByEntityIds method returns an array of PropInst objects. Each of those has an EntityId (which should match an Id in the entityIds parameter), a PropDefId (which should match the Id of the PropDef), and of course the value (Val).

 

Hope this helps,

-Dave



Dave Mink
Fusion Lifecycle
Autodesk, Inc.