Get Scheduled Field from Heading

Hi all, I was wondering if it is possible to get the scheduled field (parameter name) from the heading?

For example:
Scheduled field = “cooling capacity”
Heading = “total cooling capacity (MBH)”
Can I get the scheduled field “cooling capacity” from the heading “total cooling capacity (MBH)”?

Thanks

I don’t think you can get it directly from the header but you do have a few options to get it from the schedule definition.
https://www.revitapidocs.com/2020/435e0f04-6cb4-c0f7-3ce7-61a6ad3cd7e6.htm

script #1 will get all the scheduled fields from a specified schedule and script #2 will get the heading of all the scheduled fields from a specified schedule. I would appreciate if someone can help me edit script #1 to get the scheduled fields from the heading list from input 1 or for script #2 to get the heading from the scheduled field list from input 1. Thanks

Script #1

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

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

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

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

from System.Collections.Generic import *

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# The inputs to this node will be stored as a list in the IN variable

schedule = UnwrapElement(IN[0])
colHeading = IN[1]

# Start the transaction
TransactionManager.Instance.EnsureInTransaction(doc)

definition = schedule.Definition
fieldOrder = definition.GetFieldOrder()

paramNames = [definition.GetField(i).GetName() for i in fieldOrder]

# End the transaction
TransactionManager.Instance.TransactionTaskDone()

# Assign your output to the OUT variable
OUT = paramNames

Script #2

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

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

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

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

from System.Collections.Generic import *

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# The inputs to this node will be stored as a list in the IN variable

schedule = UnwrapElement(IN[0])
paramNames = IN[1]

# Start the transaction
TransactionManager.Instance.EnsureInTransaction(doc)

definition = schedule.Definition
fieldOrder = definition.GetFieldOrder()
colHeadings = [definition.GetField(i).ColumnHeading for i in fieldOrder]

# End the transaction
TransactionManager.Instance.TransactionTaskDone()

# Assign your output to the OUT variable
OUT = colHeadings

Why do you need to use the header? Why can’t you get the parameter directly?
My first suggestion would be to get the index of the header you’re looking for and then the item at that index from the list of parameters. (Just make sure no parameters are hidden when getting the index.)

I need the header because this is the information that is imported from an excel schedule to revit.

I solved my problem by comparing excel headers to active view headers and then finding the parameter name.

If I remember correctly you can get the information that you’re looking for from the tableview class. That class contains all the information of how a schedule is shown in revit.

This may help lead you in the right direction…