The following simple script defines functions and a button to enable one to toggle the active layer between enabled and disabled states, just as one would do by pressing on it–in fact, that’s exactly what the script does.
However, for whatever reason, from the script this only works to enable a disabled layer; it doesn’t disable an enabled layer. If you try it, you’ll see the difference, and the various Note commands will give some debugging output.
I need to be able to do this somehow, as part of a much larger script. Anyone know what’s going on?
Thanks,
Ken
//ZScript
// Flag values for layer flags returned by IGetFlags.
// 0: Not Created
// 8: Disabled
// 9: Enabled
// 10: Disabled and the active layer
// 11: Enabled and the active layer
[RoutineDef, GetActiveLayer,
[Loop, 16,
[VarSet, layer, [StrMerge, "Layer:Layer ", [Val, n+1]]]
[VarSet, flags, [IGetFlags, layer]]
[If, (flags=10) || (flags=11),
[VarSet, result, layer]
[LoopExit]
]
, n]
, result]
[RoutineDef, Toggle2,
[VarDef, activeLayer, “”] [RoutineCall, GetActiveLayer, activeLayer]
[Note, [StrMerge, "TOGGLE: Toggling ", activeLayer]]
[IPress, activeLayer]
[Note, “TOGGLE: done”]
]
[ISubPalette, Document:Ortho]
[IButton, Document:Ortho:ToggleActive, “Toggle Active View”, [RoutineCall, Toggle2]]