Got 2 columns in schedule that I need to turn on or off, cant get it to work.
Error message:Index not defined
schedule = UnwrapElement(IN[0])
scheduleDefinition = schedule.Definition
countColumns = scheduleDefinition.GetFieldCount()
for i in range(countColumns):
colName = ["Discipline", "Status"]
colNameCount = len(colName)
for y in range(colNameCount):
scheduleColumns = scheduleDefinition.GetField(y).ColumnHeading
if scheduleColumns == colName:
index = y
fields = schedule.Definition.GetField(index)
fields.IsHidden = IN[1]
print(countColumns)
Hi jmark,
That is correct, I’ve tried different indentations.
I dont have any programs like visual studio code or pycharm to help and correct the error.
Cant check if the nested for loop is correct…
schedule = UnwrapElement(IN[0])
scheduleDefinition = schedule.Definition
countColumns = scheduleDefinition.GetFieldCount()
for i in range(countColumns):
colName = ["Discipline", "Status"]
colNameCount = len(colName)
for y in range(colNameCount):
scheduleColumns = scheduleDefinition.GetField(y).ColumnHeading
if scheduleColumns in colName:
index = y
fields = schedule.Definition.GetField(index)
fields.IsHidden = IN[1]
print(countColumns)
also I changed some line in the if statement of scheduleColumns, see if it’ll work
Hi,
I’ve adjusted the indention and gets no errors, but the code dont hide or unhide the columns.
Need your help, tanks in advance
schedule = UnwrapElement(IN[0])
scheduleDefinition = schedule.Definition
countColumns = scheduleDefinition.GetFieldCount()
for i in range(countColumns):
colName = ["Sheet Number", "Current Revision"]
colNameCount = len(colName)
for y in range(colNameCount):
scheduleColumns = scheduleDefinition.GetField(i).ColumnHeading
if scheduleColumns == colName:
index = i
fields = schedule.Definition.GetField(index)
fields.IsHidden = IN[1]
OUT = countColumns
Hi, theoretically the IsHidden method can get hold of that, if it still doesn’t work then i guess we already hit a wall and let’s wait for the others to chime in, for the meantime have you tried to close and open the graph again after changing the script just to refresh it? or at least use the force run script from data-shapes.