Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find Unsheeted views should also list schedules #209

Closed
eirannejad opened this issue Jul 3, 2017 · 3 comments
Closed

Find Unsheeted views should also list schedules #209

eirannejad opened this issue Jul 3, 2017 · 3 comments

Comments

@eirannejad
Copy link
Collaborator

No description provided.

@eirannejad
Copy link
Collaborator Author

eirannejad commented Jul 3, 2017

"""Lists views that have not been placed on any sheets."""

from scriptutils import this_script
from revitutils import doc, uidoc

import clr
# noinspection PyUnresolvedReferences
from Autodesk.Revit.DB import FilteredElementCollector as Fec
# noinspection PyUnresolvedReferences
from Autodesk.Revit.DB import BuiltInCategory, View, ViewType, ScheduleSheetInstance, ViewSchedule


dviews = []
mviews = []
lviews = []
scheduleviews = []
all_sheeted_view_ids = []

views = Fec(doc).OfCategory(BuiltInCategory.OST_Views).WhereElementIsNotElementType().ToElements()
for v in views:
    if not v.IsTemplate:
        if v.ViewType == ViewType.DraftingView:
            dviews.append(v)
        elif v.ViewType == ViewType.Legend:
            lviews.append(v)
        else:
            mviews.append(v)

schedule_views = Fec(doc).OfClass(clr.GetClrType(ViewSchedule)).WhereElementIsNotElementType().ToElements()
for sv in schedule_views:
    scheduleviews.append(sv)


sheets = Fec(doc).OfCategory(BuiltInCategory.OST_Sheets).WhereElementIsNotElementType().ToElements()
for sht in sheets:
    vp_ids = [doc.GetElement(x).ViewId for x in sht.GetAllViewports()]
    all_sheeted_view_ids.extend(vp_ids)

allSheetedSchedules = Fec(doc).OfClass(ScheduleSheetInstance).ToElements()
for ss in allSheetedSchedules:
    all_sheeted_view_ids.append (ss.ScheduleId)


this_script.output.print_md('### DRAFTING VIEWS NOT ON ANY SHEETS')
for v in dviews:
    if v.Id in all_sheeted_view_ids:
        continue
    else:
        print('TYPE: {1}\t\tID: {2}\t\t{0}'.format(v.ViewName,
                                                   v.ViewType,
                                                   this_script.output.linkify(v.Id)))


this_script.output.print_md('### MODEL VIEWS NOT ON ANY SHEETS')
for v in mviews:
    if v.Id in all_sheeted_view_ids:
        continue
    else:
        print('TYPE: {1}\t\tID: {2}\t\t{0}'.format(v.ViewName,
                                                   v.ViewType,
                                                   this_script.output.linkify(v.Id)))


this_script.output.print_md('### LEGENDS NOT ON ANY SHEETS')
for v in lviews:
    if v.Id in all_sheeted_view_ids:
        continue
    else:
        print('TYPE: {1}\t\tID: {2}\t\t{0}'.format(v.ViewName,
                                                   v.ViewType,
                                                   this_script.output.linkify(v.Id)))


this_script.output.print_md('### SCHEDULES NOT ON ANY SHEETS')
for v in scheduleviews:
    if v.Id in all_sheeted_view_ids:
        continue
    else:
        print('TYPE: {1}\t\tID: {2}\t\t{0}'.format(v.ViewName,
                                                   v.ViewType,
                                                   this_script.output.linkify(v.Id)))

@eirannejad
Copy link
Collaborator Author

Will be published in 4.4 soon

eirannejad added a commit that referenced this issue Jul 4, 2017
@thanh293
Copy link

thanh293 commented Jun 5, 2018

[x] add total to the script
[x]spelling mistake COLELCTING DATA to COLLECTING DATA :D
[.]found some count discrepancy not too sure why...(I worked on a shared model alone, specific problem to look: clearly made 8 schedules but counted as 10 instead)

"""Lists views that have not been placed on any sheets."""

from pyrevit import framework
from pyrevit import revit, DB
from pyrevit import script

out = script.get_output()

COLLECTING DATA

dviews = []
mviews = []
lviews = []
scheduleviews = []
all_sheeted_view_ids = []

Collecting all the model, drafting, and legend views

views = DB.FilteredElementCollector(revit.doc)
.OfCategory(DB.BuiltInCategory.OST_Views)
.WhereElementIsNotElementType()
.ToElements()

for v in views:
if not v.IsTemplate:
if v.ViewType == DB.ViewType.DraftingView:
dviews.append(v)
elif v.ViewType == DB.ViewType.Legend:
lviews.append(v)
else:
mviews.append(v)

Schedules need to be collected separately

schedule_views = DB.FilteredElementCollector(revit.doc)
.OfClass(framework.get_type(DB.ViewSchedule))
.WhereElementIsNotElementType()
.ToElements()

for sv in schedule_views:
scheduleviews.append(sv)

Now collecting all sheets and find all sheeted views

sheets = DB.FilteredElementCollector(revit.doc)
.OfCategory(DB.BuiltInCategory.OST_Sheets)
.WhereElementIsNotElementType()
.ToElements()

for sht in sheets:
vp_ids = [revit.doc.GetElement(x).ViewId for x in sht.GetAllViewports()]
all_sheeted_view_ids.extend(vp_ids)

Find all sheeted schedule views and add them to the list as well

allSheetedSchedules = DB.FilteredElementCollector(revit.doc)
.OfClass(DB.ScheduleSheetInstance)
.ToElements()

for ss in allSheetedSchedules:
all_sheeted_view_ids.append(ss.ScheduleId)

NOW LET'S REPORT

out.print_md('### DRAFTING VIEWS NOT ON ANY SHEETS')
for v in dviews:
if v.Id in all_sheeted_view_ids:
continue
else:
print('TYPE: {1}\t\tID: {2}\t\t{0}'.format(v.ViewName,
v.ViewType,
out.linkify(v.Id)))

print("Total {}".format(len(dviews)))

out.print_md('### MODEL VIEWS NOT ON ANY SHEETS')
for v in mviews:
if v.Id in all_sheeted_view_ids:
continue
else:
print('TYPE: {1}\t\tID: {2}\t\t{0}'.format(v.ViewName,
v.ViewType,
out.linkify(v.Id)))
print("Total {}".format(len(mviews)))

out.print_md('### LEGENDS NOT ON ANY SHEETS')
for v in lviews:
if v.Id in all_sheeted_view_ids:
continue
else:
print('TYPE: {1}\t\tID: {2}\t\t{0}'.format(v.ViewName,
v.ViewType,
out.linkify(v.Id)))
print("Total {}".format(len(lviews)))

out.print_md('### SCHEDULES NOT ON ANY SHEETS')
for v in scheduleviews:
if v.Id in all_sheeted_view_ids:
continue
else:
print('TYPE: {1}\t\tID: {2}\t\t{0}'.format(v.ViewName,
v.ViewType,
out.linkify(v.Id)))
print("Total {}".format(len(scheduleviews)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants