Sheet Count Dynamo

I am trying to get dynamo to create a sheet count automatically so that my sheets read “Page __ of __”. So far through research, I’ve created the attached script. However, can not get it to work because of the error “dereferncing a non-pointer.” I am new to dynamo, and therefore stuck. Can someone please help? Thank you!SheetCount

Not sure what that err is for but I would start here.

Is “_Sheet Count” a parameter in your project? The name needs to be exactly the same.
If it is a parameter what type of parameter is it? Number, Integer, Text, Length, ex… you are passing a number which is not compatible with all parameter types.

Do the list length from List.Sort and Sequence match? Normally you need to subtract one from list count.

1 Like

It is a parameter in my project (integer), and it is written exactly as shown. Plus, the lengths do match. I had created this script using the same parameter and method, but this script didn’t sort by discipline,
as the above script does.
SheetCount2

In you’re first image, you are giving the Element.SetParameterByName node a sorted list of your Sheet Numbers and not your Sheet elements. You need to sort your Sheet elements by their Sheet numbers like you have in the second image you shared

1 Like

@asma.salim Hi,
Your method will work. Is your parameter “_Sheet Count” added to the title block? or added to the sheets? If it is added to your title block you will need to change your category to Title Blocks rather sheets.

Cheers,

DynamoSheeNumberOf

Hello Asama,

If you copy this into a Python node block and run it, it should achieve what you’re after.

import System
import clr
clr.AddReference(‘ProtoGeometry’)
clr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference(‘RevitServices’)
clr.AddReference(‘ProtoGeometry’)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
from Autodesk.DesignScript.Geometry import *
clr.AddReference(‘RevitAPI’)
import Autodesk
from Autodesk.Revit.DB import *

shts = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Sheets).WhereElementIsNotElementType().ToElements()

numberOfSheets = Len(shts)

TransactionManager.Instance.EnsureInTransaction(doc)

for s in shts:
s.LookupParameter(“_Sheet Count”).Set(numberOfSheets)

TransactionManager.Instance.TransactionTaskDone()

OUT = shts

1 Like

That works fine, until sheet AS101 needs to be before sheet AR101. That script alphabetizes and then adds sheet numbers. I am looking for a way to number the sheets as shown in the project browser of revit. Is there a way to do so? Thanks!!

Thank you so much for the python node block, but whenever I run it, this error message pops up:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
unexpected token ‘‘’

Please let me know how I can resolve this issue. Thank you!!!

Hey All! Thank you for your help, but I figured it out. First I had to group the sheets as they were in the project browser (by discipline), and then sort them by project number.

1 Like

When it comes to sheets, views, or elements I always try to find a tendency or some way to get like items together for easy manipulation.

1 Like