Vault Customization

Vault Customization

Distinguished Contributor
204 Posts
0 Kudos
Registered: ‎04-25-2008
Post 1 of 3

Forcing system-controlled status of DWFs with PS-script

296 Views, 2 Replies
08-16-2012 12:54 AM

Just in case - I'm a complete newbie to both PowerShell and Vault API.

I'd like to write script that would warn Vault user about some bad things.


First thing came to my mind that worth to bother - system-controlled status for visualisation.

AFAIK there is no way to prevent user from uploading own visualisation to Inventor or AutoCAD files, right?


But let imagine that one of vault admins goal is to provide system-controlled DWF for each and every CAD-file. And believe me I'm a bit fed up to controll this manually.


Some users don't mind admins recomendations and forget to switchON "send to Job Server" option, some files can't be DWFed due to errors and thus would be removed from job-queue by Q-tools, files that were changed inside Vault usualy don't get their DWF auto-created. So there are destructive tendetion to be fixed.


I'd like my script found all CAD files that:

a) were uploaded by particular user (that, who are logged in).

b) don't have system-controlled visualisation (DWF).

c) don't have job of type "Create.DWF" and status "Pending" in the Job Queue.


I've at least two "stuck places":

1) "ALL files". Files are not in the same folder thus I wonder if I should use recursion to gather them in one list or if there some easier/faster/smarter way?

2) How to get list of Jobs from Job Server?


Thanks in advance.


PS: I'd like my script generate warning (WARNING, this database contain ## inventor documents of  <username> responsibility that neither have system-controlled visualisation nor waiting their order to be DWFed. It is highly recommended that you add Create.DWF task for these files.)  just before user log-out, if possible.

AI2011 Certified Associate
(Soft: PDSU2012, VP2012&VP2013)
37 Posts
4 Kudos
Registered: ‎09-09-2007
Post 2 of 3

Re: Forcing system-controlled status of DWFs with PS-script

08-21-2012 09:28 PM in reply to: MaxU77

Hi MaxU77


If there is no ready utility for doing what you are looking for, then you have to use Vault API to do the customization. I'd suggest you to use Visual Studio .NET to write the code, because it has more functionalities, especially debugging related tools, that are very helpful for the programmer, but PowerShell has not. I don't know if PowerShell can provide a warning dialog to the UI, you can search Internet for the answers.


To detect if the DWF is in system controlled status, you can check the design file (in Vault) property "DwsignVisAttmtStatus", for example:

if (myFile.DesignVisAttmtStatus == DesignVisualizationAttachmentStatus.NotSyncronized

 //you will see this warnng in Vault: "Warning: This visualization file is not a system controlledvisualization file. Use //Update View."


You want to know all files' status, so your code can use Vault API GetFolderRoot to get the root folder, then call GetFoldersByParentId method to get every subfolders.The second parameter to GetFoldersByParentId is a recurse parameter.So you can get all folders with just 2 API calls:
Folder root = docSvc.GetFolderRoot(); 
Folder[] folders = docSvc.GetFoldersByParentId( root.Id,true); 

After this, you can call GetLatestFilesByFolderId to get all files.


jobs can be obtains by GetJobsByDate from JobService, e.g.:

Dim jobs() As Job = serviceManager.JobService.GetJobsByDate(100, DateTime.MinValue) 

Vault SDK has a sample demonstrating how to use JobService API, you can start from there.


Some articles in Vault API help document are very worthy to read, for example "Handling Exceptions in Your Custom Command", which tells a good programming practice. I would suggest you to view them before you starts to write program.

Barbara Han
Developer Technical Services
Autodesk Developer Network
814 Posts
272 Kudos
Registered: ‎12-12-2006
Post 3 of 3

Re: Forcing system-controlled status of DWFs with PS-script

08-22-2012 05:14 AM in reply to: barbara.han

Hi Max,


Since "visualization Attachment" is a property you can search on.  Using DocumentService.FindFilesBySearchConditions is a much better way to find your files than scanning though all the folders.


I saw your comment on my blog.  I'll try to get some example scripts posted by the end of the week.



Doug Redmond
Software Engineer
Autodesk, Inc.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!