Dear Minho,
Thank you for your query.
Welcome to Revit API programming!
I suggest that you first of all take a look at the getting started material and work through the step-by-step instructions provided by the DevTV and My First Revit Plugin video tutorials:
http://thebuildingcoder.typepad.com/blog/about-the-author.html#2
That will show you what other important material is available that you MUST be aware of, answer this question of yours, and many, many more besides.
Once you understand the basics of using filtered element collectors, the answers provided above will become self-explanatory.
They do already answer your question in full.
The Building Coder discussed the related topic of determining all views displaying a specific element in depth, implementing an external command named CmdViewsShowingElements to try out some approaches:
- Determine Views Displaying Given Element -- http://thebuildingcoder.typepad.com/blog/2014/05/views-displaying-given-element-svg-and-nosql.html
- Determining Views Showing an Element -- http://thebuildingcoder.typepad.com/blog/2016/12/determining-views-showing-an-element.html
A similar question recently also arose in a StackOverflow thread on how to
- Determine whether a FamilyInstance is visible in a View -- http://stackoverflow.com/questions/44012630/determine-is-a-familyinstance-is-visible-in-a-view
Colin Stark answered that succinctly, saying:
I have found that the most reliable way of knowing whether an element is visible in a view is to use a FilteredElementCollector specific to that view. There are so many different ways of controlling the visibility of an element that it would be impractical to try to determine this any other way.
Below is the utility function I use to achieve this. Note this works for any element, and not just for family instances...
The category filter is used to eliminate any element not of the desired category before using the slower parameter filter to find the desired element. It is probably possible to speed this up further with clever usage of filters, but I have found that it is plenty fast enough for me in practice.
I added Colin's code to The Building Coder samples
https://github.com/jeremytammik/the_building_coder_samples
CmdViewsShowingElement
https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/C...
I hope this helps.
Best regards,
Jeremy