"it can be scripted"
Since I'm new to scripting for Illustrator I would be very happy for any guidance.
Hi here you go, this sample clips two objects. Let me know if you need to "draw" more than one inside.
Select two objects (the mask on top) before running the script.
#target Illustrator
// script.name = drawInsideViaClippingMask.jsx;
// script.description = makes a clipping mask, retaining fill/stroke, to simulate "draw inside";
// script.required = two paths selected, top most path is the clipping mask;
// script.parent = carlos canto // 8/16/11;
// script.elegant = false;
if (app.documents.length > 0)
{
var idoc = app.activeDocument; // get active document;
var sel = idoc.selection; // get selection
if (sel.length==2) // continue only if 2 objects are selected
{
var igroup = idoc.groupItems.add(); // add a group that will be the clipping mask group
var imask = sel[0]; // the mask is the object on top
var ipath = sel[1]; // the "drawn object" is at the bottom
var idup = imask.duplicate(); // duplicate the mask, to later get the fill and stroke to apply to the clipping path
ipath.move(igroup, ElementPlacement.PLACEATBEGINNING); // add both path to the group
imask.move (igroup, ElementPlacement.PLACEATBEGINNING);
imask.clipping = true; // make the mask the clipping path
igroup.clipped = true; // clip the everything in the group to the clipping mask
imask.fillColor = idup.fillColor; // add fill color, same as the dup
imask.stroked = true; // stroke the mask
imask.strokeWidth = idup.strokeWidth; // add stroke width, same as the dup
imask.strokeColor = idup.strokeColor; // add stroke color, seme as the dup
idup.remove(); // remove the duplicate
}
else // show this message if other than 2 objects are selected
{
alert("Select both, the Mask and the object that needs to be 'inside'.\rThe Mask needs to be the top most object.");
}
}
else
{
alert ("there are no open documents");
}