Associating multiple Views with respectively displayed Bodies

Hello everyone,

This is my first post although using this page as source for solutions to many of my problems.

I have the following Problem and am currently looking for a way to solve it:
I have multiple DItems (Drawings) in NX opened and loaded concurrently.
Each has a various amount of Views.
Each View displays a certain amount of bodies, which should all have an attribute "x" with the same value.
I intend to check, whether the displayed bodies in each View have the correct value(the name of the view) and if the number of bodies in said View is correct. I use Check-Mate to get tags for all bodies available

mqc_askEntitiesInLayer(mqc_parseLayerStrings( { "1" }, "-"),SOLID_BODY,true);

This is forwarded to Visual Basic code and stored in a List(Of Body), resulting in all loaded parts bodies concatenated into one list.

I get all Views using following code:

    Public Function GetAllPartsViews(ByVal parts As PartCollection) As List(Of View)
        GetAllPartsViews = New List(Of View)
 
        For Each part As Part In parts
            Dim partViews As ViewCollection
            partViews = part.Views
 
            For Each view As View In partViews
                GetAllPartsViews.Add(view)
            Next
        Next
    End Function

For the next step I need to know which bodies are displayed in which View. I found the function  View.AskVisibleObjects() , but this can only be used, if the View is the current WorkView. As there is no View.Bodies or Body.Views I struggle with finding a way to associate the two.

Are you interested in the modeling views or the drafting views? The part's .Views collection will return both. If you are only interested in one type of view, there are separate collections for each (.ModelingViews, .DraftingViews).

If you are interested in modeling views, my first thought is to make each view the work view in turn and use the .AskVisibleObjects method on each. Drafting views are going to be a bit trickier as the body you see in the view may not be the same as the one in the body collection. For instance, a drafting body will be used in section views for bodies that are shown as cut in the view. I'm not sure if the drafting bodies inherit attributes from the original bodies; if they do, the task will be much easier.

Hello NXJournaling,

Thank you for the quick reply!
I was interested in DraftingViews.

Could you elaborate on how/why the bodies seen might differ from the bodies in the collection?

The Problem I saw with setting the work view was a performance issue as I am possibly looping through hundreds of parts containing thousands of bodies and I have bad experience with performance issues.

Initially I wanted to make sure, that
the number of bodies having a certain value "y" for a certain attribute "x"
and
the number of bodies diesplayed in a DraftingView named "y"
are the same.

This is no longer needed for my current task, but for the future and other people I think it could still be interesting to have a solution in this thread.