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: 

API; FindFilesBySearchConditions fails

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
joerituijn
1734 Views, 5 Replies

API; FindFilesBySearchConditions fails

I cannot get the AND and OR operators to work properly. I'm trying to perform a search that returns all Inventor Files in a certain folder excluding all DWF and DWFX files. The Help mentions this:

 

If a search condition contains a mix of OR and AND and NOT type conditions, then the OR statements are grouped together and evaluated first.  That result is then evaluated wtih the AND and NOT statements.

 

This is what I do. I might be wrong, but I can;t find the filetype property, so instead I search the extension in the filename:;

 

Private Function AddFileExtensionCriteria(ByVal Extension As String, ByVal SrchRule As SearchRuleType) As SrchCond       Dim searchCondition As SrchCond = New SrchCond()       

searchCondition.PropDefId = FileNamePropDef.Id

        searchCondition.PropTyp = PropertySearchType.SingleProperty

        searchCondition.SrchOper = 1

        searchCondition.SrchTxt = Extension

        searchCondition.SrchRule = SrchRule

 

        Return searchCondition

End Function

 

Array.Resize(Conds, Conds.Length + 1) 

Conds(Conds.Length - 1) = AddFileExtensionCriteria(".ipt", SearchRuleType.May)                   

Array.Resize(Conds, Conds.Length + 1)                   

Conds(Conds.Length - 1) = AddFileExtensionCriteria(".iam", SearchRuleType.May)                   

Array.Resize(Conds, Conds.Length + 1)                   

Conds(Conds.Length - 1) = AddFileExtensionCriteria(".idw", SearchRuleType.May)                   

Array.Resize(Conds, Conds.Length + 1)                   

Conds(Conds.Length - 1) = AddFileExtensionCriteria(".ipn", SearchRuleType.May)                   

Array.Resize(Conds, Conds.Length + 1)                   

Conds(Conds.Length - 1) = AddFileExtensionCriteria(".dwg", SearchRuleType.May)

 

'Exlude the DWF;

Array.Resize(Conds, Conds.Length + 1)                   

Conds(Conds.Length - 1) = AddFileExtensionCriteria(".dwf", SearchRuleType.MustNot)                   

Array.Resize(Conds, Conds.Length + 1)                   

Conds(Conds.Length - 1) = AddFileExtensionCriteria(".dwfx", SearchRuleType.MustNot)

 

This will return all Inventor files AND their DWF files. The only workaround I have now is to perform a second search excluding the DWF's. Am I missing something here?

5 REPLIES 5
Message 2 of 6
Redmond.D
in reply to: joerituijn

You need at least 1 Must condition.  See this article for more details.

 

Vault 2011 had an issue where MustNot didn't work.  Offhand, I can't recall if the issue was fixed for Vault 2012.

If you are having problems with MustNot, try converting it into a Must condition with the opposite condition.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 3 of 6
joerituijn
in reply to: joerituijn

Thanks for that. I had also added one must condition, but that doesn't make a difference.

 

Reversing the condition is a good idea! Use option 2 (Does not contain) for the DWF! And you need one condition less, does not contain '.dw*' also excludes '.dwfx'. Thanks!

 

Update; The must option does not work either in this case though, but using the 'may' option it does work. So it's just a wholel bunch of 'may' conditions to make it work. Only when you use a single property (just the .ipt) it's a 'must'.

 

Oh and a funny one; search for the number 1 (must option) and add all the filetypes as 'may conditions'. That will return the entire Vault. Any other value will return the expected files.

Message 4 of 6
Redmond.D
in reply to: joerituijn

I'll log this as an issue.  What version of Vault are you using?

Thanks.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 5 of 6
joerituijn
in reply to: joerituijn

I'm using Vault 2011 at the moment.

 

A forum related issue; after I log in to make a contribution, I get redirected to:

http://forums.autodesk.comhttp//forums.autodesk.com/t5/forums/replypage/board-id/101/message-id/3704...

 

That fails. I have to remove the first portion to get back here. Not sure who to inform about this....

Message 6 of 6
MaxU77
in reply to: joerituijn

Sure It's a bit too late ... but just in case for those newly connected ... avanced user would use the only search criteria. The <provider> property contains <Inventor> for all four i?? extensions and is empty for DWFs.

 

I've never used the Inventor DWG format thus not sure what property value is in them, but pretty sure should be the same (AutoCAD, AutoCAD Mechanical and AutoCad Electical DWGs are all contain <Autocad>).

 

MaxU77,
AI2011 Certified Associate
(Soft: PDSU2012, VP2012&VP2013)

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

Post to forums  

Autodesk Design & Make Report