Schedules

Schedules

stever66
Advisor Advisor
2,601 Views
5 Replies
Message 1 of 6

Schedules

stever66
Advisor
Advisor

I’m having some trouble with schedules.  In particular, I’m working with note block schedules, in case that matters.  I’ve made several attempts at these, and I’ve tried searching google and this forum for answers, but have come up short on attempts to do any of these. I’ve also tried using the BIP checker, and trying to access these via parameters.  

 

1.  Get the sheet name or number that the schedule is on.   I’ve tried working with both the viewschedule, and the definition.  This one looked like it’s stored in a parameter, but I can’t seem to get the string for this sheet menace or number.   The closest I’ve come is getting “Revit.DB.Parameter”.

 

2.   Get the name of the schedule.   The name that appears in the project browser.

 

3.  Find out if a field is hidden and/or hide or unhindered the field.   One thing I tried needed a “fieldId”, and I’m not sure how to get that.  Simply using an integer like 0 or 1 doesn’t compile?

 

thanks for help on any of these.

 

0 Likes
Accepted solutions (2)
2,602 Views
5 Replies
Replies (5)
Message 2 of 6

RPTHOMAS108
Mentor
Mentor
Accepted solution

1)

Schedules can appear on more than one sheet. ScheduleSheetInstance is the item that displays the schedule on the sheet (one or more per sheet).

You then have:

ScheduleSheetInstance.ScheduleId & ScheduleSheetInstance.OwnerViewId

So filter for ScheduleSheetInstances with the matching ScheduleId of your ViewSchedule and extract the OwnerViewId for each such item (that'll be the sheet id the SheduleSheetInstance is on). From this you can compile a list of sheets the schedule is on. Distinct could be used to remove duplicates of the same schedule on a particular sheet. It would only be user error as a reason that places the same schedule twice on a certain sheet but you have to allow for such.

2)

ViewSchedule.Name derived from Element.Name? Is the name formatted some other way in the browser (not for me)?

3)

Schedule.Definition.GetFieldOrder => a list of ScheduleFieldId

Schedule.Definition.GetField(ScheduleFieldId) => ScheduleField.IsHidden

So with the above you can iterate the fields match by criteria such as ParameterId or Name to then check IsHidden.

 

 

 

0 Likes
Message 3 of 6

sragan
Collaborator
Collaborator

Still can't figure out #1, and it somewhat goes back to my earlier question about what types of categories we can filter for:

 

collector.OfClass(typeof(??)).ToElement(); - Autodesk Community - Revit Products

 

The following line always seems to return an empty list:

IList<Element> sheetcollection = collector.(ScheduleSheetInstance).ToElements();

 

On the other hand, using the ElementCategoryFilter there isn't any category called OST_ScheduleSheetInstance.  So I don't think I can use that filter.

 

 

For #2, yes, that does work.  Oddly enough, the vs.Name is all that's needed.   Having ".ToString()" or ".AsString()" doesn't seem necessary.   However, it does still seem to work if .ToString() is tacked on the end.   I have no idea why I couldn't get this to work earlier.  I tried a lot of things, but I know I tried vs.Name.ToString(), and I just kept getting Revit.DB.Parameter as the string.

 

I still need to look at #3.  

 

0 Likes
Message 4 of 6

RPTHOMAS108
Mentor
Mentor
Accepted solution

The category of the ScheduleSheetInstance is: OST_ScheduleGraphics

The category of the ViewSchedule is: OST_Schedules

 

They should work but in this instance I would usually use a class filter, typically I use class filter unless they can't be used. When you use a class filter it inherently distinguishes between types and instances:

FamilySymbol/FamilyInstance

WallType/Wall etc.

 

Regarding (1) something of this nature would work:

 

Public Function Obj_220207a(commandData As ExternalCommandData, ByRef message As String, elements As ElementSet) As Result
        Dim app = commandData.Application
        Dim uidoc = commandData.Application.ActiveUIDocument
        Dim IntDoc = uidoc.Document

        Dim VS As ViewSchedule = TryCast(IntDoc.ActiveView, ViewSchedule)
        If VS Is Nothing Then Return Result.Cancelled Else

        Dim FEC As New FilteredElementCollector(IntDoc)
        Dim ECF As New ElementClassFilter(GetType(ScheduleSheetInstance))
        Dim Els As List(Of ScheduleSheetInstance) = FEC.WherePasses(ECF).ToElements _
                                                            .Cast(Of ScheduleSheetInstance) _
                                                            .Where(Function(x) x.ScheduleId = VS.Id).ToList

        Dim SheetIds As List(Of ElementId) = Els.Select(Function(x) x.OwnerViewId).Distinct.ToList

        For i = 0 To SheetIds.Count - 1
            Dim VSht As ViewSheet = IntDoc.GetElement(SheetIds(i))
            Debug.WriteLine(VSht.SheetNumber & " - " & VSht.Name)
        Next
        Return Result.Succeeded

    End Function

 

public Result Obj_220207a(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication app = commandData.Application;
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document IntDoc = uidoc.Document;

            ViewSchedule VS = IntDoc.ActiveView as ViewSchedule;
            if (VS == null)
                return Result.Cancelled;

            FilteredElementCollector FEC = new FilteredElementCollector(IntDoc);
            ElementClassFilter ECF = new ElementClassFilter(typeof(ScheduleSheetInstance));
            List<ScheduleSheetInstance> Els = FEC.WherePasses(ECF).ToElements().Cast<ScheduleSheetInstance>().Where(x => x.ScheduleId == VS.Id).ToList();

            List<ElementId> SheetIds = Els.Select(x => x.OwnerViewId).Distinct().ToList();

            for (int i = 0; i <= SheetIds.Count - 1; i++)
            {
                ViewSheet VSht = (ViewSheet) IntDoc.GetElement(SheetIds[i]);
                Debug.WriteLine(VSht.SheetNumber + " - " + VSht.Name);
            }
            return Result.Succeeded;

        }

 

0 Likes
Message 5 of 6

sragan
Collaborator
Collaborator

I was trying to convert your VB code into C# before I looked at your second section of code.  

 

I was doing OK until I got to the Linq lines.   Anyhow, my bad 😊 

 

I'm not sure I understand everything here 100%, but it definitely works.   Thanks so much for spelling it out in such detail for me.  I'm not a professional programmer, so this stuff doesn't always come easy to me.

 

That's 2 down, and I still need to find time to look at the fields.

0 Likes
Message 6 of 6

earlmotley.966
Community Visitor
Community Visitor

@stever66 wrote:

I’m having some trouble with schedules.  In particular, I’m working with note block schedules, in case that matters.  I’ve made several attempts at these, and I’ve tried searching google and this forum for answers, but have come up short on attempts to do any of these. I’ve also tried using the BIP checker, and trying to access these via parameters.  

 

1.  Get the sheet name or number that the Scheduling is on.   I’ve tried working with both the viewschedule, and the definition.  This one looked like it’s stored in a parameter, but I can’t seem to get the string for this sheet menace or number.   The closest I’ve come is getting “Revit.DB.Parameter”.

 

2.   Get the name of the schedule.   The name that appears in the project browser.

 

3.  Find out if a field is hidden and/or hide or unhindered the field.   One thing I tried needed a “fieldId”, and I’m not sure how to get that.  Simply using an integer like 0 or 1 doesn’t compile?

 

thanks for help on any of these.

 


Can we use app for scheduling purpose? Or we have to specific use of this thing for perform the task?

0 Likes