Revit API

Reply
Distinguished Contributor
JamieVJohnson
Posts: 136
Registered: ‎09-29-2008
Message 1 of 3 (110 Views)

Tough Compound Filter

110 Views, 2 Replies
10-09-2009 02:02 PM

I have this function that runs a few filters in loops that I would like to see if they can all be combined into one call to doc.elements(filter,elementarray). First I get a list of all family symbols that have our shared parameter "UsageID". Then I cycle through all the found symbols and look for any family instance objects using one of those family symbols. To put it in straight words, I want ALL family instance type objects that have a family symbol whose parameter "UsageID" = strUsageID. Can it be done in one compound filter? Thank you in advance if you have ANY ideas or improvements.

Public Function GetFamilyInstancesByUsageID(ByVal strUsageID As String) As ElementArray

Dim eaFamSym As New ElementArray

Dim eaFamInst As New ElementArray

'run filter on family instances that are framing

Dim cf As Creation.Filter = rApp.Create.Filter

Dim fFamInst As Filter = cf.NewTypeFilter(GetType(Elements.FamilyInstance))

'run filter on family symbols that have usageID paramter of strUsageID

Dim fUsage As Filter = cf.NewParameterFilter("UsageId", Enums.CriteriaFilterType.Equal, strUsageID)

Dim fFamSym As Filter = cf.NewTypeFilter(GetType(Symbols.FamilySymbol))

Dim fFSandU As Filter = cf.NewLogicAndFilter(fUsage, fFamSym)

Dim n As Integer = doc.Elements(fFSandU, eaFamSym)

For Each fs As Symbols.FamilySymbol In eaFamSym 'cycle through all family symbols used for as a strUsageID

Dim fFamSymName As Filter = cf.NewSymbolFilter(fs.Name)

Dim fFinal As Filter = cf.NewLogicAndFilter(fFamInst, fFamSymName)

n = doc.Elements(fFinal, eaFamInst)

Next

Return eaFamInst

End Function

Active Contributor
joelkarr
Posts: 30
Registered: ‎11-25-2008
Message 2 of 3 (110 Views)

Re: Tough Compound Filter

10-12-2009 09:05 AM in reply to: JamieVJohnson
Jamie,



If I understand correctly, you would like to minimize the calls to the document and create one filter and have a single document call?



I think you are already most of the way there. Could you move this piece to outside of the loop.



[code]

n = doc.Elements(fFinal, eaFamInst)

[/code]


Then add



[code]

//Outside of Loop

Dim fEntire as Filter;

//Inside of Loop

Dim fFinal As Filter = cf.NewLogicAndFilter(fFamInst, fFamSymName)

fEntire= cf.NewLogicOrFilter(fFinal, fEntireFilter);

[/code]



that way you will have an or statement connecting each one of your calls you were making inside the loop. The result with be the sum all of the results of the loops filters. Edited by: joelkarr on Oct 12, 2009 4:05 PM
Distinguished Contributor
JamieVJohnson
Posts: 136
Registered: ‎09-29-2008
Message 3 of 3 (110 Views)

Re: Tough Compound Filter

10-12-2009 09:07 AM in reply to: JamieVJohnson
Forest and Tree's man!!

Thanks a bunch.

jvj

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


Revit Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Revit helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Revit

Twitter

Facebook

Blogs

Youtube