Find view(s) that a selected object is in

Find view(s) that a selected object is in

davidjimm
Enthusiast Enthusiast
5,326 Views
12 Replies
Message 1 of 13

Find view(s) that a selected object is in

davidjimm
Enthusiast
Enthusiast

Is there any way I can find out what view or views an object is in from the 3D view. We are in a large project, and I would like to be able to select an object and find the sheet it is on. I can get the sheet from the view an object is on hopefully.

0 Likes
Accepted solutions (1)
5,327 Views
12 Replies
Replies (12)
Message 2 of 13

aaronrumple
Enthusiast
Enthusiast

You can using the API or Dynamo.

The object may show up on many different views. And may be in a view but not visible because it is hidden by another object. From the views, you can get the sheets.

0 Likes
Message 3 of 13

davidjimm
Enthusiast
Enthusiast

Thanks for the reply. I was hoping to get a Dynamo script to find the view by selecting the object. I apreciate the help.

0 Likes
Message 4 of 13

RDAOU
Mentor
Mentor

@davidjimm 

 

You can use the "Find Referring Views" option. However, 3D elements exist in all views even if you do not see them, unless such elements are

  1. Cropped out of the view
  2. Outside view Range / Far Clipping
  3. On a closed workset or hidden by other means such as of VG or Filters
  4. On a filtered out Phase or non-primary Design option

 

Hence, if the objects/elements you mentioned are 3D elements, then that Dynamo Graph would more or less useless unless one of the above applies

 

 

 

YOUTUBE | BIM | COMPUTATIONAL DESIGN | PARAMETRIC DESIGN | GENERATIVE DESIGN | VISUAL PROGRAMMING
If you find this reply helpful kindly hit the LIKE BUTTON and if applicable please ACCEPT AS SOLUTION


0 Likes
Message 5 of 13

davidjimm
Enthusiast
Enthusiast
Accepted solution

Thanks for all the help. I was able to write(modify) a Dynamo/Python script that allows you to select an object and find the views and sheets that the object appears in...

000477.jpg

Here's the dynamo script. Very useful to us!

import clr
clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument

elementz = UnwrapElement(IN[0])

viewtemplates = list()
views = list()
viewcollector = FilteredElementCollector(doc).OfClass(View)

sheetcollector = FilteredElementCollector(doc).OfClass(ViewSheet)

for view in viewcollector:
    if view.IsTemplate == True:
        viewtemplates.append(view)
    else:
        views.append(view)

viewmatches = list()

viewmatchez  = list()


for v in views:
        viewelemidz=[]
        viewelems = list()
        viewelems = FilteredElementCollector(doc,v.Id)
        for viewelem in viewelems:
            viewelemidz.append(viewelem.Id)
        for i in range(0,1):
			elem = elementz
			elemid = elem.Id
			viewmatchez = viewmatches
			if elemid in viewelemidz:
				viewmatchez.append(v)


sheetz = list()
for sheet in sheetcollector:
    sheetz.append(sheet)

elsheetmatches = list()
for i in range(0,1):
    elviewmatches = viewmatches
    elsheets = list()
    for viewmatch in elviewmatches:
        sheetnum = viewmatch.get_Parameter(BuiltInParameter.VIEWER_SHEET_NUMBER).AsString()
        if sheetnum != '-':
            for sheetel in sheetz:
                if sheetel.get_Parameter(BuiltInParameter.SHEET_NUMBER).AsString() == sheetnum:
                    elsheets.append(sheetel)
    elsheetmatches = elsheets

OUT = viewmatches, elsheetmatches

 

 

0 Likes
Message 6 of 13

RDAOU
Mentor
Mentor

@davidjimm wrote:

Thanks for all the help. I was able to write(modify) a Dynamo/Python script that allows you to select an object and find the views and sheets that the object appears in...

Here's the dynamo script. Very useful to us!


 

@davidjimm 

 

How is knowing that the element is in 36 views useful exactly? 

 

RDAOU_0-1638805114553.png

 

PS: when you copy a code, have the decency to provide a link to where it was copied from 

https://forum.dynamobim.com/t/find-views-and-sheets-that-show-a-specific-element/1921/5

 

 

 

YOUTUBE | BIM | COMPUTATIONAL DESIGN | PARAMETRIC DESIGN | GENERATIVE DESIGN | VISUAL PROGRAMMING
If you find this reply helpful kindly hit the LIKE BUTTON and if applicable please ACCEPT AS SOLUTION


Message 7 of 13

davidjimm
Enthusiast
Enthusiast

Yeah, my first post here. Thanks for the heads up about posting where I copied it from.

 

To answer your question, in the project I showed an example from we have well over a thousand views, and somewhere in the range of 100 sheets.

 

To be able to narrow this down 32 views and 4 sheets is extremely helpful! 

 

The key is looking for what sheets this object is on for us. Finding the views is usually just a means to find the sheets.

 

I open those 4 sheets, and the go to the 3D view and highlight the object. Then pan through the see where it is.

 

If I do have to open and page through 32 views it's a lot easier than opening 1119 views to look for it.

aa.jpg

 

bb.jpg

Thanks again for trying to help 😁. And for setting me straight on posting the link I got the original code from.

 

Message 8 of 13

RDAOU
Mentor
Mentor

@davidjimm 

 

You didn't need to type such a length reply I still do not see the usefulness of knowing the object appears in 36 views...apart from that, I wouldn't be looking for Beams Reinforcement details on a Furniture layout.

 

 

 

 

 

YOUTUBE | BIM | COMPUTATIONAL DESIGN | PARAMETRIC DESIGN | GENERATIVE DESIGN | VISUAL PROGRAMMING
If you find this reply helpful kindly hit the LIKE BUTTON and if applicable please ACCEPT AS SOLUTION


0 Likes
Message 9 of 13

davidjimm
Enthusiast
Enthusiast

I need the SHEETS that the object is on, per the original post. "We are in a large project, and I would like to be able to select an object and find the sheet it is on."

If I right click on an object and go to find referring views...

CC.jpg

DD.jpg

These are the views I get that refer to this object. Of those views only a few of them will actually be put on sheets. To find those sheets I would have to open up all those views.

 

If I run the dynamo/script, it gives me the 3 sheet names that have this object on it (SC-1214,SC-1123,C-0106)

 

I think it's helpful. If you don't I understand.

 

 

ee.jpg

 

 

 

Message 10 of 13

robert.jungergard
Enthusiast
Enthusiast

Hi,

Can you post the dynamo script? I tried to re-create it from your views and the copied code but I couldn't get it to work. I re-created it in 2022, and I got an error message about Dynamo is moving towards Python Engine 3 instead of 2.

0 Likes
Message 11 of 13

davidjimm
Enthusiast
Enthusiast

I'll try to update my Dynamo code and repost it. The models we're working in are Revit 2019, but I do have Revit 2021 on my computer. I'll get the program to run on that and repost it.

 

 

0 Likes
Message 12 of 13

davidjimm
Enthusiast
Enthusiast

Ok, here's the Dynamo file from Revit 2021.

Just for some clarification, I left the first "select" node blank. If you leave that node blank, when the users run it in the player it will ask for an object. If you fill it in, it will use that object and not ask.

 

Maybe 2022 has a different Python version than this, hopefully you can still get it to work. I'd be happy to do anything else you can think of.

I'm going to post the picture, code, and try to attach the file also. A little redundant, but maybe it will help.

 

findfile 2021.jpg

 

 

import clr
clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument

elementz = UnwrapElement(IN[0])

viewtemplates = list()
views = list()
viewcollector = FilteredElementCollector(doc).OfClass(View)

sheetcollector = FilteredElementCollector(doc).OfClass(ViewSheet)

for view in viewcollector:
    if view.IsTemplate == True:
        viewtemplates.append(view)
    else:
        views.append(view)

viewmatches = list()

viewmatchez  = list()


for v in views:
        viewelemidz=[]
        viewelems = list()
        viewelems = FilteredElementCollector(doc,v.Id)
        for viewelem in viewelems:
            viewelemidz.append(viewelem.Id)
        for i in range(0,1):
			elem = elementz
			elemid = elem.Id
			viewmatchez = viewmatches
			if elemid in viewelemidz:
				viewmatchez.append(v)


sheetz = list()
for sheet in sheetcollector:
    sheetz.append(sheet)

elsheetmatches = list()
for i in range(0,1):
    elviewmatches = viewmatches
    elsheets = list()
    for viewmatch in elviewmatches:
        sheetnum = viewmatch.get_Parameter(BuiltInParameter.VIEWER_SHEET_NUMBER).AsString()
        if sheetnum != '-':
            for sheetel in sheetz:
                if sheetel.get_Parameter(BuiltInParameter.SHEET_NUMBER).AsString() == sheetnum:
                    elsheets.append(sheetel)
    elsheetmatches = elsheets

OUT = viewmatches, elsheetmatches

 

 

Message 13 of 13

payam.rad
Advocate
Advocate

This is a great tool to have, especially if there is a change and you want to make sure all the sheets impacted with the changed elements are identified and clouded, etc. 

Seems like it is taking much longer if you have some sheets that are not part of the set, as this goes thru all the possible sheets in the project and takes a lot of time. It would be great to include another parameter to only go thru sheets that are part of selected "sheet index" schedule for example. Would you be able to include that feature as well?

0 Likes