Page 1 of 1

(LUA) Round values in grid to multiples of 10%

Posted: Thu Jun 12, 2008 1:32 pm
by RobertBell
This is a funny sort of macro for me to write because I'm of the feeling that if you set a light to 52% there may have been good reason to do so. Equally, I'll laugh at anybody if they spend 10 minutes arguing that 53% looks better. On the other hand, a lot of people like to see things as 10,20,30 etc. just so it's neat and tidy.

This macro script should be run after you've selected a range of fixtures. It will round the intensities up or down such that each level ends in a zero digit.

Code: Select all

s = HC.GetCurrentSelectionSet(',')
for fixture in string.gmatch(s,"%d+") do
  x = HC.AttributeGetValue(fixture)
   if  math.fmod(x,10) >= 5 then
   HC.SetLevel(fixture, math.floor(25.5*math.ceil(x/10)))
  else
    HC.SetLevel(fixture, math.floor(25.5*math.floor(x/10)))
  end
end
You will need to be running 10.3.15 or greater to use HC.GetCurrentSelectionSet()

Re: (LUA) Round values in grid to multiples of 10%

Posted: Mon Aug 03, 2009 10:11 am
by gooze
This doesn't work with the current version of the software (10.6.2001)

Re: (LUA) Round values in grid to multiples of 10%

Posted: Tue Aug 04, 2009 4:45 pm
by RobertBell
Nothing to do with the version you are running. Last time you tried it you used conventional lights. This time you're using movers.

try this:

Code: Select all

    s = HC.GetCurrentSelectionSet(',')
    for fixture in string.gmatch(s,"%d+") do
     x = HC.AttributeGetValue(fixture,'intensity','+V') -- more specific now
       if  math.fmod(x,10) >= 5 then
       HC.SetLevel(fixture, math.floor(25.5*math.ceil(x/10)))
      else
        HC.SetLevel(fixture, math.floor(25.5*math.floor(x/10)))
      end
    end