Hello,
once again I ask for your help.
I am trying to retrieve the list of all the identifiers of the fixtures that the user has selected in order to then apply different operations to their attributes (change color, position, ...) via lua plugin but I'm not sure I'm doing it right. Currently, for my tests, I have two fixture types:
- Magic Panel (with sub-fixture) [FID 901 Thru 912]
- MacQuantum [FID 101 Thru 110]
The code I'm currently using is:
Cmd('Next')
local selection = {}
local indexes = {}
local done = false
while true do
local first = SelectionFirst()
local currentFixtureIndex = SelectionFirst()
for _, v in ipairs(indexes) do
if (v == first) then
done = true
end
end
if done then
break
end
local subFixtures = {}
repeat
local subFixture = GetSubfixture(currentFixtureIndex);
if subFixture:GetClass() == 'Fixture' then
table.insert(subFixtures, subFixture.index)
end
currentFixtureIndex = SelectionNext(currentFixtureIndex)
until not currentFixtureIndex
table.insert(selection, subFixtures)
table.insert(indexes, first)
Cmd('Next')
end
Cmd("ClearSelection")
-- pseudo code to illustrate my goal
for _, fixtureId in ipairs(selection) do
Cmd(string.format("Fixture %d", fixtureId))
Cmd("Attribute \"Tilt\" At Absolute +45")
Cmd("ClearSelection")
end
Display More
You will notice that I use :GetClass() at Line 24 to exclude sub fixtures from magic panels. However, I'm not sure I'm doing it right.
Let me explain :
If I then want to loop over the fixtureIds and do not filter via :GetClass(), I end up with AND the fixtures' ids (101, 102, ...) AND the sub-fixtures's ids.
However, for example, if I want to do MATricks afterwards, my selection could be distorted because I only want the Fixtures and not the sub fixtures (example: in the case where I want to do some positions).
Do you have a solution ? It depends on what I want to do?
My original idea was to go through the whole selection to find out which fixture or sub-fixture had the attributes I wanted via the GetAttributeIndex and GetUIChannelIndex ("Pan" & "Tilt" for this case).
This is the way to achieve it ?
I also tried using the pseudo code from the documentation:
local subfixtureIndex = SelectionFirst(true);
repeat
Printf("subfixture selected with index: "..subfixtureIndex)
subfixtureIndex = SelectionNext(subfixtureIndex)
until not subfixtureIndex;
but I don't understand what these indexes correspond to. Is there anything that converts them to FID?