check if a graphics is controlled by a view filter

check if a graphics is controlled by a view filter

Anonymous
Not applicable
2,459 Views
11 Replies
Message 1 of 12

check if a graphics is controlled by a view filter

Anonymous
Not applicable

When I check a graphical overrides for an  element on a plan view, I can see if they are controlled by a view filter or not (see the screenshot attached). How can I access this in API? 

0 Likes
Accepted solutions (2)
2,460 Views
11 Replies
Replies (11)
Message 2 of 12

recepagah12
Advocate
Advocate

You can access this property via one of these methods

View.GetFilterOverrides

activeView.GetFilters()
Message 3 of 12

Anonymous
Not applicable

No, these methods return settings of a particular filter. I need a settings for a particular element on the view.

0 Likes
Message 4 of 12

jlpgy
Advocate
Advocate
View.GetCategoryOverrides()
View.GetElementOverrides()
View.GetFilterOverrides()

GetElementOverrides(ElementId id) method

Difficult to search for it?

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
Message 5 of 12

Anonymous
Not applicable

Read my first post again before writing such rubbish.

These methods return explicit overrides, not the flag that they are controlled by a filter as one (probably not you) can see in Revit.

Message 6 of 12

jlpgy
Advocate
Advocate

Status 1 beforing changing them in UI :

element overrides color by filter UI.png

elemOverrides.ProjectionLineColor is not a Valid object

element overrides color by filter.png

ProjectionLinePatternId == -1 , of which I think might be a flag useful for you.

element overrides line pattern by object type.png

 

Changing to a meaningful Line pattern changes the ProjectionLinePatternId to a valid ID.

Changing to a meaningful Line color changes the ProjectionLineColor to a valid <Color> object.

 

I have not yet found a definite method to determine if an Element Overrides object is "By Object Style" of "By Filter"

Thinking perhaps need to get the view filters and to check if some filter contains (or passes) a specific Element.

Still trying...

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
Message 7 of 12

jlpgy
Advocate
Advocate

Hi:

As we have experienced, Revit renders models (line patter and color) in the following sequence:

  1. By family type (or family symbol) material ( if a family contains some material paramenters) (very complicated, I'm not so sure)
  2. By view category graphical settings
  3. By view filter graphical settings
  4. By element graphical settings

So I am thinking about

  1. View.GetCategoryOverrides() to check if ProjectionLineColor is valid or not
  2. View.GetFilterOverrides() to check if ProjetionLineColor is valid or not
  3. View.GetElementOverrides() to check if it's valid or not

 If filter color is valid, and element color is invalid, then => It's controled by filter.

I ran a simple test to check the above solution, but not sure if it works fine at all status.

 

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
0 Likes
Message 8 of 12

Anonymous
Not applicable

"Changing to a meaningful Line color changes the ProjectionLineColor to a valid <Color> object."

 

That's the problem: a valid Color Id appears when it is explicetly set up EITHER by a filter OR by element overrides. But Revit somehow can recognise these cases.

My task is to understand what properties of each element are controlled by filters, what are from users and what become from other overrides...

 

Theoretically, we can pass each element into every filter and see, whether the element passes and the color (e.g.) is the same. But sometimes users apply the same color manually, to make drawings look pretty, so, even this does not help...

0 Likes
Message 9 of 12

jlpgy
Advocate
Advocate

I post a new reply:

Revit renders models in a view by

  1. Category
  2. View Filter
  3. Specific Element

So get those 3 overrides, and check them in the same sequence.

Soppse you wanna check a Specific Element Projection Line Color:

  1. Category Projection Line Color is RED
  2. Filter Projection Line Color is GREEN
  3. Element Projection Line Color is "invalid"

Then I guess this Specific Element graphical overrides is driven by "View Filter". And this Specific Element will be displayed as GREEN.

Filter overrides over write the Category overrides. But there is no ELement overrides to over write Filter overrides.

Is it clear?

 

Notice that the above solution is based on a theory that Revit always renders a model in a view by the definite sequence.

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
Message 10 of 12

Revitalizer
Advisor
Advisor
Message 11 of 12

Anonymous
Not applicable
Accepted solution

Ok, got it. So, we do it by exclusion:

1. For each element check its ElementOverrides. If the color there is valid, this element is definitely controlled by ElementOverrides. Filter them out.

2. For the rest of elements we need to check, wheter they pass in any of view filters, which control colors:

2.1 Collect all filters applyed to the view

2.2 Define filters, which change colors

2.3 Construct a "super-filter" as OR-filter for all logical filters from 2.2

2.4 Construct a filtered elements collector for a collection of elements from 2 which pass lofical filter from 2.3 - these are elements whose color is controlled by a filter (we don't know which one, to define it we'd have to loop through all logical filters from 2.2 explicitely). The rest is either controlled by a category or untouched at all. In this case we don't care...

0 Likes
Message 12 of 12

jlpgy
Advocate
Advocate
Accepted solution

Yep you got there.

But one more thing.

I do remember that the View.GetFilters() returns all applied view filters in a permanent order. But this order sometimes is not the order you can see in Revit UI.

There is possibility that a specific element passes not only 1 filter. Because of the limitation of Revit API, you still cannot definitely determine which filter is finally controling a specific element ( if the specific element is passed by more than 1 filter)

https://forums.autodesk.com/t5/revit-api-forum/view-filter-order/td-p/5003890 

 

All about discussion, nothing is rubbish 😊

Nice working day.

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com