Vault Customization

Reply
Distinguished Contributor
MaxU77
Posts: 204
Registered: ‎04-25-2008
Message 1 of 3 (272 Views)

Forcing system-controlled status of DWFs with PS-script

272 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.

MaxU77,
AI2011 Certified Associate
(Soft: PDSU2012, VP2012&VP2013)
Employee
barbara.han
Posts: 37
Registered: ‎09-09-2007
Message 2 of 3 (256 Views)

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
Employee
Redmond.D
Posts: 800
Registered: ‎12-12-2006
Message 3 of 3 (250 Views)

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.
http://justonesandzeros.typepad.com/

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community