Vault Customization

Reply
Valued Contributor
joerituijn
Posts: 65
Registered: ‎09-20-2009
Message 1 of 6 (625 Views)
Accepted Solution

API; FindFilesBySearchConditions fails

625 Views, 5 Replies
07-09-2011 10:57 PM

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?

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.

Employee
Redmond.D
Posts: 812
Registered: ‎12-12-2006
Message 2 of 6 (606 Views)

Re: API; FindFilesBySearchConditions fails

07-11-2011 11:22 AM 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.
http://justonesandzeros.typepad.com/

Valued Contributor
joerituijn
Posts: 65
Registered: ‎09-20-2009
Message 3 of 6 (597 Views)

Re: API; FindFilesBySearchConditions fails

07-11-2011 07:46 PM 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.

Employee
Redmond.D
Posts: 812
Registered: ‎12-12-2006
Message 4 of 6 (585 Views)

Re: API; FindFilesBySearchConditions fails

07-12-2011 04:19 AM 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.
http://justonesandzeros.typepad.com/

Valued Contributor
joerituijn
Posts: 65
Registered: ‎09-20-2009
Message 5 of 6 (582 Views)

Re: API; FindFilesBySearchConditions fails

07-12-2011 04:36 AM 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....

Distinguished Contributor
MaxU77
Posts: 204
Registered: ‎04-25-2008
Message 6 of 6 (294 Views)

Re: API; FindFilesBySearchConditions fails

08-17-2012 08:02 AM 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)
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 or visit the Installation and Licensing Forum to get help installing your software.