// YOUR SETTINGS
// ====================================
const RADIUS = '1mm';
const CIRCLE_PROPS = {
fillColor: 'Black',
strokeColor: 'None',
// Etc... but don't change the line below.
geometricBounds: ['-'+RADIUS,'-'+RADIUS,'+'+RADIUS,'+'+RADIUS],
};
const parentSpread = function F(/*DOM*/o, p)
//--------------------------------------
// Get the parent spread of this DOM object, or NULL.
{
p = o && o.parent;
if( (!p) || (p instanceof Document) ) return null;
return ( (p instanceof Spread) || (p instanceof MasterSpread) ) ? p : F(p);
};
(function(/*?DOM[]*/a, o,t,u)
//--------------------------------------
// Place circles on the selected curve.
{
// Check.
// ---
if( !a || 1 != a.length ) { alert( "Please select one object!" ); return; }
if( !('paths' in (a=a[0])) ){ alert( "Please select a spline item!" ); return; }
if( !(o=parentSpread(a)) ){ alert( "No parent spread found!" ); return; }
// Create the template circle at [0,0] (ruler space.)
// ---
o = o.ovals.add(CIRCLE_PROPS);
// Flat array of all pathpoints coordinates.
// a :: [x,y] | [[lx,ly],[x,y],[rx,ry]]
// ---
a = [].concat.apply([],a.paths.everyItem().entirePath);
// Duplicate the template at each point.
// ---
for( ; t=a.pop() ; o.duplicate(u,'number'== typeof t[0] ? t : t[1]) );
// Remove the template.
// ---
o.remove();
})(app.properties.selection);