Mobile app version of vmapp.org
Login or Join
Caterina889

: Die Lines Drawing of boxes Adobe illustrator cc script http://swsharings.blogspot.com.tr how do I do this for the described here FEFCO 0201 code box ? I tried so hard but I couldn't The .jsx

@Caterina889

Posted in: #AdobeIllustrator #Script

swsharings.blogspot.com.tr how do I do this for the described here FEFCO 0201 code box ?

I tried so hard but I couldn't

The .jsx script can be downloaded at the following link instances.

In addition these examples might need people. Are Sorry for my English.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Caterina889

1 Comments

Sorted by latest first Latest Oldest Best

 

@Vandalay110

try this (yeah i should refactor it but i cant be bothered, did it for fun):
#target illustrator

// Copyright joojaa 2016
// License: Buy somebody you do not know
// a beer or other similar culturally
// appropriate refreshment.

(function(){
var win = new Window('dialog');
var height = txtgroup(win, 'Height', '30 mm');
var width = txtgroup(win, 'Width', '10 mm');
var length = txtgroup(win, 'Length', '40 mm');

var grp = win.add('group');
var ok = grp.add('button {text: "OK"}');
grp.add('button {text: "Cancel"}');

var doDraw = function(){
draw();
win.close(0);
}
ok.onClick = doDraw;

win.show();

function txtgroup(win, name ,txt) {
var grp = win.add('group');
grp.add('statictext {text: "'+name+': "}');
var item = grp.add('edittext {characters: 12, active: true}');
item.text = txt;
return item;
}

// almost from scriptUI for dummies
function convert_units(n, to) {
var unitConversions = {
'pt': 1.0000000000,
'p': 12.0000000000,
'mm': 2.8346456692,
'in': 72.00000000,
'ag': 5.1428571428,
'cm': 28.3464566929,
'c': 12.7878751998,
'tr': 3.0112500000
}
var obj = fix_measurement(n);
var temp = (obj.amount * unitConversions[obj.unit]) / unitConversions[to];
return temp
}

// almost from scriptUI for dummies
function fix_measurement(n) {
n = n.replace(/ /g, ' '); // Delete all spaces
n = n.replace(/^([pc])/, '0'); // Change p3 to 0p3
// Infixed 'p' and 'c' to decimal suffixes: 3p6 > 3.5 p
n = n.replace(/(d+)([pc])([.d]+)$/, function() {
return Number(arguments[1]) + Number(arguments[3] / 12) + arguments[2]
});
// Split on unit
var temp = n.split(/(ag|cm|mm|c|pt|p|in)$/);
return {
amount: Number(temp[0]),
unit: temp.length === 1 ? doc_units() : temp[1]
};
}








function draw(){

var myDoc = app.activeDocument;
grp = myDoc.groupItems.add();
grp.name = 'dieline';
function line(){

var l = grp.pathItems.add();
l.stroked = true;
l.filled = false;
return l;
}

var w = convert_units(width.text, 'pt');
var l = convert_units(length.text, 'pt');
var h = convert_units(height.text, 'pt');

var mm =2.8346456692
var o = [10*mm, -10*mm];
var p = o;

//flap

line().setEntirePath([
p=[ p[0], p[1] -(w/2 + 3*mm) ],
p=[p[0] - (w/8 + 4*mm), p[1] - (w/16 + 2*mm)],
p=[p[0], p[1] - (h + 6*mm) + 2*(w/16 +2*mm)],
[o[0], p[1] - (w/16 +2*mm)]
]
);

// horizontal lines
var p = o;
line().setEntirePath([ p, p=[ p[0], p[1] -(w/2 + 3*mm) ]]);
line().setEntirePath([ p, p=[ p[0], p[1] -(h + 6*mm) ]]);
line().setEntirePath([ p, p=[ p[0], p[1] -(w/2 + 3*mm) ]]);

var p=[o[0] + (w + 4*mm), o[1]];
line().setEntirePath([ p, p=[ p[0], p[1] -(w/2 + 3*mm) ]]);
line().setEntirePath([ p, p=[ p[0], p[1] -(h + 6*mm) ]]);
line().setEntirePath([ p, p=[ p[0], p[1] -(w/2 + 3*mm) ]]);

var p=[p[0] + (l + 5*mm), o[1]];
line().setEntirePath([ p, p=[ p[0], p[1] -(w/2 + 3*mm) ]]);
line().setEntirePath([ p, p=[ p[0], p[1] -(h + 6*mm) ]]);
line().setEntirePath([ p, p=[ p[0], p[1] -(w/2 + 3*mm) ]]);

var p=[p[0] + (w + 4*mm), o[1]];
line().setEntirePath([ p, p=[ p[0], p[1] -(w/2 + 3*mm) ]]);
line().setEntirePath([ p, p=[ p[0], p[1] -(h + 6*mm) ]]);
line().setEntirePath([ p, p=[ p[0], p[1] -(w/2 + 3*mm) ]]);

var p=[p[0] + (l + 5*mm), o[1]];
line().setEntirePath([ p, p=[ p[0], p[1] -(w/2 + 3*mm) ]]);
line().setEntirePath([ p, p=[ p[0], p[1] -(h + 6*mm) ]]);
line().setEntirePath([ p, p=[ p[0], p[1] -(w/2 + 3*mm) ]]);

// then vertical
var p = o;
line().setEntirePath([ p, p=[ p[0] + (w + 4*mm), p[1] ]]);
line().setEntirePath([ p, p=[ p[0] + (l + 5*mm), p[1] ]]);
line().setEntirePath([ p, p=[ p[0] + (w + 4*mm), p[1] ]]);
line().setEntirePath([ p, p=[ p[0] + (l + 5*mm), p[1] ]]);

var p=[o[0], p[1] -(w/2 + 3*mm)];
line().setEntirePath([ p, p=[ p[0] + (w + 4*mm), p[1] ]]);
line().setEntirePath([ p, p=[ p[0] + (l + 5*mm), p[1] ]]);
line().setEntirePath([ p, p=[ p[0] + (w + 4*mm), p[1] ]]);
line().setEntirePath([ p, p=[ p[0] + (l + 5*mm), p[1] ]]);

var p=[o[0], p[1] -(h + 6*mm)];
line().setEntirePath([ p, p=[ p[0] + (w + 4*mm), p[1] ]]);
line().setEntirePath([ p, p=[ p[0] + (l + 5*mm), p[1] ]]);
line().setEntirePath([ p, p=[ p[0] + (w + 4*mm), p[1] ]]);
line().setEntirePath([ p, p=[ p[0] + (l + 5*mm), p[1] ]]);

var p=[o[0], p[1] -(w/2 + 3*mm)];
line().setEntirePath([ p, p=[ p[0] + (w + 4*mm), p[1] ]]);
line().setEntirePath([ p, p=[ p[0] + (l + 5*mm), p[1] ]]);
line().setEntirePath([ p, p=[ p[0] + (w + 4*mm), p[1] ]]);
line().setEntirePath([ p, p=[ p[0] + (l + 5*mm), p[1] ]]);

return grp;
}

})();

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme