Example
This Lava script performs a colour edit in the same style as the Design > Attribute Edit > Graphics option in Vulcan. The colour from the first selected object is used as the default for the panel that prompts for the colour. This colour is then applied to the remaining objects in the selection. >
use Lava; my $colour = 3; # The object $s contains a reference to the current selection for ( my $s = new Lava::Selection( "to recolour", "multi" ); $s->has_more(); $s->next() ) { # Use the colour from the first object as the default # When no argument is passed to the colour method, its current value is returned. $colour = $s->colour(); # Create panel my $panel = new Lava::Panel; $panel->colour( "Please enter New colour ", \$colour ); # The "|| last" (pronounced "or last") construct is typical of the # shorthand notation available in Perl, and useful for the execute # method: If the execute method returns true (that is, the user clicks OK ) then # the second command ("last") is not required or performed - if # the user clicks Cancel, then the evaluation of the or statement moves to the # "last" command and the "for(...)" loop terminates. $panel->execute('Select colour') || last; # By passing an argument to the colour method, the object's colour is set. $s->colour($colour); # This replaces the object in the database. Since the coordinates/text # data were never accessed, only the header is updated. $s->replace(); }
Related topics