var five = $.getenv("bz_five") + "" !== 'null' ? ($.getenv("bz_five") === 'false' ? false : true) : true
var count = $.getenv("bz_count") ? $.getenv("bz_count") : 1
function main(_flagMargin, _flagFontSize, _arrowSize, _arrowWidth, isTop, isBottom, isLeft, isRight) {
var doc = app.activeDocument; // 当前文档
var theSelect = doc.selection; // 选中的内容
var _datumPointUnit = 2.834645 // 基准单位
var flagMargin = _flagMargin * _datumPointUnit;// 标尺距离物体边沿宽度
var flagFontSize = _flagFontSize * _datumPointUnit; // 标尺字体大小
var arrowSize = _arrowSize * _datumPointUnit // 箭头尺寸
doc.selection = null; // 取消选择所有内容
var newSpot
var newColor
try {
newSpot = app.activeDocument.spots.getByName("Dimension Line")
} catch (error) {
// 创建专色
newSpot = app.activeDocument.spots.add();
newColor = new CMYKColor();
newColor.cyan = 100;
newColor.magenta = 0;
newColor.yellow = 0;
newColor.black = 0;
newSpot.name = "Dimension Line";
newSpot.colorType = ColorModel.SPOT;
newSpot.color = newColor;
}
function createColor() {
var newSpotColor = new SpotColor();
newSpotColor.spot = newSpot;
return newSpotColor
}
doc.defaultFilled = false; // 默认填充: 无
doc.defaultStroked = true; // 默认描边: 打开
doc.defaultStrokeWidth = _arrowWidth * _datumPointUnit; // 描边0.3
doc.defaultStrokeColor = createColor();
for (var index = 0; index < theSelect.length; index++) {
var _this = theSelect[index];
// -------获取元素信息
var strokeWidth = 0 // 元素描边
if (_this == '[PathItem ]' && _this.stroked) {
strokeWidth = _this.strokeWidth
}
var left = _this.left; // 元素距离左边的距离
var top = _this.top; // 元素距离顶部边的距离
var width = _this.width + strokeWidth; // 元素宽度
var height = _this.height + strokeWidth; // 元素高度
// -------获取元素信息
var flagGroup = doc.groupItems.add();// 创建一个标尺组
if (isLeft) {
// --------------------左 - 画高度标尺--------------------
// 画线条
var line1 = flagGroup.pathItems.add();
line1.strokeOverprint = true
line1.setEntirePath([
[left - flagMargin, top],
[left - flagMargin, top - height]
]);
line1 = flagGroup.pathItems.add();
line1.strokeOverprint = true
line1.setEntirePath(
[
[left - flagMargin - flagMargin / 2, top],
[left - flagMargin + flagMargin / 2, top]
]
);
line1 = flagGroup.pathItems.add();
line1.strokeOverprint = true
line1.setEntirePath(
[
[left - flagMargin - flagMargin / 2, top - height],
[left - flagMargin + flagMargin / 2, top - height]
]
);
// 画线条
// 画箭头
var arrow1 = flagGroup.pathItems.add(); //画箭头上
arrow1.stroked = false;
arrow1.fillColor = createColor();
arrow1.fillOverprint = true
arrow1.setEntirePath([
[left - flagMargin, top],
[left - flagMargin - arrowSize / 2, top - arrowSize],
[left - flagMargin + arrowSize / 2, top - arrowSize]]
);
arrow1.closed = true
arrow1 = flagGroup.pathItems.add(); //画箭头下
arrow1.stroked = false;
arrow1.fillColor = createColor();
arrow1.fillOverprint = true
arrow1.setEntirePath([
[left - flagMargin, top - height],
[left - flagMargin - arrowSize / 2, top - height + arrowSize],
[left - flagMargin + arrowSize / 2, top - height + arrowSize]]
);
arrow1.closed = true
// 画箭头
// 尺寸文字
var text1 = flagGroup.textFrames.add()
text1.contents = mathNum(height / _datumPointUnit, five, count) + " mm"
text1.textRange.characterAttributes.size = flagFontSize;
for (var i = 0; i < app.textFonts.length; i++) {
var e = app.textFonts[i];
if (e.family === "Adobe 宋体 Std L") {
text1.textRange.characterAttributes.textFont = app.textFonts[i]
}
}
text1.textRange.fillColor = createColor();
text1.textRange.characterAttributes.overprintFill = true
text1.left = left - flagMargin - text1.width - flagMargin / 2;
text1.top = top - height / 2 + text1.height / 2;
// ---------------------左 - 画高度标尺--------------------
}
if (isRight) {
// --------------------右 - 画高度标尺--------------------
// 画线条
var line1 = flagGroup.pathItems.add();
line1.strokeOverprint = true
line1.setEntirePath([
[left + width + flagMargin, top],
[left + width + flagMargin, top - height]
]);
line1 = flagGroup.pathItems.add();
line1.strokeOverprint = true
line1.setEntirePath(
[
[left + width + flagMargin - flagMargin / 2, top],
[left + width + flagMargin + flagMargin / 2, top]
]
);
line1 = flagGroup.pathItems.add();
line1.strokeOverprint = true
line1.setEntirePath(
[
[left + width + flagMargin - flagMargin / 2, top - height],
[left + width + flagMargin + flagMargin / 2, top - height]
]
);
// 画线条
// 画箭头
var arrow1 = flagGroup.pathItems.add(); //画箭头上
arrow1.stroked = false;
arrow1.fillColor = createColor();
arrow1.fillOverprint = true
arrow1.setEntirePath([
[left + width + flagMargin, top],
[left + width + flagMargin - arrowSize / 2, top - arrowSize],
[left + width + flagMargin + arrowSize / 2, top - arrowSize]]
);
arrow1.closed = true
arrow1 = flagGroup.pathItems.add(); //画箭头下
arrow1.stroked = false;
arrow1.fillColor = createColor();
arrow1.fillOverprint = true
arrow1.setEntirePath([
[left + width + flagMargin, top - height],
[left + width + flagMargin - arrowSize / 2, top - height + arrowSize],
[left + width + flagMargin + arrowSize / 2, top - height + arrowSize]]
);
arrow1.closed = true
// 画箭头
// 尺寸文字
var text1 = flagGroup.textFrames.add()
text1.contents = mathNum(height / _datumPointUnit, five, count) + " mm"
text1.textRange.characterAttributes.size = flagFontSize;
for (var i = 0; i < app.textFonts.length; i++) {
var e = app.textFonts[i];
if (e.family === "Adobe 宋体 Std L") {
text1.textRange.characterAttributes.textFont = app.textFonts[i]
}
}
text1.textRange.fillColor = createColor();
text1.textRange.characterAttributes.overprintFill = true
text1.left = left + width + flagMargin + flagMargin / 2;
text1.top = top - height / 2 + text1.height / 2;
// ---------------------左 - 画高度标尺--------------------
}
if (isBottom) {
// ---------------------下 - 画宽度标尺--------------------
// 画线条
var line1 = flagGroup.pathItems.add();
line1.strokeOverprint = true
line1.setEntirePath([
[left, top - height - flagMargin],
[left + width, top - height - flagMargin]
]);
line1 = flagGroup.pathItems.add();
line1.strokeOverprint = true
line1.setEntirePath(
[
[left, top - height - flagMargin / 2],
[left, top - height - flagMargin - flagMargin / 2]
]
);
line1 = flagGroup.pathItems.add();
line1.strokeOverprint = true
line1.setEntirePath(
[
[left + width, top - height - flagMargin / 2],
[left + width, top - height - flagMargin - flagMargin / 2]
]
);
// 画线条
// 画箭头
var arrow1 = flagGroup.pathItems.add(); //画箭头左
arrow1.stroked = false;
arrow1.fillColor = createColor();
arrow1.fillOverprint = true
arrow1.setEntirePath([
[left, top - height - flagMargin],
[left + arrowSize, top - height - flagMargin + arrowSize / 2],
[left + arrowSize, top - height - flagMargin - arrowSize / 2]]
);
arrow1.closed = true
var arrow1 = flagGroup.pathItems.add(); //画箭头右
arrow1.stroked = false;
arrow1.fillColor = createColor();
arrow1.fillOverprint = true
arrow1.setEntirePath([
[left + width, top - height - flagMargin],
[left + width - arrowSize, top - height - flagMargin + arrowSize / 2],
[left + width - arrowSize, top - height - flagMargin - arrowSize / 2]]
);
arrow1.closed = true
// 画箭头
// 尺寸文字
var text1 = flagGroup.textFrames.add()
text1.contents = mathNum(width / _datumPointUnit, five, count) + " mm"
text1.textRange.characterAttributes.size = flagFontSize;
text1.textRange.fillColor = createColor();
text1.textRange.characterAttributes.overprintFill = true
text1.left = left + width / 2 - text1.width / 2;
text1.top = top - height - flagMargin - text1.height / 2;
for (var i = 0; i < app.textFonts.length; i++) {
var e = app.textFonts[i];
if (e.family === "Adobe 宋体 Std L") {
text1.textRange.characterAttributes.textFont = app.textFonts[i]
}
}
// ---------------------下 - 画宽度标尺--------------------
}
if (isTop) {
// ---------------------上 - 画宽度标尺--------------------
// 画线条
var line1 = flagGroup.pathItems.add();
line1.strokeOverprint = true
line1.setEntirePath([
[left, top + flagMargin],
[left + width, top + flagMargin]
]);
line1 = flagGroup.pathItems.add();
line1.strokeOverprint = true
line1.setEntirePath(
[
[left, top + flagMargin / 2],
[left, top + flagMargin + flagMargin / 2]
]
);
line1 = flagGroup.pathItems.add();
line1.strokeOverprint = true
line1.setEntirePath(
[
[left + width, top + flagMargin / 2],
[left + width, top + flagMargin + flagMargin / 2]
]
);
// 画线条
// 画箭头
var arrow1 = flagGroup.pathItems.add(); //画箭头左
arrow1.stroked = false;
arrow1.fillColor = createColor();
arrow1.fillOverprint = true
arrow1.setEntirePath([
[left, top + flagMargin],
[left + arrowSize, top + flagMargin + arrowSize / 2],
[left + arrowSize, top + flagMargin - arrowSize / 2]]
);
arrow1.closed = true
var arrow1 = flagGroup.pathItems.add(); //画箭头右
arrow1.stroked = false;
arrow1.fillColor = createColor();
arrow1.fillOverprint = true
arrow1.setEntirePath([
[left + width, top + flagMargin],
[left + width - arrowSize, top + flagMargin + arrowSize / 2],
[left + width - arrowSize, top + flagMargin - arrowSize / 2]]
);
arrow1.closed = true
// 画箭头
// 尺寸文字
var text1 = flagGroup.textFrames.add()
text1.contents = mathNum(width / _datumPointUnit, five, count) + " mm"
text1.textRange.characterAttributes.size = flagFontSize;
text1.textRange.fillColor = createColor();
text1.textRange.characterAttributes.overprintFill = true
text1.left = left + width / 2 - text1.width / 2;
text1.top = top + flagMargin + text1.height + text1.height / 2;
for (var i = 0; i < app.textFonts.length; i++) {
var e = app.textFonts[i];
if (e.family === "Adobe 宋体 Std L") {
text1.textRange.characterAttributes.textFont = app.textFonts[i]
}
}
// ---------------------下 - 画宽度标尺--------------------
}
}
}
// 入口函数
function init() {
// 在屏幕左上角附近创建一个空对话框窗口
dlg = new Window('dialog', '尺寸标注@冰镇果冻');
dlg.center()
dlg.frameLocation = [400, 400];
dlg.msgPnl = dlg.add('panel', undefined, '配置');
dlg.msgPnl.alignChildren = "center";
dlg.positionPnl = dlg.add('panel', undefined, '数值/位置');
dlg.positionPnl.alignChildren = "center";
dlg.msgPnl._margin = dlg.msgPnl.add('group');
dlg.msgPnl._fontSize = dlg.msgPnl.add('group');
dlg.msgPnl._alSize = dlg.msgPnl.add('group');
dlg.msgPnl._alWidth = dlg.msgPnl.add('group');
dlg.msgPnl._alNum = dlg.msgPnl.add('group');
with (dlg.msgPnl) {
_margin.st = _margin.add('statictext', undefined, '标注与对象的距离(mm)');
_margin.et = _margin.add('edittext', undefined, $.getenv("bz_margin") ? $.getenv("bz_margin") : "1");
_margin.et.preferredSize = [60, 30];
_fontSize.st = _fontSize.add('statictext', undefined, '标注文字字体大小(mm)');
_fontSize.et = _fontSize.add('edittext', undefined, $.getenv("bz_fontSize") ? $.getenv("bz_fontSize") : "2");
_fontSize.et.preferredSize = [60, 30];
_alSize.st = _alSize.add('statictext', undefined, '标注箭头大小尺寸(mm)');
_alSize.et = _alSize.add('edittext', undefined, $.getenv("bz_alSize") ? $.getenv("bz_alSize") : "0.1");
_alSize.et.preferredSize = [60, 30];
_alWidth.st = _alWidth.add('statictext', undefined, '标注线条粗细尺寸(mm)');
_alWidth.et = _alWidth.add('edittext', undefined, $.getenv("bz_alWidth") ? $.getenv("bz_alWidth") : "0.1");
_alWidth.et.preferredSize = [60, 30];
_alNum.st = _alNum.add('statictext', undefined, '标注数值小数个数(cs)');
_alNum.et = _alNum.add('edittext', undefined, count);
_alNum.et.preferredSize = [60, 30];
}
dlg.positionPnl._direction = dlg.positionPnl.add('group');
with (dlg.positionPnl) {
_five = _direction.add("checkbox", undefined, "四舍五入");
_five.value = five
_top = _direction.add("checkbox", undefined, "上");
_top.value = $.getenv("bz_top") + "" !== 'null' ? ($.getenv("bz_top") === 'false' ? false : true) : false
_bottom = _direction.add("checkbox", undefined, "下");
_bottom.value = $.getenv("bz_bottom") + "" !== 'null' ? ($.getenv("bz_bottom") === 'false' ? false : true) : false
_left = _direction.add("checkbox", undefined, "左");
_left.value = $.getenv("bz_left") + "" !== 'null' ? ($.getenv("bz_left") === 'false' ? false : true) : true
_right = _direction.add("checkbox", undefined, "右");
_right.value = $.getenv("bz_right") + "" !== 'null' ? ($.getenv("bz_right") === 'false' ? false : true) : false
}
dlg.btnPnl = dlg.add('panel', undefined, '操作');
dlg.btnPnl.orientation = "row";
dlg.btnPnl.buildBtn = dlg.btnPnl.add('button', undefined, '标注选中对象', { name: 'ok' });
dlg.btnPnl.build2Btn = dlg.btnPnl.add('button', undefined, '标注横向距离', { name: '_width' });
dlg.btnPnl.build3Btn = dlg.btnPnl.add('button', undefined, '标注纵向距离', { name: '_height' });
dlg.btnPnl.ok.onClick = function () {
count = Number(dlg.msgPnl._alNum.et.text)
five = _five.value
var _margin = Number(dlg.msgPnl._margin.et.text)
var _fontSize = Number(dlg.msgPnl._fontSize.et.text)
var _alSize = Number(dlg.msgPnl._alSize.et.text)
var _alWidth = Number(dlg.msgPnl._alWidth.et.text)
$.setenv("bz_count", count)
$.setenv("bz_five", five)
$.setenv("bz_margin", _margin)
$.setenv("bz_fontSize", _fontSize)
$.setenv("bz_alSize", _alSize)
$.setenv("bz_alWidth", _alWidth)
$.setenv("bz_left", _left.value)
$.setenv("bz_top", _top.value)
$.setenv("bz_bottom", _bottom.value)
$.setenv("bz_right", _right.value)
main(_margin, _fontSize, _alSize, _alWidth, _top.value, _bottom.value, _left.value, _right.value)
dlg.fivelose()
}
dlg.btnPnl.build2Btn.onClick = function () {
count = Number(dlg.msgPnl._alNum.et.text)
five = _five.value
var _margin = Number(dlg.msgPnl._margin.et.text)
var _fontSize = Number(dlg.msgPnl._fontSize.et.text)
var _alSize = Number(dlg.msgPnl._alSize.et.text)
var _alWidth = Number(dlg.msgPnl._alWidth.et.text)
$.setenv("bz_count", count)
$.setenv("bz_five", five)
$.setenv("bz_margin", _margin)
$.setenv("bz_fontSize", _fontSize)
$.setenv("bz_alSize", _alSize)
$.setenv("bz_alWidth", _alWidth)
main2("标注横向距离", _margin, _fontSize, _alSize, _alWidth)
dlg.close()
}
dlg.btnPnl.build3Btn.onClick = function () {
count = Number(dlg.msgPnl._alNum.et.text)
five = _five.value
var _margin = Number(dlg.msgPnl._margin.et.text)
var _fontSize = Number(dlg.msgPnl._fontSize.et.text)
var _alSize = Number(dlg.msgPnl._alSize.et.text)
var _alWidth = Number(dlg.msgPnl._alWidth.et.text)
$.setenv("bz_count", count)
$.setenv("bz_five", five)
$.setenv("bz_margin", _margin)
$.setenv("bz_fontSize", _fontSize)
$.setenv("bz_alSize", _alSize)
$.setenv("bz_alWidth", _alWidth)
main2("标注纵向距离", _margin, _fontSize, _alSize, _alWidth)
dlg.close()
}
dlg.show()
}
init()
// --------下面是增强代码--------
function elDistanceLabeling(el1, el2, type, flagMargin, flagFontSize, arrowSize, arrowWidth) {
var config = getConfig(flagMargin, flagFontSize, arrowSize, arrowWidth) // 获取配置
// 获取两个元素的位置信息
var el1_leftX = el1.geometricBounds[0]
var el1_leftY = el1.geometricBounds[1]
var el1_rightX = el1.geometricBounds[2]
var el1_rightY = el1.geometricBounds[3]
var el2_leftX = el2.geometricBounds[0]
var el2_leftY = el2.geometricBounds[1]
var el2_rightX = el2.geometricBounds[2]
var el2_rightY = el2.geometricBounds[3]
// 获取两个元素的位置信息
// 中心点
var align = (el2_rightY - el1_leftY) / 2 + el1_leftY
var center = (el2_rightX - el1_leftX) / 2 + el1_leftX
// 获得组
var _group = getGroupAndLayer()
if (type === "标注横向距离") {
var margin = (el2_leftX - el1_rightX)
widthFlag(_group, center, align, margin, el1_leftX, el1_leftY, el1_rightX, el1_rightY, el2_leftX, el2_leftY, el2_rightX, el2_rightY, config)
}
if (type === "标注纵向距离") {
var margin = el2_leftY - el1_rightY
heightFlag(_group, center, align, margin, el1_leftX, el1_leftY, el1_rightX, el1_rightY, el2_leftX, el2_leftY, el2_rightX, el2_rightY, config)
}
}
function main2(type, flagMargin, flagFontSize, arrowSize, arrowWidth) {
var theSelect = activeDocument.selection;
if (theSelect.length < 2) {
alert('选择的物体数量小于2, 无法计算', "提示")
return
}
// 排序
if (type === "标注横向距离") {
my_sort(theSelect)
} else {
my_sort2(theSelect)
}
for (var i = 0; i < theSelect.length - 1; i++) {
elDistanceLabeling(theSelect[i], theSelect[i + 1], type, flagMargin, flagFontSize, arrowSize, arrowWidth)
}
}
function getConfig(flagMargin, flagFontSize, arrowSize, arrowWidth) {
var newSpot
var newColor
try {
newSpot = app.activeDocument.spots.getByName("Dimension Line")
} catch (error) {
// 创建专色
newSpot = app.activeDocument.spots.add();
newColor = new CMYKColor();
newColor.cyan = 100;
newColor.magenta = 0;
newColor.yellow = 0;
newColor.black = 0;
newSpot.name = "Dimension Line";
newSpot.colorType = ColorModel.SPOT;
newSpot.color = newColor;
}
var newSpotColor = new SpotColor();
newSpotColor.spot = newSpot;
return {
flagMargin: toMM(flagMargin),
flagFontSize: toMM(flagFontSize),
arrowSize: toMM(arrowSize),
arrowWidth: toMM(arrowWidth),
spot: newSpotColor
}
}
function getGroupAndLayer() {
var name = "@PDG_标注图层"
var name2 = "@PDG_标注图层_组"
var doc = app.activeDocument
for (var i = 0; i < doc.layers.length; i++) {
var lay = doc.layers[i];
if (lay.name === name) {
for (var j = 0; j < doc.groupItems.length; j++) { // 查找是否有路径组
var group = doc.groupItems[j];
if (group.name === name2)
return group
}
// 有图层没组
var _my_group = lay.groupItems.add()
_my_group.name = name2
return _my_group
}
}
var cutlayer = activeDocument.layers.add();
cutlayer.name = name; //设置图层名称
var my_group = cutlayer.groupItems.add();
my_group.name = name2
return my_group
}
function widthFlag(_group, center, align, margin, el1_leftX, el1_leftY, el1_rightX, el1_rightY, el2_leftX, el2_leftY, el2_rightX, el2_rightY, config) {
var _datumPointUnit = 2.834646
// ---------------------画宽度标尺--------------------
// 画线条
var line1 = _group.pathItems.add();
line1.strokeColor = config.spot
line1.strokeOverprint = true
line1.filled = false
line1.setEntirePath([
[el1_rightX, align],
[el1_rightX + margin, align]
]);
line1 = _group.pathItems.add();
line1.strokeColor = config.spot
line1.strokeOverprint = true
line1.filled = false
line1.setEntirePath(
[
[el1_rightX, align - config.flagMargin / 2],
[el1_rightX, align + config.flagMargin / 2]
]
);
line1 = _group.pathItems.add();
line1.strokeColor = config.spot
line1.strokeOverprint = true
line1.filled = false
line1.setEntirePath(
[
[el2_leftX, align - config.flagMargin / 2],
[el2_leftX, align + config.flagMargin / 2]
]
);
// 画线条
var arrow1 = _group.pathItems.add(); //画箭头左
arrow1.stroked = false;
arrow1.fillColor = config.spot;
arrow1.fillOverprint = true
arrow1.setEntirePath([
[el1_rightX, align],
[el1_rightX + config.arrowSize, align + config.arrowSize / 2],
[el1_rightX + config.arrowSize, align - config.arrowSize / 2]]
);
arrow1.closed = true
var arrow1 = _group.pathItems.add(); //画箭头右
arrow1.stroked = false;
arrow1.fillColor = config.spot;
arrow1.fillOverprint = true
arrow1.setEntirePath([
[el2_leftX, align],
[el2_leftX - config.arrowSize, align + config.arrowSize / 2],
[el2_leftX - config.arrowSize, align - config.arrowSize / 2]]
);
arrow1.closed = true
// 尺寸文字
var text1 = _group.textFrames.add()
text1.contents = mathNum(margin / _datumPointUnit, five, count) + " mm"
text1.textRange.characterAttributes.size = config.flagFontSize;
text1.textRange.fillColor = config.spot;
text1.textRange.characterAttributes.overprintFill = true
text1.left = el1_rightX + margin / 2 - text1.width / 2;
text1.top = align + text1.height;
for (var i = 0; i < app.textFonts.length; i++) {
var e = app.textFonts[i];
if (e.family === "Adobe 宋体 Std L") {
text1.textRange.characterAttributes.textFont = app.textFonts[i]
}
}
}
function heightFlag(_group, center, align, margin, el1_leftX, el1_leftY, el1_rightX, el1_rightY, el2_leftX, el2_leftY, el2_rightX, el2_rightY, config) {
var _datumPointUnit = 2.834646
// ---------------------画高度标尺--------------------
// 画线条
var line1 = _group.pathItems.add();
line1.strokeColor = config.spot
line1.strokeOverprint = true
line1.filled = false
line1.setEntirePath([
[center, el1_rightY],
[center, el2_leftY]
]);
var line1 = _group.pathItems.add();
line1.strokeColor = config.spot
line1.strokeOverprint = true
line1.filled = false
line1.setEntirePath([
[center - config.flagMargin / 2, el2_leftY],
[center + config.flagMargin / 2, el2_leftY]
]);
var line1 = _group.pathItems.add();
line1.strokeColor = config.spot
line1.strokeOverprint = true
line1.filled = false
line1.setEntirePath([
[center - config.flagMargin / 2, el1_rightY],
[center + config.flagMargin / 2, el1_rightY]
]);
var arrow1 = _group.pathItems.add(); //画箭头上
arrow1.stroked = false;
arrow1.fillColor = config.spot;
arrow1.fillOverprint = true
arrow1.setEntirePath([
[center, el1_rightY],
[center - config.arrowSize / 2, el1_rightY - config.arrowSize],
[center + config.arrowSize / 2, el1_rightY - config.arrowSize]]
);
arrow1.closed = true
var arrow1 = _group.pathItems.add(); //画箭头上
arrow1.stroked = false;
arrow1.fillColor = config.spot;
arrow1.fillOverprint = true
arrow1.setEntirePath([
[center, el2_leftY],
[center - config.arrowSize / 2, el2_leftY + config.arrowSize],
[center + config.arrowSize / 2, el2_leftY + config.arrowSize]]
);
arrow1.closed = true
// 尺寸文字
var text1 = _group.textFrames.add()
text1.contents = mathNum(margin / _datumPointUnit, five, count) + " mm"
text1.textRange.characterAttributes.size = config.flagFontSize;
text1.textRange.fillColor = config.spot;
text1.textRange.characterAttributes.overprintFill = true
text1.left = center + config.flagMargin / 2;
text1.top = align + text1.height / 2;
for (var i = 0; i < app.textFonts.length; i++) {
var e = app.textFonts[i];
if (e.family === "Adobe 宋体 Std L") {
text1.textRange.characterAttributes.textFont = app.textFonts[i]
}
}
}
function my_sort(arr) {
for (var i = 0; i < arr.length - 1; ++i) {
// 假设最小的值是当前的下标
var indexMin = i;
//遍历剩余长度找到最小下标
for (var j = i; j < arr.length; ++j) {
if (arr[j].geometricBounds[0] < arr[indexMin].geometricBounds[0] || arr[j].geometricBounds[2] < arr[indexMin].geometricBounds[2]) {
indexMin = j;
}
}
if (indexMin !== i) {
//交换当前下标i与最小下标的
var temp = arr[i];
arr[i] = arr[indexMin];
arr[indexMin] = temp;
}
}
return arr
};
function my_sort2(arr) {
for (var i = 0; i < arr.length - 1; ++i) {
// 假设最小的值是当前的下标
var indexMin = i;
//遍历剩余长度找到最小下标
for (var j = i; j < arr.length; ++j) {
if (arr[j].geometricBounds[1] > arr[indexMin].geometricBounds[1] || arr[j].geometricBounds[3] > arr[indexMin].geometricBounds[3]) {
indexMin = j;
}
}
if (indexMin !== i) {
//交换当前下标i与最小下标的
var temp = arr[i];
arr[i] = arr[indexMin];
arr[indexMin] = temp;
}
}
return arr
};
function toMM(num) {
var _baseUnit = 2.834646
return num * _baseUnit
}
function mathNum(_value, _five, _count) {
if (_five) {
_value = _value.toFixed(_count)
} else {
_value = _value + ""
// 截取
_start = _value.split(".")[0].length
_value = _value.slice(0, _start + 1 + _count)
}
return Number(_value)
}





承担因您的行为而导致的法律责任,
本站有权保留或删除有争议评论。
参与本评论即表明您已经阅读并接受
上述条款。