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
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.
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.
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.
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