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

Open Source software contributions and discussions that supplement or extend the Palette / Light Palette software
Post Reply
User avatar
RobertBell
Posts: 2421
Joined: Fri Oct 12, 2007 1:11 pm
Primary Venue / Use: Other
Where I Am: Horizon Control Inc
Location: On the dark side just north of Toronto
Contact:

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

Post by RobertBell » Thu Jun 12, 2008 1:32 pm

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()
Robert Bell - Product Manager - Horizon Control Inc.

User avatar
gooze
Posts: 1760
Joined: Tue Dec 18, 2007 12:42 pm
Location: Amsterdam, The Netherlands
Contact:

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

Post by gooze » Mon Aug 03, 2009 10:11 am

This doesn't work with the current version of the software (10.6.2001)
Floriaan Ganzevoort - Lighting designer
THEATERMACHINE design. production. operations.

User avatar
RobertBell
Posts: 2421
Joined: Fri Oct 12, 2007 1:11 pm
Primary Venue / Use: Other
Where I Am: Horizon Control Inc
Location: On the dark side just north of Toronto
Contact:

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

Post by RobertBell » Tue Aug 04, 2009 4:45 pm

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
Robert Bell - Product Manager - Horizon Control Inc.

Post Reply