Unable to change SheetColumnWidth (Schedule View)

Hi,
I am struggling to change the width of a column in a schedule (or the width of the entire schedule) already placed on to a sheet.
I’ve tried and failed to change ScheduleField properties. What did I wrong?
Thanks in advance.

import clr

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

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

#element = UnwrapElement(IN[0])
element = IN[0]
otput = []

otput.append(element.SheetColumnWidth)

#TransactionManager.Instance.EnsureInTransaction(doc)
#TransactionManager.Instance.TransactionTaskDone()

OUT = otput

Hi @csaba.szabo ,
It is not working because of the class of the input you’re giving to the Python node which is a Revit.Schedule.ScheduleField, as you can see from the image below.
The class you are looking for is DB.ScheduleField, from a complete different Namespace :slight_smile:

try with this method below.
(here the function you want copy/paste)

def getField(schedule, field_name):
	definition = schedule.Definition
	count = definition.GetFieldCount()
	for i in range(count):
		if definition.GetField(i).GetName() == field_name:
			return definition.GetField(i)

1 Like

addendum:
You’ve been of inspiration for a project I’m building up lately, so I made also this custom node in my package. Its name is 𝑀⁴𝐵 Views.ScheduleColumnWidth

The project name is Macro4BIM
Maybe some users that land to this post are more comfortable using custom node/packages instead of python nodes… or maybe someone will find interesting my package.

3 Likes

Thank you! It works as expected.