Copy link to clipboard
Copied
Hi,
I am using Indesign CS6 (Windows Version) and looking for a script to add small circles on a curve with several nodes on it starting from node 1 as shown in the below picture.
The curve is single continuous line .... is there any that this can be possible...
Hi henum,
Try something like this:
...// 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 instanceo
Copy link to clipboard
Copied
Hi henum,
Try something like this:
// 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);
@+
Marc
Copy link to clipboard
Copied
Hi Marc
This really works... thank you very much...
I have one more point... though the script gives the desired result but is this possible to have the circles created on a new layer....
thanx again....
Rakesh
Copy link to clipboard
Copied
Hi Marc
Also, is there a way to set the size of the dots as the dots created using the scripts are about 2 mm each. The change in const RADIUS = '1mm'; seems does not working....
Is there any solution to this?
Thanx
Rakesh
Copy link to clipboard
Copied
Hi Rakesh,
I tested Marc's script and cannot see that it is not working as intended.
( A radius of 1 mm will result in a circle of 2 mm diameter. So nothing unusual. )
I also tested with a radius of "0.5mm". No problem.
The result is a circle of 1 mm in diameter.
For the layers:
Just add appropriate code in the section that begins with //Check of Marc's code that would
1. check if a certain layer exists by a name and
2. if not, adds a new layer with the name
Then add:
itemLayer : "name of layer",
right after line 5 of Marc's code.
There are plenty of code examples here in the forum that check, if a layer of a specified name is there and add a layer to the active InDesign document, if the layer is not found.
Regards,
Uwe
Copy link to clipboard
Copied
Opps.... sorry
I just missed out the word radius and only focused on the output result which was 2 mm....
Your tip on layers also works.....
Thank you very much Laubender for correcting me...
Thanks Marc for all your support...
Rakesh
Copy link to clipboard
Copied
Nice one Marc,
A less verbose version of line 42 could be.
while (t = a.pop()) o.duplicate(u, t[2] ? t[1] : t);
Trevor
Copy link to clipboard
Copied
hi all ,
many thanks for Marc Laubender Trevor, i learned a lot from their participation in this forum.
it is nice and interesting discussion,
i would like to study this script,
first i look all over to see the assignment statement for the variables a,u
i could not find may any one help me
Copy link to clipboard
Copied
Hi Saeedfs
I should leave this one to Marc but I shall put it this way
function addMostPeople(a,b){
var c;
if ((a === undefined) || (b === undefined)){
throw 'Please supply 2 arguments';
}
c = a + b;
return c;
}
function addMarc(a /*Num*/,b /*Num*/, u, c){
if ((a === u) || (b === u)){
throw 'Please supply 2 arguments';
}
c = a + b;
return c;
}
The 2 examples aren't really how these functions would be implemented either by Marc or others but they give over the idea.
u and c in "Marc's" function are placed in the argument list to declare them as variables.
As u is not assigned a value it is undefined.
He has a post on this in his blog Indiscripts :: Why I Do Not Use Meaningful Variable Names (Anymore)
I think also part of his motives are a backup in case the jsxBlind fails 😉
HTH
Trevor
Copy link to clipboard
Copied
As for 'a' in Marc's original script that gets assigned at the last line of the script.
})(app.properties.selection);
Take this example
(function iCallMySelf(a){alert(a);})('bar');
Note the whole function is wrapped in brackets and then the function is called with the arguments provided in the brackets at the end.
This is the equivalent of
var foo = function iDoNotCallMySelf(a){alert(a);}
foo('bar');
Copy link to clipboard
Copied
Thank you Trevor for your quick responses.
i will study this