Get/set location of schedule graphics on sheet

Any way to get/set location of schedule graphics on sheet?

1 Like

I believe the API method for getting a schedule instance location is schedule.Point
Creating a schedule instance requires the ScheduleId. You can find the method here:
http://www.revitapidocs.com/2017/8402dc3c-8bdc-40f5-be54-da08bc69d0cd.htm

1 Like

Thanks @Nick_Boyts
I’m learning Python but not there yet to tap into API.
It’s interesting that there’s no standard/custom node for it.
Can be something for the programmers here to look into.

Give the API a try. It wasn’t as hard as I expected when I first started on it.
This would be a good method to learn with as well, as the inputs are all pretty straight forward. You should be able to get all of the inputs with some pretty standard nodes and just plug them into your python code.

This should do the trick:

Here’s code for the Sheet.Schedules node:

# Copyright(c) 2017, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

import clr
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

clr.AddReference("RevitNodes")
import Revit

clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

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


def process_list(_func, _list):
    return map(lambda x: process_list(_func, x) if type(x) == list else _func(x), _list)


def get_schedules(item):
    return FilteredElementCollector(doc, ElementId(item.Id)).OfClass(ScheduleSheetInstance).ToElements()


output = []
try:
    errorReport = None
    output = process_list(get_schedules, IN[0])

except:
    # if error occurs anywhere in the process catch it
    import traceback

    errorReport = traceback.format_exc()

if errorReport is None:
    OUT = output
else:
    OUT = errorReport

Here’s code for the Schedule.SetLocation node:

# Copyright(c) 2017, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

import clr
import sys

pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

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

clr.AddReference("RevitNodes")
import Revit

clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

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

doc = DocumentManager.Instance.CurrentDBDocument

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


def process_list(_func, _list):
    return map(lambda x: process_list(_func, x) if type(x) == list else _func(x), _list)


def set_location(item, location=IN[1].ToXyz()):
    schedule = UnwrapElement(item)
    schedule.Point = location
    return item

output = []
try:
    errorReport = None
    TransactionManager.Instance.EnsureInTransaction(doc)
    output = process_list(set_location, IN[0])
    TransactionManager.Instance.TransactionTaskDone()
except:
    import traceback

    errorReport = traceback.format_exc()

# Assign your output to the OUT variable
if errorReport is None:
    OUT = output
else:
    OUT = errorReport

The general idea here is that you select all ScheduleSheetInstance object. Those are basically schedules placed on a sheet. The only trick here is that a Revision Schedule is also a ScheduleSheetInstance so we need to get rid of it. Then we collect just the one that we need based on a name and finally set all of their locations to the same position so all our schedules nicely align from sheet to sheet.

Ps. Sheet location is relative to view origin which is not always titleblocks bottom/left corner. Keep in mind that user could have moved the titleblock and in that case this will align all schedules but you would need need to also first align all Titleblocks to get the desired result. That’s however, a different topic so if you wish for someone to help with that, just start a new topic.

8 Likes

2 posts were split to a new topic: Get/Set Location of Schedule graphics follow up

Thanks @Konrad_K_Sobon for your python script on the related thread Get/Set Location of Schedule graphics follow up. It works perfectly with all our schedules!!

But, we can’t make it works with any other type of view, like viewports of floor plans or sections.

What we have to modify on the script to get the view location?

We are getting this error on the python script:

Traceback (most recent call last):
    File "<string>, line 38, in <module>
    File "<string>, line 29, in process_list
    File "<string>, line 29, in<lambda$703>
    File "<string>, line 33, in get_location
AttributeError: 'ViewPlan' object has no attribute 'Point'

We have duplicated sheets and the views with the scope box. But we don’t know why, on the resulted sheets the view it’s not on the same location. So we need to get the coordinates from the original to move the final views with a vector.

Thanks in advance!

Regular views use a different API method to set location. I think for views it’s called viewport.SetBoxCenter() and actually uses center of the viewport as reference which is different than schedules which use top/left corner if I remember correctly.

Revit API reference: https://apidocs.co/apps/revit/2019/6c94a491-60e6-d598-5c0b-1cb08468e655.htm

1 Like

niceeee!!

Hi, do you know what im doing wrong here?

Im not sure if this is what you are looking for, but here is a simpler way to align schedules and views. Just arrange the views on one sheet how you want. Select that sheet in the drop down and then select the other sheets you want the other views to be align on in the project browser. This will align schedules, views, etc on those sheets selected.

ALIGN VIEWS ON SHEETS.dyn (4.1 KB)