Illustrator ExtendScript set FILL selection opacity

Is there a way to access the transparency of the pathItem using javascript? I can access the overall opacity, but I want to reduce the opacity of the fill while keeping the stroke completely opaque.

I cannot find anything in the documentation and I cannot find anyone else asking this question.

I can set the overall opacity like this:

var selection = app.activeDocument.selection;
selection[0].opacity = 50;

      

I've tried every " fillOpacity

" option I can think of, for example:

var selection = app.activeDocument.selection;
selection[0].fillOpacity = 50;
selection[0].FillOpacity = 50;
selection[0].fill.opacity = 50;

      

... but it doesn't work.

Am I going to get it wrong, or is it just not possible?

+3


source to share


2 answers


You cannot access it as you cannot normally access it even in illustrator. This is just a Photoshop property. I also checked the documentation to be sure. What you could do is this, although this would do the same:



doc = app.activeDocument;
i = 0
var selection = doc.selection[i];
var storedColor = doc.selection[i].fillColor;

//new object with only fill, we send it to back so it doesn't overlap stroke, if there is one
var newObject = app.selection[i].duplicate(doc, ElementPlacement.PLACEATEND);
//turn off fill for first object
doc.selection[i].filled = false;
i = i + 1;
newObject.stroked = false;
//apply stored color from earlier to new shape
newObject.fillColor = storedColor;
newObject.opacity = 50;
newObject.name = "50p fill";

      

+4


source


What I did to solve the problem was to apply tint to objects where I am using the tint property



var docRef = app.activeDocument;
var selectedObjects = docRef.selection;
var theTint;
var fillwithSwatch = function (pathItems, sname ){

for (var i=0;i< pathItems.length; i++){
pathItems[i].fill = true;
theTint = pathItems[i].fillColor.gray;
pathItems[i].fillColor = docRef.swatches.getByName ( sname ).color ;
pathItems[i].fillColor.tint = theTint; 
}
}
theTint = fillTint(selectedObjects);
// the spotcolor should be in the swatchpallet already
fillwithSwatch (selectedObjects, "myBlue" ); 

      

+2


source







All Articles