This example loops through the selected shapes in a shape layer, and turns on the shadows. If there are no selected shapes, then it loops through all the shapes in the layer.
Note: This plugin requires Acorn 1.0.3
@implementation TurnOnShadows
+ (id) plugin {
return [[[self alloc] init] autorelease];
}
- (void) willRegister:(id<ACPluginManager>)pluginManager {
[pluginManager addFilterMenuTitle:@"Turn on shadows"
withSuperMenuTitle:@"Shape"
target:self
action:@selector(turnOnShadows:userObject:)
keyEquivalent:@""
keyEquivalentModifierMask:0
userObject:nil];
}
- (void) didRegister {
}
- (void) turnOnShadows:(id<ACShapeLayer>)layer userObject:(id)uo {
if ([layer layerType] != ACShapeLayer) {
return;
}
NSArray *graphics = [layer selectedGraphics];
if (![graphics count]) {
graphics = [layer graphics];
}
[graphics makeObjectsPerformSelector:@selector(setHasShadow:) withObject:[NSNumber numberWithBool:YES]];
}
- (NSNumber*) worksOnShapeLayers:(id)userObject {
return [NSNumber numberWithBool:YES];
}
@end
And the same plugin in Python:
import objc
from Foundation import *
from AppKit import *
ACScriptSuperMenuTitle = None
ACScriptMenuTitle = "Shape Layer test"
ACShortcutKey = 'k'
ACShortcutMask = "shift command"
ACBitmapLayer = 1
ACShapeLayer = 2
# this only works in Acorn 1.0.3+
def layerAction(currentLayer):
if currentLayer.layerType() != 2:
return
graphics = currentLayer.selectedGraphics()
if len(graphics) == 0:
graphics = currentLayer.graphics()
for graphic in graphics:
graphic.setHasShadow_(True)
Back to
AcornPlugins