Copy link to clipboard
Copied
Hi,
For our product catalog we make linedrawings of all our products. For this we use our 3D designs and export a certain perspective into a drawing. This object we then need to fit it into a 50x50mm square artboard, put linewidth on 1pt and export it to bmp. The last two steps I'm able to complete with Actions in Illustrator.
For the first step I need to scale the object down to 50mm in width OR height, depending on the shape.
This is why I need the script that compares the object width to object length and depending on the outcome activate either a script that scales length to 50mm and the width proportionally or vice versa.
Is this possible? Does this post belong here?
I wrote a custom version for a customer, keeping items proportional, so I couldn't post it on my website. But that wouldn't work for you, unless you added artboards as image placeholders.
do you do one item at a time? do you select an item and run your actions?
here's a script you can incorporate into your Action set.
Select ONE object before running
// resize to 50 mm
// carlos canto
// https://community.adobe.com/t5/illustrator/illustrator-script-that-compares-object-width-to-length/t
...
Copy link to clipboard
Copied
The Links panel has fitting options when links are replaced. Maybe this will be an option?
Copy link to clipboard
Copied
Hi Tom,
Thanks for your reply. This would be very helpful but unfortunatly Illustrator doesn't see it as a link since I need to embed it to adjust the line width.
I found this script online that scales objects to the artboard. Unfortunatly the developer has never made a version that proportionally scales object.
I hope that someone can still help me with this.
Copy link to clipboard
Copied
If only we knew who that scripting developer was...!
Copy link to clipboard
Copied
...if we only knew.
Copy link to clipboard
Copied
I wrote a custom version for a customer, keeping items proportional, so I couldn't post it on my website. But that wouldn't work for you, unless you added artboards as image placeholders.
do you do one item at a time? do you select an item and run your actions?
here's a script you can incorporate into your Action set.
Select ONE object before running
// resize to 50 mm
// carlos canto
// https://community.adobe.com/t5/illustrator/illustrator-script-that-compares-object-width-to-length/td-p/10984755?page=1
var idoc = app.activeDocument;
var sel = idoc.selection[0];
var max = Math.max(sel.width, sel.height);
var targetSize = 50*72/25.4;
var percent = targetSize/max*100;
sel.resize(percent, percent);
Copy link to clipboard
Copied
Hi CarlosCanto,
Thank you so much! The script does exactly what I want it to do.
Might need to make a different topic for this but in Illustrator CC 2020 when I record my action and load the script the recording does not add this step to the action.
Any ideas on how to fix this?
EDIT: I found a way around it by using the "Insert Menu Item..." under the Actions tab.
Copy link to clipboard
Copied
that's correct, glad to hear you found "Insert Menu Item..."
Copy link to clipboard
Copied
Do you mind if i use this for CEP panel i helped a on. Ive helped mevCJ upgrade his logo exporter panel. I noticed when JPG is either to small or to big, the exporter will fail to export JPG files. I had done some testing and got some code working. But could not figure out how to use scale to do it proportional. This code works like a champ!
The initial panel he designed was great! Im a graphic designer myself and was missing some features which are workflow depended. I added some features so it gives cleaner exports.
Copy link to clipboard
Copied
Hi @schroef , sure no problem, ok to use.
Copy link to clipboard
Copied
Thanks! I've implemented a check and used the code. Works like a champ!