Example ====== Patch - Park fixtures 1 thru 100000====== ^ by: | Sebastian Beutel, july 2020 | ^ idea: | Yenz Nyholm, see https://www.facebook.com/groups/Avolites/permalink/1931175330348025/ | ^ description: | Parks/unparks fixtures 1 ~ 100000 | {{tag>park fixtures}} **From Titan v15 on ClearAll() requires two parameters, see [[macros:function:programmer.editor.clearall|]].\\ Simply change the relevant line(s) to ''Programmer.Editor.ClearAll(false, false)''.** ==== functions ==== * [[:macros:function:Menu.Stack.PushOrReloadMenu]] * [[:macros:function:Menu.InjectInput]] * [[:macros:function:Programmer.Editor.Selection.GetSelectedHandles]] * [[:macros:function:Handles.SetSourceHandleRangeFromHandles]] * [[:macros:function:Patch.Repatch.SetDmxAddressesFromSelectedFixture]] * [[:macros:function:Patch.Repatch.ParkSelectedFixtures]] * [[:macros:function:Patch.Repatch.UnParkSelectedFixtures]] * [[:macros:function:Handles.ClearSelection]] * [[:macros:function:Programmer.Editor.ClearAll]] ==== affected properties ==== * [[:macros:property:Windows.PatchView.Handles]] * [[:macros:property:Patch.Repatch.SelectedFixtureHandles]] >The repatch menu does not actually use the PatchSelection, it has its own property Patch.Repatch.SelectedFixtureHandles. ===== Code ===== Parks fixtures 1 ~ 100000. Menu.Stack.PushOrReloadMenu("Primary", "Expert.Root.Program") Menu.InjectInput("OnButtonDown","Channel","",0) Menu.InjectInput("OnButtonDown","NumericKeys","",1) Menu.InjectInput("OnButtonDown","KeypadThrough","",0) Menu.InjectInput("OnButtonDown","NumericKeys","",1) Menu.InjectInput("OnButtonDown","NumericKeys","",0) Menu.InjectInput("OnButtonDown","NumericKeys","",0) Menu.InjectInput("OnButtonDown","NumericKeys","",0) Menu.InjectInput("OnButtonDown","NumericKeys","",0) Menu.InjectInput("OnButtonDown","NumericKeys","",0) Menu.InjectInput("OnButtonDown","KeypadEnter","",0) Programmer.Editor.Selection.GetSelectedHandles("Windows.PatchView.Handles") Handles.SetSourceHandleRangeFromHandles(Windows.PatchView.Handles, true) Patch.Repatch.SetDmxAddressesFromSelectedFixture() Patch.Repatch.ParkSelectedFixtures() Handles.ClearSelection() Programmer.Editor.ClearAll() Unparks fixtures 1 ~ 100000. Menu.Stack.PushOrReloadMenu("Primary", "Expert.Root.Program") Menu.InjectInput("OnButtonDown","Channel","",0) Menu.InjectInput("OnButtonDown","NumericKeys","",1) Menu.InjectInput("OnButtonDown","KeypadThrough","",0) Menu.InjectInput("OnButtonDown","NumericKeys","",1) Menu.InjectInput("OnButtonDown","NumericKeys","",0) Menu.InjectInput("OnButtonDown","NumericKeys","",0) Menu.InjectInput("OnButtonDown","NumericKeys","",0) Menu.InjectInput("OnButtonDown","NumericKeys","",0) Menu.InjectInput("OnButtonDown","NumericKeys","",0) Menu.InjectInput("OnButtonDown","KeypadEnter","",0) Programmer.Editor.Selection.GetSelectedHandles("Windows.PatchView.Handles") Handles.SetSourceHandleRangeFromHandles(Windows.PatchView.Handles, true) Patch.Repatch.SetDmxAddressesFromSelectedFixture() Patch.Repatch.UnParkSelectedFixtures(true) Handles.ClearSelection() Programmer.Editor.ClearAll() Here, the '' pause="0.01" '' seems to be required - if there is no pause, always the previously for repatching selected fixtures will be parked, and if there aren't any an exception is thrown. ===== Explanation ===== This explains the functional steps within the sequence. For all the other XML details please refer to [[:macros:formats_and_syntax#xml_format|Formats and syntax]] The first part simply emulates fixture selection by syntax, like ''1 THRO 100000'': * ''Menu.Stack.PushOrReloadMenu("Primary", "Expert.Root.Program")'' makes sure we are in the root menu * the ''Menu.InjectInput(..)'' commands emulate the button presses ''Fixture'' ''1'' ''THRO'' ''1'' ''0'' ''0'' ''0'' ''0'' ''0'' ''Enter'' This way the fixtures 1 ~ 100000 are selected. The following code is taken from [[macros:example:parkselectedfixtures|]] * The first line retrieves the current selection and stores it in a menu property, it is not important which one just that it is the correct type. * From that we then set the source handle selection (this is the same selection that is used for copy, move, set legend etc.). * The third line copies the source handle selection to the Repatch property (and initialises other properties used in the repatch menu). * The forth line performs the Park operation and * the last line clears the source handle selection once you are done. ===== How to use it ===== * [[:macros:deploying|make this macro available]] * When needed, select some fixtures and apply this macro in order to park these fixtures. ~~DISCUSSION~~