Rename Schedule Header

Dear Experts,
I was looking for to rename schedule header. Is it possible by Dynamo?

A quick search in the forum:

Yes sir. But Python script not mentioned at post.

You asked if it was possible. The post proves that it is possible and links to the API method for doing so. Now itā€™s up to you to try and make it work.

This will get you started:

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
import Autodesk.Revit.DB as DB
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

# The inputs to this node will be stored as a list in the IN variables.
sched = UnwrapElement(IN[0])
names = IN[1]
newNames = IN[2]

# Retrieve data from the schedule
fields = sched.Definition

#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
# Check for head title match and set new name
for number in range(fields.GetFieldCount()):
	colHead = fields.GetField(number).ColumnHeading
	for n, newName in zip(names, newNames):
		if colHead == n:
			sched.Definition.GetField(number).ColumnHeading = newName
TransactionManager.Instance.TransactionTaskDone()

# Assign your output to the OUT variable.
OUT = 0
1 Like

Off-topic
I really appreciate the help people get on these forum, but people keep asking the same question over and over on these forums because of this (this = solution or code not posted).

Why reinvent the wheel?

Also, not everyone knows Python.

Because these forums are for discussing and learning, not handing people answers. Iā€™m not talking about anybody specifically, but many of these questions that are asked ā€œover and overā€ are not because they havenā€™t been answered, but because people are looking for finished solutions without doing any work (or at least not showing it).

Many threads end up being a back and forth discussion between the people of this forum - offering up partial solutions or insight on how to go about solving a problem - eventually leading to the OP finding their own solution. But itā€™s up to them to share that solution. Thereā€™s nothing that says anybody on these forums is required to provide or share any solution. Most people here are spending their own time trying to help other people, to further educate a growing community. That canā€™t happen if those trying to learn arenā€™t doing anything for themselves.

4 Likes

I should have also clarified in my original post.

ā€œNow itā€™s up to you to try and make it workā€ does not mean youā€™re now on your own. It means itā€™s up to you to put in the effort and try to find a solution. Work through what you can and when you get stuck, come back with specific questions. Thatā€™s what weā€™re here for.

3 Likes

Last off-topic (b/c i donā€™t wanna hijack this topic or pollute it)

I partial agree with you. But i have seen numerous topics (searching for an answer for a problem i have) with hardly any discussion or just someone saying solved (and not telling how).
Forum is getting cluttered with topics / posts which are of no help to anyone.

This does happen and I agree itā€™s frustrating. But like I said before, thereā€™s nothing that says anybody has to share their solution with the forum. You would hope that people coming to a forum for help would be willing to reciprocate the favor, but that isnā€™t always the case. All you can do is ask and hope that they are willing to share or at least help someone else in a similar situation.

2 Likes

Dears,
Thanks for your time and messages. I am Designer and no any capability to write such kind of python programs. My programming skills is 0. That is why addressed this question to the Python experts consideration.
Anyways, many thanks for your time and effort.

Using architectcodingā€™s post (Thank you for proving that!), I was able to figure it out in case anyone is still curious.

Load the Python Standard and DesignScript Libraries

import sys
import clr
clr.AddReference(ā€˜ProtoGeometryā€™)
from Autodesk.DesignScript.Geometry import *

clr.AddReference(ā€˜RevitAPIā€™)
import Autodesk.Revit.DB as DB
clr.AddReference(ā€˜RevitServicesā€™)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

The inputs to this node will be stored as a list in the IN variables.

sched = UnwrapElement(IN[0])
names = IN[1]
newNames = IN[2]

Retrieve data from the schedule

fields = sched.Definition

#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

Check for head title match and set new name

for number in range(fields.GetFieldCount()):

sched.Definition.GetField(number).ColumnHeading = newNames[number]

TransactionManager.Instance.TransactionTaskDone()

Assign your output to the OUT variable.

OUT = 0