Set Schedule Field to Hidden

I’m trying to set some of my schedule fields to be hidden using the IsHidden property (link) I found on RevitAPIDocs. Seems pretty straight forward but something seems to be going over my head.

I’ve tried getting and setting the property but everything returns the same warning. Am I missing a reference? Gotta be something simple.

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

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
param = UnwrapElement(IN[0])

#TransactionManager.Instance.EnsureInTransaction(doc)
param.IsHidden = True
#TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = 0
2 Likes

Hi @Nick_Boyts

You can do like this:

And here is the dyn file Hide Column Schedule.dyn (4.1 KB)

2 Likes

Thanks @Kulkul!
Is there a difference between using the ScheduleField object I used and the one pulled directly from the schedule definition? This was the direction I was about to go.

EDIT: Must be. It looks like ScheduleField object from Dynamo isn’t unwrapping properly.
image

I don’t get this. Would it be possible to see the related piece of code? Thanks :slightly_smiling_face:

I already have done that please look carefully before you ask.

I tried it unfortunately I’m getting null when I feed parameters with a list. Is it not possible with list?

I read carefully, I would like to see an illustration the use of ScheduleField that would illustrate what Nick exposed, if you don’t mind :slight_smile:

I just got the schedule view from the Views node and used the ScheduleFields node to get it’s list of fields. Then input one (or many) of the fields into my python code.

Got an error:
Hide-field

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

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
from Revit.Elements import *
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.GeometryReferences)

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

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

view = doc.ActiveView

def U(elem): 
	a = UnwrapElement(elem)
	return a

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


definit = schedule.Definition
countParameters = definit.GetFieldCount() 
# Parameter names
names = []
for i in range(countParameters):
	Parname = definit.GetField(i).ColumnHeading # Parameter Column name
	if Parname == colName:
		index = i

field = schedule.Definition.GetField(index) # schedule field

TransactionManager.Instance.EnsureInTransaction(doc)
field.IsHidden = IN[2] # 1 = Hide, 0 = Show
TransactionManager.Instance.TransactionTaskDone()
OUT = schedule

I had the same problem, but now I resolved. Field name should be a string. Try to use the string from object node.

Kulkul,

This script works great for a single schedule, but how can it be adapted to accept a list of applicable schedules that require a common column to be hidden?

4 Likes

hello I am looking a solution to rename the heading of a field, I found this topic as something that could solve it with python

The dyn link is outdated. Can you share again if possible? I have been trying to hide column but unsuccessful. Thank you in advance