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: 

Auto file naming challenge

3 REPLIES 3
Reply
Message 1 of 4
dlconsulting
577 Views, 3 Replies

Auto file naming challenge

I'm in the process of creating a routine that will copy a template file to create a new project file within vault.  For one category in particular, the goal is to propose the next sequential number for naming the file to the user, which he is then free to modify.  I want to generate this file name from within a custom API routine.  So I have a couple questions...

 

a) Ideally, I'd like to search the vault for the file within the category with the highest file name, and then just increment it to generate the proposed filename.  Is there an efficient way to do this via the API?  (In SQL terms this would be simple: SELECT MAX(FileName) as "HighestFIlenameSoFar" FROM files WHERE Category="XYZ")

 

b) Failing that, I'd like to stick the highest known file number in a global variable somewhere in the vault, and increment it via the API whenever a file within this category is loaded.  Is there a practical way to do this via the API?  I don't like this as it requires way too much program for a simple problem.

 

c) I don't think I can make custom numbering will work in a case like this where I want to propose the name and let the user change it if necessary, but is there something I haven't thought of?

 

Any insight would be greatly appreciate! Thanks.

Dan

3 REPLIES 3
Message 2 of 4
Redmond.D
in reply to: dlconsulting

Let me back up a minute.  You want to generate file names but you don't want to use the file naming scheme feature that Vault has because the user might say no, and you don't want to reserve the name.

 

There is an API function that lets you rollback the reserved name, RollbackFileNamingDescriptions().  This function works with the AddFileNamingScheme() and ReserveFileNamingDescription().

Keep in mind these functions are for file naming schemes, not to be confused with file numbering schemes.  Copy Design is the only feature I know of that uses the naming schemes.

 

 

To answer your other questions...

a)  FindFilesBySearchConditions() is what you want.  This is the back-end to the Advanced search feature.  In your case, you can do a search based on the Category Name with File Name as your sort property.

 

b) No pratical way to do this.  Vault Options provides you with a global variable, but only admins can write this.  Also you can't lock down this value in a multi-user environment.

 

c) Answered at the top.

 

- Doug

 

 

PS.  Do you mind if I canabalize your AU class in one of my blog posts?



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 3 of 4
dlconsulting
in reply to: Redmond.D

Hi Doug, thanks for the quick reply.

 

Feel free to canabalize the AU class.  Part of the reason I went to as much work as I did was to help others with the learning curve as well as to inspire some new ideas.  If I have time I'll also provide some feedback on the "Scripter persona".

 

On the auto naming: There are four groups involved.  Two of them name designs based on an algorithm, so they are easy to handle.  The other two name designs based on the next available ID.  If they follow the instructions (Scenario A), they will start in Vault Explorer and click on a new (as of yesterday) toolbar button "Create New Project", which will propose the new filename.  They can accept the name or modify it.  It will then copy the appropriate template file and name it based on what was provided. 

 

It's likely that some will not follow instructions (Scenario B), and start in AutoCAD, name the design, create the design, and then try to check it in.  So long as it's not a duplicate name, this will have to be OK.

 

So ideally I can have it come up an approach that, for Scenario A, will identify the last (highest) ID used, increment it, and propose this as the id/filename.  Note to complicate matters, their file names are Axnnnn, where A is "A" and "xnnnn" is a 5 digit number unless the first digit is zero in which case it's a hyphen.  Don't ask.  🙂 

 

I'll probably try the FindFilesBySearchConditions().  My only concern is that when there are 20,000 drawings, that it will be really inefficient.

Dan

Message 4 of 4
Redmond.D
in reply to: dlconsulting

Before starting with FindFilesBySearchConditions(), play around with the Advanced Find feature to figure out the exact query you want.  Then you can translate that into the FindFilesBySearchConditions inputs.

 

The function returns data in pages, just like a Google search.  So even if there are 200,000 hits, it will still perform well.  The trick is to get the conditions and the sort correct so that what you want is at the top of the list.



Doug Redmond
Software Engineer
Autodesk, Inc.

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

Post to forums  

Autodesk Design & Make Report