Copy link to clipboard
Copied
But, as I am a novice at best, I've been unable to get anything to work. I've done a couple hours of searching to no avail.
I need to be able to select the artwork on a given layer "Layer A", remove the stroke, and set the fill to an RGB color, then select "Layer B" and change the stroke to inside fill, then "Layer C" and change the dropshadow FX setting.
Any help with this is extremely appreciated!
Thanks guys!
Copy link to clipboard
Copied
Hi,
Your problem here is that nor the stroke alignment property nor the drop shadow settings seem accessible with scripting (unless I am wrong).
FWIW
Loic
Copy link to clipboard
Copied
It is possible to do singular live-effects using the live effect XML feature, which is completely undocumented except for some threads on this forum. For stroke alignment, you can create and play an Illustrator Action. Altogether, these details make such a script non-trivial as all would take a good dedicated hour to create and test.
Copy link to clipboard
Copied
Are you wanting to align the stroke to the inside of the objects on Layer B, or remove the stroke and apply a fill?
do you need to use a drop shadow? could you use a blend with transparency?
if you have a sample file of before, and one of after we could see how your document is constructed and exactly what you are trying to achieve.
Copy link to clipboard
Copied
Sorry, should have proofread that a little better last night!
Silly - I had a feeling hehee!
Qwerty - Yes, I meant change the stroke from outside to inside alignment. While I've been pressing to stop using raster FX, that's how the bosses want it.
I will get a couple files together that show the changes I'm trying to make, and the start of the totally broken script I've begun with as well hah. (Left on my work comp, so will post again in a couple hours from work! )
Thank you guys for the quick reply!
Copy link to clipboard
Copied
here is a working example of the XML filters thing Silly-V mentioned.
all you need do is wrap that in a for loop to cycle each item on layer 3.
i'll think on the inside/outside stroke
var doc = app.activeDocument;
var myPath = doc.selection[0];
var TOpt = 2.83466796875;
var myMode = 1; // 0 = Normal, 1 = Multiply, 2 = Screen ect...
var myOpacity = 0.75;
var myXoffset = 3 * TOpt;
var myYoffset = 3 * TOpt;
var myBlur = 1 * TOpt;
var myDarkness = 50;
xmlstring = '<LiveEffect index="0" major="1" minor="0" name="Adobe Drop Shadow"><Dict data="B usePSLBlur 1 R dark '+ myDarkness +' I csrc 1 I blnd '+ myMode +' R opac '+ myOpacity +' R horz '+ myXoffset +' R vert '+ myYoffset +' B pair 1 R blur '+ myBlur +' I Adobe Effect Expand Before Version 16 "><Entry name="sclr" valueType="F"><Fill color="1 0 0 0 1"/></Entry></Dict></LiveEffect>';
myPath.applyEffect(xmlstring);
Copy link to clipboard
Copied
Just cause I need the practice.
here is layers A&C dealt with.
is it important that the stroke be set in or out.
or is the importance on where it is.
we could offset a path to simulate an inside stroke.
ProcessLayers();
function ProcessLayers(){
var doc = app.activeDocument;
LayerA();
//LayerB(); // Skipping this due to not having worked out a clean way to deal with inside/outside strokes
LayerC();
function LayerA(){
var LayA;
var fillCol = new RGBColor();
fillCol.red = 166;
fillCol.green = 44;
fillCol.blue = 222;
try{
LayA = doc.layers.getByName("Layer A");
}catch(err){
alert("Layer A - Not Found");
return;
}
for(var i=0; i<LayA.pageItems.length; i++){
LayA.pageItems.stroked = false;
LayA.pageItems.filled = true;
LayA.pageItems.fillColor = fillCol;
}
}
function LayerC(){
var LayC;
var TOpt = 2.83466796875;
var myMode = 1; // 0 = Normal, 1 = Multiply, 2 = Screen ect...
var myOpacity = 0.75;
var myXoffset = 3 * TOpt;
var myYoffset = 3 * TOpt;
var myBlur = 1 * TOpt;
var myDarkness = 50;
var xmlstring = '<LiveEffect index="0" major="1" minor="0" name="Adobe Drop Shadow"><Dict data="B usePSLBlur 1 R dark '+ myDarkness +' I csrc 1 I blnd '+ myMode +' R opac '+ myOpacity +' R horz '+ myXoffset +' R vert '+ myYoffset +' B pair 1 R blur '+ myBlur +' I Adobe Effect Expand Before Version 16 "><Entry name="sclr" valueType="F"><Fill color="1 0 0 0 1"/></Entry></Dict></LiveEffect>';
try{
LayC = doc.layers.getByName("Layer C");
}catch(err){
alert("Layer C - Not Found");
return;
}
for(var i=0; i<LayC.pageItems.length; i++){
LayC.pageItems.applyEffect(xmlstring);
}
}
}
Copy link to clipboard
Copied
Qwerty, I happen to think you are a God(dess if applicable)!
There is an example of what I'm trying to convert, file has both the before and after in it. I trashed the script I started as frankly it was garbage that I'd be ashamed of anyone ever seeing!
Thank you guys again
Copy link to clipboard
Copied
So Layer A is the structure, this is where we remove stroke and add fill.
Layer B is windows, and due to the stroke being removed from the walls the windows jut out wider... GRRR.
(is leaving the stroke on the walls an option??? this would stop the windows and wall not aligning properly)
also be aware that even if we do sort out how to make stroke align to inside, this will not work for open paths, not an issue in this example but could be...
Layer C, dropshadow edit. in the file above this dropshadow is added to Layer A groups.
I will have a look now at modifying the dropshadow. i still think we will need to remove dropshadow and apply a new one
Copy link to clipboard
Copied
Unfortunately the stroke has to be removed, to make the walls the proper width. If we can't get the windows, it's not the worth thing in the world, I'll still have to touch them up even if we do figure it out, as when the inside stroke is applied, they are going to be slightly too short making a gap between the window and wall.
As for the drop shadow, as long as it looks about the same, I'm sure I can pass off any minor differences as and upgrade, as drop shadows are raster instead of vector. I had issues when I was trying to start the change over to a blend for the drop shadow, and then the boss told me to back burner that project, and that's where it has been since, so this may actually help me hit a 7th bird with the same stone!
Thanks again, truly amazing help Qwerty!
Copy link to clipboard
Copied
You may find that the XML way of doing the dropshadow is not for this project.
I'm unsure how to tell if the item has a shadow in the first place, and not sure how to remove it.
(prob can be done but I can't think of how)
I think graphic styles would be your friend here.
select layer A,
apply graphic style A
select layer B
apply graphic style B
ect...
Copy link to clipboard
Copied
I was worried that raster effect would wind up being a PITA, I've been pressing to move off of the raster effects, so I can just make a quick action that'll handle that part of it, as I think that's going to be what my boss wants anyways, so I might as well just do it right the first time around, as I never ever want to touch these files again once I've gotten them converted!
Copy link to clipboard
Copied
if you go the graphicstyle you can have the dropshadow effect in that. and it will be raster as "boss" wants.
even the inside stroke can be done by calling on a graphicstyle.
we just need to work out how to add the graphicstyles to each document.
as for windows being to short... grrrr we could increase the longest side of the window by a set amount. may not be perfect.
Copy link to clipboard
Copied
Doesn't need to be perfect in that regard - they can overlap the walls in that direction, I just figured it'd be too much of a pain to script that out, as there are both vertical and horizontal windows in most files (example file only had the horizontal one in it) on the same layer of course, but I didn't think about the idea of using the longest side! Fricking game changer right there - even if we don't use it here, can you shoot me that snippet, as I can think of a few places where that will come in very very handy!
Copy link to clipboard
Copied
Hmm if you are able to use this, you can set the default graphic style - which should in most cases be just black stroke/white fill and no other effects. As long as it's not tampered with, you can do this:
var item = doc.pathItems[0];
doc.graphicStyles.getByName("[Default]").applyTo(item);
item.applyEffect(xmlstring);