LXBeams Scripting Support


Introduction


The scripting support built into LXBeams allows you to access the same information that is displayed in the Inspector's Measurements and Info tabs. There are five commands that accomplish this:


getMeasurement key ___getMeasurement key "loc_x"
setMeasurement key ___ to ___   setMeasurement key "loc_x" to "10-6"
getInfo key ___getInfo key "color"
setInfo key ___ to ___setInfo key "color" to "R80"
showField key ___showField key "chan"

AppleScript is not designed to be fast. However, it allows the creation of customized commands through simple scripts. Quite powerful tasks can be accomplished simply by retrieving information from an object, making a decision, and setting another property based on the result. Some useful examples of how this works with LXBeams are included in this folder.


Accessing Objects in LXBeams


You can retrieve a documents positions and lights simply by referring to them:


set my_lights to the lights of the front document

set my_positions to the positions of the front document


As with creating reports in LXBeams, only objects in layers that are visible are returned.


You can also retrieve only some lights which contain specific text in one of their fields.  ( this is much faster than using a script to step through a list of lights and using getInfo).  To retrieve only certain lights takes two steps.  First you specify the key and what that field must contain.  Then, you retrieve the results much like getting all the lights:


tell the front document to setSomeLights key "color" contains "R80"

set my_lights to somelights of the front document


Accessing the Scriptable Properties of LXBeams Objects


Properties accessed by using keys to specify the field you are getting or setting:


Light Measurement Keys
"loc_x"X Location in document coordinates
"loc_y"Y Location in document coordinates
Position Measurement Keys
"start_x"X coordinate of the start point in document coordinates
"start_y"Y coordinate of the start point in document coordinates
"end_x"X coordinate of the end point in document coordinates
"end_y"Y coordinate of the end point in document coordinates
"len"Length of the line
"dir"Direction in degrees from start to end
Light Info Keys
"hang"Position
"num"Unit Number
"color"Color
"chan"Channel
"cir"Circuit
"dim"Address or Dimmer
"gobo"Template
"use"Use<
"grp"Group
"mk"Mark
"note"Note
"foc_x"X coordinate of focus location, in document coordinates
"foc_y"Y coordinate of focus location, in document coordinates
"foc_z"Z (height) coordinate of focus, in document coordinates
"maploc_x"X location as mapped by the light's position
"maploc_y"Y location as mapped by the light's position
"maploc_z"Z (height) location as mapped by the light's position

Some light properties can be accessed directly as indicated in LXBeams's AppleScript dictionary.  The values returned by this method for the channel, dimmer and circuit are all numeric rather than text:


set my_channel to the channel of my_light --returns a number

set my_channel to my_light getInfo key "chan" --returns a string


Position Info Keys
"pname"Name
"ht"Height
"n_o""Numbering Options
"l_o"Layout Option
"space"Spacing
"pnote"Note
"map_st_x"Map Start X
"map_st_y"Map Start Y
"map_st_z"Map Start Z (height)
"map_ed_x"Map End X
"map_ed_y"Map End Y
"map_ed_z"Map End Z (height)