User Tools

Site Tools


macros:example:offonattribute

Example

Off/On Attribute (snippets)

by: Gregory Haynes, November 2018
published: http://forum.avolites.com/viewtopic.php?f=20&t=5936
description: snippets and explanation of how to turn an attribute off or on by means of a coded macro
remarks: essentially this is to enhance the macro Off/On Attribute in Palette which holds this part as recorded commands

functions

Code and Explanation

This was the - not working - idea:

  Programmer.Editor.Fixtures.OnOffAttributeSelected(MenuItem item, Boolean on)
MenuItem refers to one of the softkey menu options, specifically in this case it is one of the attribute softkeys shown when you press the Off button. When you press the softkey in the menu it calls this function passing in a reference to itself, from this it determines which attribute was selected. This is not something that it practical to use in your own macros, instead you should consider the SetControlOff* function.

This would set a particular attribute off in group 1:

  Group.RecallGroup(userNumber:1)
  Programmer.Editor.Fixtures.SetControlOff(Programmer.Editor.Fixtures.GetControlIdFromName("Shutter"))
Above I have also used the GetControlIdFromName function to get the control/attribute ID which SetControlOff takes as a parameter, some of these are pre-defined such as Dimmer being 16 however many others are not.

This would set the attribute back to on in the programmer:

To remove the Off flag you can call SetControlProgrammer, if the programmer parameter is set to true it will leave/put the value in the programmer (and remove the Off flag if there is one), if it is set to false the attribute will be cleared.
  Group.RecallGroup(userNumber:1)
  Programmer.Editor.Fixtures.SetControlProgrammer(Programmer.Editor.Fixtures.GetControlIdFromName("Shutter"), true)

This is again to set the attribute on:

To turn an attribute on you need to first select the attribute you want to change and then run the SetSelectedControlsOn function:
  Group.RecallGroup(userNumber:1)
  Programmer.Editor.Fixtures.SetContextAttributeFromId(Programmer.Editor.Fixtures.GetControlIdFromName("Shutter"))
  Programmer.Editor.Fixtures.SetSelectedControlsOn(true)
Pass in true to set the flag, false to remove it. If you prefer there is a matching SetSelectedControlsOff function that you can use in the same way.

All the previous examples are for individual attributes. Here is to set attribute groups off or on:

  Group.RecallGroup(userNumber:1)
  Attribute.Mask.SetMask("OnOff", "IP")
  Programmer.Editor.Fixtures.OnOffFixtureControls(false)
The IP can be any combination of the IPCGBES letters, the parameter for OnOffFixtureControls should be false to turn the attributes off and true to flag them as on.

How to use it

These are code snippets which do not run themselves but are a useful explanation of how these functions work together.

You could leave a comment if you were logged in.
macros/example/offonattribute.txt · Last modified: 2019/05/04 08:38 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki