Set Schedule Field to Hidden


#1

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

Hi @Nick_Boyts

You can do like this:

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


#3

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


#4

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


#5

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


#6

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


#7

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:


#8

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.


#9

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

#10

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