// An Illustrator CS6 JavaScript
( function main() {
if ( !app.selection || app.selection.length !== 1 ) return;
var doc = app.activeDocument;
var item = doc.selection[ 0 ];
var name = inject_dummy_roughen_style({
size : 25,
detail : 25,
is_smooth : 0,
is_absolute : 0,
});
doc.activate();
app.paste();
app.cut();
item.selected = true;
var style = doc.graphicStyles.getByName( name );
style.mergeTo( item );
style.remove();
return;
function inject_dummy_roughen_style( options_obj ) {
if ( typeof( options_obj ) !== 'object' ) options_obj = {};
if ( !options_obj.size ) options_obj.size = 5;
if ( !options_obj.detail ) options_obj.detail = 10;
if ( !options_obj.is_abs ) options_obj.is_abs = 0;
if ( !options_obj.is_smooth ) options_obj.is_smooth = 0;
var name = '~/' + ( new Date()).getTime();
var str = '%!PS-Adobe-3.0\
%%Creator: Adobe Illustrator(R) 16.0\
%%BoundingBox: 0 0 0 0\
%%EndComments\
%%BeginProlog\
%%EndProlog\
%%BeginSetup\
%AI9_BeginArtStyles\
/KnownStyle :\
('+ name + ') /Name ,\
/ActiveStyle :\
/CompoundFilter :\
(Chain Style Filter) 0 0 /Filter ,\
1 /Visible ,\
/BasicFilter :\
(Adobe Roughen) 1 0 /Filter ,\
1 /Visible ,\
(Roughen.aip) /PluginFileName ,\
(Roughen) /Title ,\
/Dictionary : /NotRecorded ,\
' + options_obj.is_smooth + ' /Real (roundness) ,\
' + options_obj.size + ' /Real (size) ,\
' + options_obj.detail + ' /Real (dtal) ,\
5 /Real (asiz) ,\
' + options_obj.is_absolute + ' /Real (absoluteness) ,\
; /Dict ;\
/Part ,\
/CompoundFilter :\
(Stack Style Filter) 0 0 /Filter ,\
1 /Visible ,\
/BasicFilter :\
(Stroke Style Filter) 0 0 /Filter ,\
1 /Visible ,\
2 /FillOrStroke ,\
/Dictionary : /NotRecorded ,\
/StrokeStyle : 0 1 0 0 0 Xy\
0 J 0 j 1 w 10 M []0 d 0 XR\
0 0 Xd\
/Def ; \
(StrokeStyle) ,\
; /Dict ;\
/Part ,\
/BasicFilter :\
(Conduit Filter) 0 0 /Filter ,\
1 /Visible ,\
;\
/Part ,\
/BasicFilter :\
(Fill Style Filter) 0 0 /Filter ,\
1 /Visible ,\
/Dictionary : /NotRecorded ,\
0 /Bool (UseEvenOdd) ,\
/FillStyle : 0 1 0 0 0 Xy\
0 J 0 j 1 w 10 M []0 d 0 XR\
0 0 Xd\
/Def ; \
(FillStyle) ,\
; /Dict ;\
/Part ,\
;\
/Part ,\
/BasicFilter :\
(Blend Style Filter) 0 0 /Filter ,\
1 /Visible ,\
/Dictionary : /NotRecorded ,\
/BlendStyle : 0 1 0 0 0 Xy\
0 J 0 j 1 w 10 M []0 d 0 XR\
/Def ;\
(BlendStyle) ,\
; /Dict ;\
/Part ,\
;\
\
/Execution ;\
/Def ;\
%AI9_EndArtStyles\
%AI9_BeginArtStyleList\
(' + name + ')\
%AI9_EndArtStyleList\
%%EndSetup\
%%Trailer\
%%EOF\n';
var f = new File( name );
f.open( 'w' );
f.write( str );
f.close();
var tmp = app.open( f );
var style = tmp.graphicStyles.getByName( name );
var rect = tmp.pathItems.rectangle( 0, 0, 1, 1 );
style.applyTo( rect );
rect.selected = true;
app.cut();
tmp.close( SaveOptions.DONOTSAVECHANGES );
f.remove();
return name;
}
})();