feat: AI套图分层方案 + Gemini集成 - 4种图案类型处理 + 正片叠底 + 宽高比 + 模型选择
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2740
psmark/JSX1.py
Normal file
2740
psmark/JSX1.py
Normal file
File diff suppressed because it is too large
Load Diff
1094
psmark/JSX10.py
Normal file
1094
psmark/JSX10.py
Normal file
File diff suppressed because it is too large
Load Diff
1066
psmark/JSX11.py
Normal file
1066
psmark/JSX11.py
Normal file
File diff suppressed because it is too large
Load Diff
191
psmark/JSX12.py
Normal file
191
psmark/JSX12.py
Normal file
@@ -0,0 +1,191 @@
|
||||
dxf12_jscode = """
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
批量套数写入()
|
||||
|
||||
function 批量套数写入() {
|
||||
app.preferences.rulerUnits = Units.CM;
|
||||
var 主文档 = app.activeDocument;
|
||||
var 主文档名称 = 主文档.name;
|
||||
|
||||
// 遍历当前打开的文档
|
||||
for (var i = 0; i < app.documents.length; i++) {
|
||||
var document = app.documents[i];
|
||||
var documentName = document.name;
|
||||
|
||||
// 判断文档名称是否与主文档名称不相同
|
||||
if (documentName !== 主文档名称) {
|
||||
// 设置当前文档为活动文档
|
||||
app.activeDocument = document;
|
||||
|
||||
var 匹配图层数组 = 遍历图层查找P1();
|
||||
|
||||
// 遍历匹配图层数组
|
||||
for (var j = 0; j < 匹配图层数组.length; j++) {
|
||||
var 当前匹配图层 = 匹配图层数组[j];
|
||||
}
|
||||
// 选中当前匹配图层
|
||||
|
||||
|
||||
// 获取当前选区
|
||||
var currentSelection = app.activeDocument.selection;
|
||||
|
||||
// 确保当前选区不为空且为矩形选区
|
||||
if (currentSelection != null && currentSelection.hasOwnProperty('bounds')) {
|
||||
// 进行缩放操作
|
||||
|
||||
app.activeDocument.activeLayer = 当前匹配图层;
|
||||
|
||||
// 载入选区
|
||||
载入选区();
|
||||
// 获取当前选区的坐标
|
||||
var bounds = currentSelection.bounds;
|
||||
|
||||
// 获取当前选区的宽度和高度(以 cm 为单位)
|
||||
var resolution = app.activeDocument.resolution;
|
||||
var widthInCM = (bounds[2].as("cm") - bounds[0].as("cm"));
|
||||
var heightInCM = (bounds[3].as("cm") - bounds[1].as("cm"));
|
||||
var 当前P1图层宽高信息 = "宽度:" + widthInCM.toFixed(2) + "cm,高度:" + heightInCM.toFixed(2) + "cm";
|
||||
|
||||
// 获取当前裁片套数
|
||||
var 搜索关键词 = "P1";
|
||||
var 匹配的图层数量 = 获取匹配图层数量(搜索关键词);
|
||||
var 当前裁片套数 = "一段" + 匹配的图层数量 + "件";
|
||||
|
||||
// 创建新图层并设置名称
|
||||
/// var 新图层 = 主文档.artLayers.add();
|
||||
// var 新图层 = "当前文档宽度缩水" + 宽度值 + "高度缩水" + 高度值;
|
||||
|
||||
// 移动选区到新图层
|
||||
// currentSelection.cut();
|
||||
// app.activeDocument.paste();
|
||||
// alert(当前裁片套数);
|
||||
// alert( 当前P1图层宽高信息);
|
||||
// 文件简介写入
|
||||
文件简介写入(当前裁片套数, 当前P1图层宽高信息 );
|
||||
|
||||
// 这里删除了文件简介的写入将缩水值修改按钮
|
||||
// 调整图像尺寸(宽度值, 高度值);
|
||||
////这里取消了保存功能 为了防止运行的时候变卡
|
||||
//activeDocument.save();
|
||||
} else {
|
||||
// alert("没有找到匹配的图层。");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
app.activeDocument=主文档
|
||||
// alert("写入信息成功","来自左威的提醒");
|
||||
}
|
||||
|
||||
function 文件简介写入(当前裁片套数, 当前P1图层宽高信息) {
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("fileInfo"));
|
||||
r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putString(stringIDToTypeID("caption"), 当前裁片套数);
|
||||
d1.putString(stringIDToTypeID("keywords"), 当前P1图层宽高信息);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("fileInfo"), d1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 调整图像尺寸(宽度值, 高度值) {
|
||||
var 动作描述 = new ActionDescriptor();
|
||||
动作描述.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("percentUnit"), 100 + 宽度值);
|
||||
动作描述.putUnitDouble(stringIDToTypeID("height"), stringIDToTypeID("percentUnit"), 100 + 高度值);
|
||||
动作描述.putEnumerated(charIDToTypeID("Intr"), stringIDToTypeID("interpolationType"), stringIDToTypeID("nearestNeighbor"));
|
||||
executeAction(stringIDToTypeID("imageSize"), 动作描述, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 载入选区() //载入选区
|
||||
{
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 遍历图层查找P1() {
|
||||
var 匹配图层数组 = [];
|
||||
var 文档 = app.activeDocument;
|
||||
|
||||
// 遍历所有图层
|
||||
function 遍历所有图层(图层) {
|
||||
if (图层.typename === "LayerSet") {
|
||||
for (var i = 0; i < 图层.layers.length; i++) {
|
||||
遍历所有图层(图层.layers[i]);
|
||||
}
|
||||
} else {
|
||||
var 图层名分割数组 = 图层.name.split("-"); // 假设分割符是 "_"
|
||||
if (图层名分割数组[0] === "P1") { // 精确匹配
|
||||
匹配图层数组.push(图层);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 开始遍历
|
||||
for (var j = 0; j < 文档.layers.length; j++) {
|
||||
遍历所有图层(文档.layers[j]);
|
||||
}
|
||||
|
||||
return 匹配图层数组;
|
||||
}
|
||||
|
||||
|
||||
function 获取匹配图层数量(搜索关键词) {
|
||||
var 匹配图层数量 = 0;
|
||||
|
||||
// 递归遍历图层及其子图层
|
||||
function 遍历图层(图层) {
|
||||
if (图层.typename === "LayerSet") {
|
||||
for (var i = 0; i < 图层.layers.length; i++) {
|
||||
遍历图层(图层.layers[i]);
|
||||
}
|
||||
} else {
|
||||
// 进行模糊匹配和精确分割匹配
|
||||
if (图层.name.indexOf(搜索关键词) !== -1 && 精确分割匹配图层(图层.name, 搜索关键词)) {
|
||||
匹配图层数量++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 精确分割匹配图层名
|
||||
function 精确分割匹配图层(图层名, 搜索词) {
|
||||
var 图层名分割数组 = 图层名.split("-"); // 假设分割符是 "_"
|
||||
return 图层名分割数组[0] === 搜索词;
|
||||
}
|
||||
|
||||
var 当前文档 = app.activeDocument;
|
||||
var 所有图层 = 当前文档.layers;
|
||||
|
||||
for (var i = 0; i < 所有图层.length; i++) {
|
||||
遍历图层(所有图层[i]);
|
||||
}
|
||||
|
||||
return 匹配图层数量;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
982
psmark/JSX13.py
Normal file
982
psmark/JSX13.py
Normal file
@@ -0,0 +1,982 @@
|
||||
dxf13_jscode = """
|
||||
|
||||
|
||||
function 裁片射出宽高缩放() {
|
||||
app.preferences.rulerUnits = Units.PIXELS
|
||||
var 主文档 = app.activeDocument;
|
||||
var 主文档名称 = 主文档.name;
|
||||
|
||||
// 遍历当前打开的文档
|
||||
for (var i = 0; i < app.documents.length; i++) {
|
||||
var document = app.documents[i];
|
||||
var documentName = document.name;
|
||||
|
||||
// 判断文档名称是否与主文档名称不相同
|
||||
if (documentName !== 主文档名称) {
|
||||
app.activeDocument = document;
|
||||
遍历图层();
|
||||
}
|
||||
}
|
||||
|
||||
function 遍历图层() {
|
||||
var layerNames = []; // 用于存储图层名称的数组
|
||||
var currentDocument = app.activeDocument;
|
||||
|
||||
for (var j = 0; j < currentDocument.layers.length; j++) {
|
||||
var layer = currentDocument.layers[j];
|
||||
var layerName = layer.name;
|
||||
layerNames.push(layerName);
|
||||
}
|
||||
|
||||
// 逐个处理图层
|
||||
for (var k = 0; k < layerNames.length; k++) {
|
||||
var 当前图层名称 = layerNames[k];
|
||||
// $.writeln("图层名称:" + 当前图层名称);
|
||||
// alert(当前图层名称);
|
||||
|
||||
var parts = 当前图层名称.split("-");
|
||||
if (parts.length > 0) {
|
||||
var 裁片名称 = parts[0];
|
||||
app.activeDocument = 主文档;
|
||||
$.writeln(裁片名称);
|
||||
初始化模板裁片名称 = 当前图层名称.split("-");
|
||||
初始化码数裁片名称 = 当前图层名称.split("_");
|
||||
大货组名称 =初始化模板裁片名称[0]+("-大货裁片")
|
||||
实际裁片名称 = 初始化模板裁片名称[0]+"-"+初始化码数裁片名称[2]
|
||||
$.writeln(大货组名称);
|
||||
$.writeln(实际裁片名称);
|
||||
var 空白裁片模板 = app.activeDocument.layerSets.getByName(大货组名称).layers.getByName(实际裁片名称 );
|
||||
app.activeDocument.activeLayer = 空白裁片模板;
|
||||
载入选区()
|
||||
|
||||
var 边距 = 获取当前选区四边距();
|
||||
var 当前选区高度=边距.bottom-边距.top
|
||||
var 当前选区宽度=边距.right-边距.left
|
||||
var 高度转毫米 = pixelsToMillimeters(当前选区高度);
|
||||
var 宽度转毫米 = pixelsToMillimeters(当前选区宽度);
|
||||
|
||||
var 搜索词 = 裁片名称;
|
||||
var 匹配图层数组 = 匹配图层名(搜索词);
|
||||
|
||||
// 显示匹配的图层列表
|
||||
if (匹配图层数组.length > 0) {
|
||||
var 图层列表文本 = "匹配的图层列表:";
|
||||
for (var i = 0; i < 匹配图层数组.length; i++) {
|
||||
if (i !== 0) {
|
||||
图层列表文本 += " ";
|
||||
}
|
||||
图层列表文本 += 匹配图层数组[i].name;
|
||||
}
|
||||
var 数据解析分割=图层列表文本.split("_");
|
||||
//var 实际套花名称=名称部分[0]
|
||||
var 基码图层宽度 = parseFloat(数据解析分割[1]);
|
||||
var 基码图层高度 = parseFloat(数据解析分割[2]);
|
||||
var 缩放比例高度=高度转毫米/基码图层高度*100
|
||||
var 缩放比例宽度=宽度转毫米/基码图层宽度*100
|
||||
// alert(基码图层宽度);
|
||||
} else {
|
||||
alert("没有找到匹配的图层。");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
$.writeln("上边距:" + 边距.top);
|
||||
$.writeln("左边距:" + 边距.left);
|
||||
$.writeln("下边距:" + 边距.bottom);
|
||||
$.writeln("右边距:" + 边距.right);
|
||||
*/8
|
||||
// 示例用法:
|
||||
var 毫米 = 300;
|
||||
var 每英寸像素数 = app.activeDocument.resolution; // 获取当前文档的分辨率(每英寸像素数)
|
||||
var 扩展像素 = 毫米转像素(毫米, 每英寸像素数);
|
||||
|
||||
var 裁切上边距= 边距.top-扩展像素
|
||||
var 裁切左边距= 边距.left-扩展像素
|
||||
var 裁切下边距= 边距.bottom+扩展像素
|
||||
var 裁切右边距= 边距.right+扩展像素
|
||||
$.writeln(裁切上边距);
|
||||
$.writeln(裁切左边距);
|
||||
$.writeln(裁切下边距);
|
||||
$.writeln(裁切右边距);
|
||||
裁切图层(裁切上边距,裁切左边距,裁切下边距,裁切右边距)
|
||||
|
||||
var 空白裁片模板 = app.activeDocument.layerSets.getByName(大货组名称).layers.getByName(实际裁片名称);
|
||||
app.activeDocument.activeLayer = 空白裁片模板;
|
||||
载入选区()
|
||||
var 缩放定位点的中心坐标=获取当前缩放定位点选区四边距()
|
||||
var 缩放定位点的Y轴坐标=缩放定位点的中心坐标.top2+(缩放定位点的中心坐标.bottom2-缩放定位点的中心坐标.top2)/2
|
||||
var 缩放定位点的X轴坐标=缩放定位点的中心坐标.left2+(缩放定位点的中心坐标.right2-缩放定位点的中心坐标.left2)/2
|
||||
$.writeln("Y轴中心坐标"+缩放定位点的Y轴坐标);
|
||||
$.writeln("X轴中心坐标"+缩放定位点的X轴坐标);
|
||||
|
||||
var 裁片 = app.activeDocument.layers.getByName(裁片名称);
|
||||
app.activeDocument.activeLayer = 裁片
|
||||
//var 空白裁片模板 = app.activeDocument.layerSets.getByName(大货组名称).layers.getByName(实际裁片名称 );
|
||||
//app.activeDocument.activeLayer = 空白裁片模板;
|
||||
取消选择()
|
||||
|
||||
图层按照缩放定位点进行宽高缩放(缩放定位点的X轴坐标,缩放定位点的Y轴坐标,缩放比例高度,缩放比例宽度)
|
||||
|
||||
// var 裁片 = app.activeDocument.layers.getByName(裁片名称);
|
||||
// app.activeDocument.activeLayer = 裁片;
|
||||
|
||||
var 空白裁片模板 = app.activeDocument.layerSets.getByName(大货组名称).layers.getByName(实际裁片名称 );
|
||||
app.activeDocument.activeLayer = 空白裁片模板;
|
||||
载入选区()
|
||||
var 裁片 = app.activeDocument.layers.getByName(裁片名称);
|
||||
app.activeDocument.activeLayer = 裁片
|
||||
添加图层蒙版()
|
||||
应用图层蒙版()
|
||||
裁片.copy();
|
||||
历史记录回退()
|
||||
app.activeDocument = currentDocument;
|
||||
图层选择(当前图层名称);
|
||||
载入选区();
|
||||
粘贴图层();
|
||||
|
||||
取消选择();
|
||||
// app.refresh();
|
||||
|
||||
|
||||
var 裁片名称 = 当前图层名称.split("_");
|
||||
if (裁片名称.length > 1) {
|
||||
var 角度信息 = 裁片名称[1];
|
||||
|
||||
if (角度信息 === "180" || 角度信息 === "-180") {
|
||||
自由变换();
|
||||
} else if (角度信息 === "-90") {
|
||||
逆时针90旋转()
|
||||
|
||||
} else if (角度信息 === "90") {
|
||||
|
||||
顺时针90旋转()
|
||||
} else {
|
||||
// 如果以上条件都不满足,则执行默认的代码
|
||||
}
|
||||
|
||||
|
||||
|
||||
//历史记录回退缩放函数()
|
||||
}
|
||||
app.activeDocument = 主文档;
|
||||
历史记录回退缩放函数()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
app.activeDocument = currentDocument;
|
||||
烧花线添加()//alert("当前码拍好")///////////////////////////////////这里可以填写添加烧花线函数
|
||||
|
||||
}
|
||||
//alert("排版完成,请检查文件!!!")
|
||||
app.activeDocument = 主文档;
|
||||
}
|
||||
|
||||
|
||||
// 将像素转换为毫米
|
||||
function pixelsToMillimeters(pixels) {
|
||||
// 获取当前文档
|
||||
var doc = app.activeDocument;
|
||||
|
||||
// 获取图像的分辨率(像素/英寸)
|
||||
var resolution = doc.resolution;
|
||||
|
||||
// 计算像素转换为毫米
|
||||
var inches = pixels / resolution;
|
||||
var millimeters = inches * 25.4;
|
||||
|
||||
return millimeters.toFixed(2); // 保留两位小数
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 顺时针90旋转() //自由变换
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), d1);
|
||||
d.putUnitDouble(stringIDToTypeID("angle"), stringIDToTypeID("angleUnit"), 90);
|
||||
d.putBoolean(stringIDToTypeID("linked"), true);
|
||||
d.putEnumerated(charIDToTypeID("Intr"), stringIDToTypeID("interpolationType"), stringIDToTypeID("nearestNeighbor"));
|
||||
executeAction(stringIDToTypeID("transform"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 逆时针90旋转() //自由变换
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), d1);
|
||||
d.putUnitDouble(stringIDToTypeID("angle"), stringIDToTypeID("angleUnit"), -90);
|
||||
d.putBoolean(stringIDToTypeID("linked"), true);
|
||||
d.putEnumerated(charIDToTypeID("Intr"), stringIDToTypeID("interpolationType"), stringIDToTypeID("nearestNeighbor"));
|
||||
executeAction(stringIDToTypeID("transform"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 匹配图层名(搜索词) {
|
||||
// 获取指定图层组中的所有图层
|
||||
function 获取组中所有图层(组) {
|
||||
var 图层数组 = [];
|
||||
var 图层组中图层 = 组.layers;
|
||||
|
||||
for (var i = 0; i < 图层组中图层.length; i++) {
|
||||
var 图层 = 图层组中图层[i];
|
||||
图层数组.push(图层);
|
||||
if (图层.typename === "LayerSet") {
|
||||
var 子图层 = 获取组中所有图层(图层);
|
||||
图层数组 = 图层数组.concat(子图层);
|
||||
}
|
||||
}
|
||||
|
||||
return 图层数组;
|
||||
}
|
||||
|
||||
// 获取指定名称的图层组
|
||||
function 根据名称获取图层组(文档, 组名称) {
|
||||
var 组 = null;
|
||||
var 所有图层 = 文档.layers;
|
||||
|
||||
for (var i = 0; i < 所有图层.length; i++) {
|
||||
var 图层 = 所有图层[i];
|
||||
if (图层.typename === "LayerSet" && 图层.name === 组名称) {
|
||||
组 = 图层;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 组;
|
||||
}
|
||||
|
||||
var 文档 = app.activeDocument;
|
||||
var 组名称 = "图层基础信息"; // 指定要匹配的图层组名称
|
||||
var 组 = 根据名称获取图层组(文档, 组名称);
|
||||
|
||||
if (组) {
|
||||
var 图层数组 = 获取组中所有图层(组);
|
||||
var 模糊匹配图层数组 = [];
|
||||
|
||||
// 首先进行模糊匹配
|
||||
for (var i = 0; i < 图层数组.length; i++) {
|
||||
var 图层 = 图层数组[i];
|
||||
if (图层.name.indexOf(搜索词) !== -1) {
|
||||
模糊匹配图层数组.push(图层);
|
||||
}
|
||||
}
|
||||
|
||||
// 在模糊匹配结果中进行图层基础信息数组分割过滤
|
||||
var 精确匹配图层数组 = [];
|
||||
for (var j = 0; j < 模糊匹配图层数组.length; j++) {
|
||||
var 模糊匹配图层 = 模糊匹配图层数组[j];
|
||||
// 进行图层基础信息数组分割过滤
|
||||
var 图层基础信息数组 = 模糊匹配图层.name.split("_"); // 假设分割符是 "_"
|
||||
if (图层基础信息数组[0] === 搜索词) {
|
||||
精确匹配图层数组.push(模糊匹配图层);
|
||||
}
|
||||
}
|
||||
|
||||
// 返回匹配的图层数组
|
||||
return 精确匹配图层数组;
|
||||
} else {
|
||||
alert('未找到名为"' + 组名称 + '"的图层组。');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 毫米转像素(毫米, 每英寸像素数) {
|
||||
var 每英寸毫米数 = 25.4;
|
||||
var 英寸 = 毫米 / 每英寸毫米数;
|
||||
return Math.round(英寸 * 每英寸像素数);
|
||||
}
|
||||
|
||||
function 图层按照缩放定位点进行宽高缩放(缩放定位点的X轴坐标,缩放定位点的Y轴坐标,缩放比例高度,缩放比例宽度) //自由变换
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSIndependent"));
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 缩放定位点的X轴坐标);
|
||||
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 缩放定位点的Y轴坐标);
|
||||
d.putObject(stringIDToTypeID("position"), stringIDToTypeID("point"), d1);
|
||||
var d2 = new ActionDescriptor();
|
||||
d2.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d2.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d2.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), d2);
|
||||
d.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("percentUnit"), 缩放比例宽度);
|
||||
d.putUnitDouble(stringIDToTypeID("height"), stringIDToTypeID("percentUnit"), 缩放比例高度);
|
||||
|
||||
d.putEnumerated(charIDToTypeID("Intr"), stringIDToTypeID("interpolationType"), stringIDToTypeID("nearestNeighbor"));
|
||||
executeAction(stringIDToTypeID("transform"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 裁切图层(裁切上边距,裁切左边距,裁切下边距,裁切右边距) //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("top"), stringIDToTypeID("pixelsUnit"), 裁切上边距);
|
||||
d1.putUnitDouble(stringIDToTypeID("left"), stringIDToTypeID("pixelsUnit"), 裁切左边距);
|
||||
d1.putUnitDouble(stringIDToTypeID("bottom"), stringIDToTypeID("pixelsUnit"),裁切下边距);
|
||||
d1.putUnitDouble(stringIDToTypeID("right"), stringIDToTypeID("pixelsUnit"), 裁切右边距);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("rectangle"), d1);
|
||||
d.putUnitDouble(stringIDToTypeID("angle"), stringIDToTypeID("angleUnit"), 0);
|
||||
d.putBoolean(stringIDToTypeID("delete"), true);
|
||||
d.putEnumerated(stringIDToTypeID("cropAspectRatioModeKey"), stringIDToTypeID("cropAspectRatioModeClass"), stringIDToTypeID("pureAspectRatio"));
|
||||
d.putBoolean(stringIDToTypeID("constrainProportions"), false);
|
||||
executeAction(stringIDToTypeID("crop"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 获取当前缩放定位点选区四边距() {
|
||||
var currentDocument = app.activeDocument;
|
||||
var selectionBounds = currentDocument.selection.bounds;
|
||||
|
||||
var top2 = selectionBounds[1].value;
|
||||
var left2 = selectionBounds[0].value;
|
||||
var bottom2 = selectionBounds[3].value;
|
||||
var right2 = selectionBounds[2].value;
|
||||
|
||||
return {
|
||||
top2: top2,
|
||||
left2: left2,
|
||||
bottom2: bottom2,
|
||||
right2: right2
|
||||
};
|
||||
}
|
||||
|
||||
function 获取当前选区四边距() {
|
||||
var currentDocument = app.activeDocument;
|
||||
var selectionBounds = currentDocument.selection.bounds;
|
||||
|
||||
var top = selectionBounds[1].value;
|
||||
var left = selectionBounds[0].value;
|
||||
var bottom = selectionBounds[3].value;
|
||||
var right = selectionBounds[2].value;
|
||||
|
||||
return {
|
||||
top: top,
|
||||
left: left,
|
||||
bottom: bottom,
|
||||
right: right
|
||||
};
|
||||
}
|
||||
|
||||
function 历史记录回退缩放函数() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putOffset(stringIDToTypeID("historyState"), -4 );
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 粘贴图层() //粘贴图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("paste"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 复制图层() //复制图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("copyEvent"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 载入选区() //载入选区
|
||||
{
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 取消选择() //取消选择
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("to"), stringIDToTypeID("ordinal"), stringIDToTypeID("none"));
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 图层选择(当前图层名称) //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putName(stringIDToTypeID("layer"), 当前图层名称);
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(6);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 自由变换() //自由变换
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), d1);
|
||||
d.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("percentUnit"), -100);
|
||||
d.putUnitDouble(stringIDToTypeID("height"), stringIDToTypeID("percentUnit"), -100);
|
||||
d.putBoolean(stringIDToTypeID("linked"), true);
|
||||
d.putEnumerated(charIDToTypeID("Intr"), stringIDToTypeID("interpolationType"), stringIDToTypeID("nearestNeighbor"));
|
||||
executeAction(stringIDToTypeID("transform"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 选择上一图层() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("forwardEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(8);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 添加图层蒙版() //添加图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("at"), r);
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("userMaskEnabled"), stringIDToTypeID("revealSelection"));
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 应用图层蒙版() //应用图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("apply"), true);
|
||||
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 拼合所有蒙版() //拼合所有蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("e805a6ee-6d75-4b62-b6fe-f5873b5fdf20"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 选择蒙版() //选择蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 历史记录回退() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putOffset(stringIDToTypeID("historyState"), -5);
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 烧花线添加() {
|
||||
|
||||
app.activeDocument.suspendHistory("烧花线添加", "烧花线()");
|
||||
|
||||
|
||||
function 烧花线() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 遍历当前文档图层
|
||||
|
||||
var doc = app.activeDocument;
|
||||
var layers = doc.layers;
|
||||
var filteredLayers = [];
|
||||
|
||||
// 遍历图层,筛选以P开头的图层
|
||||
for (var i = 0; i < layers.length; i++) {
|
||||
var layer = layers[i];
|
||||
if (layer.name.charAt(0) === 'P') {
|
||||
filteredLayers.push(layer);
|
||||
}
|
||||
}
|
||||
|
||||
空置图层()
|
||||
// 输出图层名称
|
||||
for (var j = 0; j < filteredLayers.length; j++) {
|
||||
var filteredLayer = filteredLayers[j];
|
||||
|
||||
var 裁片底图名称=filteredLayer.name;
|
||||
|
||||
多选图层(裁片底图名称);
|
||||
|
||||
// alert(filteredLayer.name);
|
||||
|
||||
}
|
||||
合并图层();
|
||||
置为顶层();
|
||||
画布大小();
|
||||
var layer = app.activeDocument.activeLayer;
|
||||
layer.name = "底图";
|
||||
恢复默认颜色()
|
||||
矩形选框像素点()
|
||||
//色彩范围()
|
||||
填充();
|
||||
魔棒烧花线()
|
||||
新建图层()
|
||||
var layer2 = app.activeDocument.activeLayer;
|
||||
layer2.name = "剪口";
|
||||
扩展2();
|
||||
恢复止口线默认颜色()
|
||||
填充();
|
||||
矩形选框准备删除()
|
||||
清除();
|
||||
魔棒();
|
||||
扩展();
|
||||
选择反向();
|
||||
清除();
|
||||
var 底图 = app.activeDocument.layers.getByName( "底图");
|
||||
app.activeDocument.activeLayer=底图;
|
||||
矩形选框准备删除()
|
||||
清除();
|
||||
置为底层()
|
||||
图层样式()
|
||||
取消选择()
|
||||
|
||||
function 多选图层(裁片底图名称) //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putName(stringIDToTypeID("layer"), 裁片底图名称);
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("selectionModifier"), stringIDToTypeID("selectionModifierType"), stringIDToTypeID("addToSelection"));
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(4);
|
||||
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 空置图层() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("selectNoLayers"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 恢复止口线默认颜色() //取消选择
|
||||
{
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("color"), stringIDToTypeID("foregroundColor"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putDouble(stringIDToTypeID("cyan"), 30);
|
||||
d1.putDouble(stringIDToTypeID("magenta"), 0);
|
||||
d1.putDouble(stringIDToTypeID("yellowColor"), 0);
|
||||
d1.putDouble(stringIDToTypeID("black"), 0);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("CMYKColorClass"), d1);
|
||||
d.putString(stringIDToTypeID("source"), "photoshopPicker");
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 合并图层() //合并图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("mergeLayersNew"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 恢复默认颜色() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("color"), stringIDToTypeID("colors"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("reset"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 魔棒烧花线() //魔棒
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("point"), d1);
|
||||
d.putInteger(stringIDToTypeID("tolerance"), 6);
|
||||
d.putBoolean(stringIDToTypeID("contiguous"), false);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
function 矩形选框像素点() //矩形选框
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("top"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("left"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("bottom"), stringIDToTypeID("distanceUnit"), 0.48);
|
||||
d1.putUnitDouble(stringIDToTypeID("right"), stringIDToTypeID("distanceUnit"), 0.48);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("rectangle"), d1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 置为底层() //置为底层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("back"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("move"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 置为顶层() //置为顶层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("front"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("move"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 色彩范围() //色彩范围
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putInteger(stringIDToTypeID("fuzziness"), 40);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putDouble(stringIDToTypeID("luminance"), 0);
|
||||
d1.putDouble(stringIDToTypeID("a"), 0);
|
||||
d1.putDouble(stringIDToTypeID("b"), 0);
|
||||
d.putObject(stringIDToTypeID("minimum"), stringIDToTypeID("labColor"), d1);
|
||||
var d2 = new ActionDescriptor();
|
||||
d2.putDouble(stringIDToTypeID("luminance"), 0);
|
||||
d2.putDouble(stringIDToTypeID("a"), 0);
|
||||
d2.putDouble(stringIDToTypeID("b"), 0);
|
||||
d.putObject(stringIDToTypeID("maximum"), stringIDToTypeID("labColor"), d2);
|
||||
d.putInteger(stringIDToTypeID("colorModel"), 0);
|
||||
executeAction(stringIDToTypeID("colorRange"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 新建图层() //新建图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("layer"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putInteger(stringIDToTypeID("layerID"), 33);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 扩展2() //扩展
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putUnitDouble(stringIDToTypeID("by"), stringIDToTypeID("pixelsUnit"), 1);
|
||||
d.putBoolean(stringIDToTypeID("selectionModifyEffectAtCanvasBounds"), false);
|
||||
executeAction(stringIDToTypeID("expand"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 填充() //填充
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("fillContents"), stringIDToTypeID("foregroundColor"));
|
||||
d.putUnitDouble(stringIDToTypeID("opacity"), stringIDToTypeID("percentUnit"), 100);
|
||||
d.putEnumerated(stringIDToTypeID("mode"), stringIDToTypeID("blendMode"), stringIDToTypeID("normal"));
|
||||
executeAction(stringIDToTypeID("fill"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 画布大小() //画布大小
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putBoolean(stringIDToTypeID("relative"), true);
|
||||
d.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("distanceUnit"), 40);
|
||||
d.putUnitDouble(stringIDToTypeID("height"), stringIDToTypeID("distanceUnit"), 40);
|
||||
d.putEnumerated(stringIDToTypeID("horizontal"), stringIDToTypeID("horizontalLocation"), stringIDToTypeID("center"));
|
||||
d.putEnumerated(stringIDToTypeID("vertical"), stringIDToTypeID("verticalLocation"), stringIDToTypeID("center"));
|
||||
executeAction(stringIDToTypeID("canvasSize"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 魔棒() //魔棒
|
||||
{
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 3);
|
||||
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 3);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("point"), d1);
|
||||
d.putInteger(stringIDToTypeID("tolerance"), 6);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 矩形选框准备删除() //矩形选框
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("top"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("left"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("bottom"), stringIDToTypeID("distanceUnit"), 0.96);
|
||||
d1.putUnitDouble(stringIDToTypeID("right"), stringIDToTypeID("distanceUnit"), 0.96);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("rectangle"), d1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 扩展() //扩展
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putUnitDouble(stringIDToTypeID("by"), stringIDToTypeID("pixelsUnit"), 25);
|
||||
d.putBoolean(stringIDToTypeID("selectionModifyEffectAtCanvasBounds"), false);
|
||||
executeAction(stringIDToTypeID("expand"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 选择反向() //选择反向
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("inverse"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 清除() //清除
|
||||
{
|
||||
app.activeDocument.selection.clear();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 图层样式() //图层样式
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerEffects"));
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("scale"), stringIDToTypeID("percentUnit"), 12);
|
||||
var d2 = new ActionDescriptor();
|
||||
d2.putBoolean(stringIDToTypeID("enabled"), true);
|
||||
d2.putBoolean(stringIDToTypeID("present"), true);
|
||||
d2.putBoolean(stringIDToTypeID("showInDialog"), true);
|
||||
d2.putEnumerated(stringIDToTypeID("style"), stringIDToTypeID("frameStyle"), stringIDToTypeID("outsetFrame"));
|
||||
d2.putEnumerated(stringIDToTypeID("paintType"), stringIDToTypeID("frameFill"), stringIDToTypeID("solidColor"));
|
||||
d2.putEnumerated(stringIDToTypeID("mode"), stringIDToTypeID("blendMode"), stringIDToTypeID("normal"));
|
||||
d2.putUnitDouble(stringIDToTypeID("opacity"), stringIDToTypeID("percentUnit"), 100);
|
||||
d2.putUnitDouble(stringIDToTypeID("size"), stringIDToTypeID("pixelsUnit"), 16);
|
||||
var d3 = new ActionDescriptor();
|
||||
d3.putDouble(stringIDToTypeID("red"), 90);
|
||||
d3.putDouble(stringIDToTypeID("green"), 79);
|
||||
d3.putDouble(stringIDToTypeID("blue"), 74);
|
||||
d2.putObject(stringIDToTypeID("color"), stringIDToTypeID("RGBColor"), d3);
|
||||
d2.putBoolean(stringIDToTypeID("overprint"), false);
|
||||
d1.putObject(stringIDToTypeID("frameFX"), stringIDToTypeID("frameFX"), d2);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("layerEffects"), d1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 取消选择() //取消选择
|
||||
{
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("to"), stringIDToTypeID("ordinal"), stringIDToTypeID("none"));
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
"""
|
||||
1187
psmark/JSX14.py
Normal file
1187
psmark/JSX14.py
Normal file
File diff suppressed because it is too large
Load Diff
385
psmark/JSX15.py
Normal file
385
psmark/JSX15.py
Normal file
@@ -0,0 +1,385 @@
|
||||
dxf15_jscode = """
|
||||
|
||||
|
||||
|
||||
function 图层自动编组2() {
|
||||
|
||||
app.activeDocument.suspendHistory("图层自动编组", "图层自动编组()");
|
||||
}
|
||||
|
||||
|
||||
function 图层自动编组(){
|
||||
var currentDocument = app.activeDocument;
|
||||
var matchCount = 0; // 匹配到的数值计数
|
||||
var existingPatternSet = false;
|
||||
var layerNames = []; // 保存匹配到的图层名称的数组
|
||||
|
||||
// 遍历图层
|
||||
for (var j = 0; j < currentDocument.layers.length; j++) {
|
||||
var layer = currentDocument.layers[j];
|
||||
var layerName = layer.name;
|
||||
|
||||
// 检查图层名称是否以P开头并且后面跟着数字
|
||||
if (/^P\d+$/.test(layerName)) {
|
||||
matchCount++;
|
||||
layerNames.push(layer); // 将匹配到的图层添加到数组中
|
||||
}
|
||||
}
|
||||
|
||||
// 输出匹配到的数值个数
|
||||
$.writeln("匹配到的数值个数:" + matchCount);
|
||||
|
||||
// 遍历匹配到的图层名称
|
||||
for (var i = 0; i < layerNames.length; i++) {
|
||||
var layerName = layerNames[i].name;
|
||||
// $.writeln("匹配到的图层名称:" + layerName);
|
||||
var 当前花样图层 = app.activeDocument.layers.getByName(layerName);
|
||||
app.activeDocument.activeLayer = 当前花样图层;
|
||||
图层编组main()
|
||||
app.activeDocument.activeLayer.name=layerName
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 图层编组main() //图层编组
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("layerSection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("from"), r1);
|
||||
d.putInteger(stringIDToTypeID("layerSectionStart"), 43);
|
||||
d.putInteger(stringIDToTypeID("layerSectionEnd"), 44);
|
||||
d.putString(stringIDToTypeID("name"), "main");
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 快速超级链接2() {
|
||||
|
||||
app.activeDocument.suspendHistory("快速超链接", "快速超级链接()");
|
||||
}
|
||||
|
||||
|
||||
function 快速超级链接() {
|
||||
var 导出目录 = Folder.selectDialog("选择超链接素材目录");
|
||||
if (!导出目录) {
|
||||
alert("未选择导出目录。操作已取消。");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
画布大小()
|
||||
app.preferences.rulerUnits = Units.PIXELS
|
||||
var currentDocument = app.activeDocument;
|
||||
var matchCount = 0; // 匹配到的数值计数
|
||||
var existingPatternSet = false;
|
||||
var layerNames = []; // 保存匹配到的图层名称的数组
|
||||
|
||||
// 遍历图层
|
||||
for (var j = 0; j < currentDocument.layers.length; j++) {
|
||||
var layer = currentDocument.layers[j];
|
||||
var layerName = layer.name;
|
||||
|
||||
// 检查图层名称是否以P开头并且后面跟着数字
|
||||
if (/^P\d+$/.test(layerName)) {
|
||||
matchCount++;
|
||||
layerNames.push(layer); // 将匹配到的图层添加到数组中
|
||||
}
|
||||
}
|
||||
|
||||
// 输出匹配到的数值个数
|
||||
// $.writeln("匹配到的数值个数:" + matchCount);
|
||||
|
||||
// 遍历匹配到的图层名称
|
||||
for (var i = 0; i < layerNames.length; i++) {
|
||||
var layerName = layerNames[i].name;
|
||||
$.writeln("匹配到的图层名称:" + layerName);
|
||||
var 当前花样图层 = app.activeDocument.layers.getByName(layerName);
|
||||
app.activeDocument.activeLayer = 当前花样图层;
|
||||
切换mask()
|
||||
载入选区()
|
||||
var 边距 = 获取当前选区四边距();
|
||||
var 毫米 = 130;
|
||||
var 每英寸像素数 = app.activeDocument.resolution; // 获取当前文档的分辨率(每英寸像素数)
|
||||
var 扩展像素 = 毫米转像素(毫米, 每英寸像素数);
|
||||
|
||||
var 裁切上边距= 边距.top-扩展像素
|
||||
var 裁切左边距= 边距.left-扩展像素
|
||||
var 裁切下边距= 边距.bottom+扩展像素
|
||||
var 裁切右边距= 边距.right+扩展像素
|
||||
|
||||
var selRegion = [
|
||||
[裁切左边距,裁切上边距],
|
||||
[裁切右边距,裁切上边距],
|
||||
[裁切右边距,裁切下边距],
|
||||
[裁切左边距,裁切下边距]
|
||||
];
|
||||
|
||||
app.activeDocument.selection.select(selRegion, SelectionType.REPLACE);
|
||||
新建图层()
|
||||
app.activeDocument.selection.select(selRegion, SelectionType.REPLACE);
|
||||
|
||||
var c = new SolidColor();
|
||||
c.rgb.hexValue = "FFFFFF";
|
||||
app.activeDocument.selection.fill(c);
|
||||
后移一层()
|
||||
app.activeDocument.activeLayer = 当前花样图层;
|
||||
切换mask()
|
||||
载入选区()
|
||||
删除图层蒙版()
|
||||
创建剪贴蒙版()
|
||||
向下合并()
|
||||
新建文档()
|
||||
当前花样图层 = app.activeDocument.activeLayer
|
||||
app.activeDocument.crop( 当前花样图层.bounds, 0);
|
||||
var 文件路径 = 导出目录 + "/" + layerName + ".tif";
|
||||
tiffOptions = new TiffSaveOptions();
|
||||
app.activeDocument.saveAs(new File(文件路径), tiffOptions);
|
||||
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
|
||||
app.activeDocument=currentDocument
|
||||
转换为智能对象()
|
||||
重新链接到文件(文件路径)
|
||||
添加图层蒙版()
|
||||
//当前图层=app.activeDocument.activeLayer
|
||||
//当前图层.name=layerName
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 新建文档() //复制图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("document"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("using"), r1);
|
||||
d.putInteger(stringIDToTypeID("version"), 5);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
function 转换为智能对象() //转换为智能对象
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("newPlacedLayer"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 重新链接到文件(文件路径) //重新链接到文件
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putPath(stringIDToTypeID("null"), new File(文件路径));
|
||||
d.putInteger(stringIDToTypeID("layerID"), 94);
|
||||
executeAction(stringIDToTypeID("placedLayerRelinkToFile"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 切换mask() //取消选择
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 毫米转像素(毫米, 每英寸像素数) {
|
||||
var 每英寸毫米数 = 25.4;
|
||||
var 英寸 = 毫米 / 每英寸毫米数;
|
||||
return Math.round(英寸 * 每英寸像素数);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 画布大小() //画布大小
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putBoolean(stringIDToTypeID("relative"), true);
|
||||
d.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("distanceUnit"), 850.56);
|
||||
d.putUnitDouble(stringIDToTypeID("height"), stringIDToTypeID("distanceUnit"), 850.56);
|
||||
d.putEnumerated(stringIDToTypeID("horizontal"), stringIDToTypeID("horizontalLocation"), stringIDToTypeID("center"));
|
||||
d.putEnumerated(stringIDToTypeID("vertical"), stringIDToTypeID("verticalLocation"), stringIDToTypeID("center"));
|
||||
executeAction(stringIDToTypeID("canvasSize"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 载入选区() //载入选区
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 获取当前选区四边距() {
|
||||
var currentDocument = app.activeDocument;
|
||||
var selectionBounds = currentDocument.selection.bounds;
|
||||
|
||||
var top = selectionBounds[1].value;
|
||||
var left = selectionBounds[0].value;
|
||||
var bottom = selectionBounds[3].value;
|
||||
var right = selectionBounds[2].value;
|
||||
|
||||
return {
|
||||
top: top,
|
||||
left: left,
|
||||
bottom: bottom,
|
||||
right: right
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 新建图层() //新建图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("layer"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putInteger(stringIDToTypeID("layerID"), 135);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 后移一层() //后移一层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("previous"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("move"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 删除图层蒙版() //删除图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 载入选区() //载入选区
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 删除图层蒙版() //删除图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 向下合并() //向下合并
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("mergeLayersNew"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 添加图层蒙版() //添加图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("at"), r);
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("userMaskEnabled"), stringIDToTypeID("revealSelection"));
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 创建剪贴蒙版() //创建剪贴蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("groupEvent"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
554
psmark/JSX16.py
Normal file
554
psmark/JSX16.py
Normal file
@@ -0,0 +1,554 @@
|
||||
dxf16_jscode = """
|
||||
|
||||
|
||||
|
||||
function 快速定位码链接() {
|
||||
|
||||
app.activeDocument.suspendHistory("快速定位码链接", "花样图层导出()");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 花样图层导出() {
|
||||
var 导出目录 = Folder.selectDialog("选择外链素材目录");
|
||||
if (!导出目录) {
|
||||
alert("未选择导出目录。操作已取消。");
|
||||
return;
|
||||
}
|
||||
花样图层导出为TIF透明底(导出目录)
|
||||
// 花样图层导出为TIF(导出目录);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 花样图层导出为TIF透明底(导出目录) {
|
||||
|
||||
app.preferences.rulerUnits = Units.MM;
|
||||
var doc = app.activeDocument;
|
||||
var 扩展毫米数=80
|
||||
|
||||
// 获取文档中的所有图层
|
||||
var allLayers = doc.layers;
|
||||
|
||||
// 循环遍历所有图层
|
||||
for (var i = 0; i < allLayers.length; i++) {
|
||||
// 检查图层是否是图层组
|
||||
if (allLayers[i] instanceof LayerSet) {
|
||||
// 获取图层组中的所有子图层
|
||||
subLayers = allLayers[i].layers;
|
||||
图层组名称=allLayers[i].name
|
||||
文档名称=app.activeDocument.name
|
||||
文档名称去除后缀 = 文档名称.replace(/\.[^\.]+$/, "");
|
||||
// 检查图层组是否包含子图层
|
||||
if (subLayers.length > 0) {
|
||||
// 获取图层组中最后一个子图层的名称
|
||||
var lastSubLayer = subLayers[subLayers.length - 1];
|
||||
var lastSubLayerName = lastSubLayer.name;
|
||||
var lastSubLayerName = lastSubLayer.name;
|
||||
FastSubLayer = subLayers[0];
|
||||
FastSubLayername= FastSubLayer.name
|
||||
|
||||
//alert(SastSubLayerName)
|
||||
// 输出图层组名称和最后一个子图层的名称
|
||||
|
||||
|
||||
if (图层组名称 === "填充底图") {
|
||||
填充底图裁片模板 = app.activeDocument.layerSets.getByName("填充底图")
|
||||
app.activeDocument.activeLayer = 填充底图裁片模板;
|
||||
新建文档()
|
||||
合并图层()
|
||||
载入选区()
|
||||
裁剪()
|
||||
名称=文档名称去除后缀 +"-填充底图"
|
||||
制作图案预设(名称)
|
||||
var 文件路径 = 导出目录 + "/" + 文档名称去除后缀 +"-填充底图"+ ".tif";
|
||||
tiffOptions = new TiffSaveOptions();
|
||||
app.activeDocument.saveAs(new File(文件路径), tiffOptions);
|
||||
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
|
||||
app.activeDocument=doc
|
||||
// 执行某一个操作(例如,设置图层组的可见性)
|
||||
// alert("测试")
|
||||
} else {
|
||||
// 执行别的操作(例如,隐藏其他图层组)
|
||||
|
||||
|
||||
|
||||
空白裁片模板 = app.activeDocument.layerSets.getByName(图层组名称).layers.getByName(lastSubLayerName);
|
||||
app.activeDocument.activeLayer = 空白裁片模板;
|
||||
新建图层()
|
||||
app.activeDocument.activeLayer.name="最大白边值"
|
||||
裁片边界 = lastSubLayer.bounds;
|
||||
扩展值 = 毫米转像素(扩展毫米数); //50cm
|
||||
裁片边界_左 = 毫米转像素(裁片边界[0]) - 扩展值;
|
||||
|
||||
裁片边界_上 = 毫米转像素(裁片边界[1]) - 扩展值;
|
||||
裁片边界_右 = 毫米转像素(裁片边界[2]) + 扩展值;
|
||||
裁片边界_下 = 毫米转像素(裁片边界[3]) + 扩展值;
|
||||
|
||||
var selRegion = [
|
||||
[裁片边界_左,裁片边界_上],
|
||||
[裁片边界_右,裁片边界_上],
|
||||
[裁片边界_右,裁片边界_下],
|
||||
[裁片边界_左,裁片边界_下]
|
||||
];
|
||||
app.activeDocument.selection.select(selRegion, SelectionType.REPLACE);
|
||||
背景切换();
|
||||
恢复白底();
|
||||
填充();
|
||||
隐藏图层();
|
||||
裁片图层组 = app.activeDocument.layerSets.getByName(图层组名称)
|
||||
app.activeDocument.activeLayer = 裁片图层组 ;
|
||||
新建文档()
|
||||
空白裁片模板 = app.activeDocument.layerSets.getByName(图层组名称).layers.getByName(lastSubLayerName);
|
||||
app.activeDocument.activeLayer = 空白裁片模板;
|
||||
删除图层()
|
||||
最大白边值=app.activeDocument.layerSets.getByName(图层组名称).layers.getByName("最大白边值");
|
||||
app.activeDocument.activeLayer = 最大白边值;
|
||||
app.activeDocument.crop(最大白边值.bounds, 0);
|
||||
|
||||
// 保存为TIF
|
||||
var 文件路径 = 导出目录 + "/" + 图层组名称 + ".tif";
|
||||
tiffOptions = new TiffSaveOptions();
|
||||
app.activeDocument.saveAs(new File(文件路径), tiffOptions);
|
||||
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
|
||||
app.activeDocument=doc
|
||||
最大白边值=app.activeDocument.layerSets.getByName(图层组名称).layers.getByName(FastSubLayername);
|
||||
app.activeDocument.activeLayer = 最大白边值;
|
||||
//上移图层()
|
||||
多选图层()
|
||||
转换为智能对象()
|
||||
释放剪贴蒙版()
|
||||
栅格化图层()
|
||||
选择下一图层()
|
||||
新建图层()
|
||||
背景切换();
|
||||
恢复白底();
|
||||
填充();
|
||||
选择上一图层()
|
||||
添加图层蒙版()
|
||||
向下合并()
|
||||
转换为智能对象()
|
||||
重新链接到文件(文件路径)
|
||||
创建剪贴蒙版()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
function 恢复白底() //删除图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("color"), stringIDToTypeID("colors"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("exchange"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 创建剪贴蒙版() //创建剪贴蒙版
|
||||
|
||||
{
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("groupEvent"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 制作图案预设(名称) //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("pattern"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putProperty(stringIDToTypeID("property"), stringIDToTypeID("selection"));
|
||||
r1.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("using"), r1);
|
||||
d.putString(stringIDToTypeID("name"), 名称);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function mergeLayersNew_72799682617188() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("mergeLayersNew"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 合并图层() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("mergeLayersNew"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 背景切换() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("color"), stringIDToTypeID("colors"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("reset"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 图层可见性show() //图层可见性
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var list = new ActionList();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
list.putReference(r);
|
||||
d.putList(stringIDToTypeID("null"), list);
|
||||
executeAction(stringIDToTypeID("show"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 裁剪() //裁剪
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putBoolean(stringIDToTypeID("delete"), true);
|
||||
executeAction(stringIDToTypeID("crop"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 重新链接到文件(文件路径) //重新链接到文件
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putPath(stringIDToTypeID("null"), new File(文件路径));
|
||||
d.putInteger(stringIDToTypeID("layerID"), 94);
|
||||
executeAction(stringIDToTypeID("placedLayerRelinkToFile"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 转换为智能对象() //转换为智能对象
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("newPlacedLayer"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 载入选区() //载入选区
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 向下合并() //向下合并
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("mergeLayersNew"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 添加图层蒙版() //添加图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("at"), r);
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("userMaskEnabled"), stringIDToTypeID("revealSelection"));
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function 上移图层() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("forwardEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(11);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 毫米转像素(毫米)
|
||||
{
|
||||
//厘米转像素
|
||||
doc_w = app.activeDocument.width;
|
||||
//用户设定的厘米数 支持小数
|
||||
user_mm = UnitValue(毫米,"mm");
|
||||
user_px = user_mm.as("px")*app.activeDocument.resolution/72;
|
||||
return user_px;
|
||||
}
|
||||
|
||||
|
||||
function 删除图层() //删除图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var list = new ActionList();
|
||||
list.putInteger(22);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 多选图层(SastSubLayerName) //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putName(stringIDToTypeID("layer"), "最大白边值");
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("selectionModifier"), stringIDToTypeID("selectionModifierType"), stringIDToTypeID("addToSelectionContinuous"));
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
|
||||
list.putInteger(115);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
function 新建图层() //新建图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("layer"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putBoolean(stringIDToTypeID("group"), true);
|
||||
d.putObject(stringIDToTypeID("using"), stringIDToTypeID("layer"), d1);
|
||||
d.putInteger(stringIDToTypeID("layerID"), 22);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 释放剪贴蒙版() //释放剪贴蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("ungroup"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 添加图层蒙版() //添加图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("at"), r);
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("userMaskEnabled"), stringIDToTypeID("revealSelection"));
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 向下合并() //向下合并
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("mergeLayersNew"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 栅格化图层() //栅格化图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("rasterizeLayer"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 选择下一图层() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("backwardEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(314);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 选择上一图层() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("forwardEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(369);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
function 新建图层() //新建图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("layer"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putInteger(stringIDToTypeID("layerID"), 373);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 恢复白底() //删除图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("color"), stringIDToTypeID("colors"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("exchange"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 背景切换() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("color"), stringIDToTypeID("colors"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("reset"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 填充() //填充
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("fillContents"), stringIDToTypeID("foregroundColor"));
|
||||
d.putUnitDouble(stringIDToTypeID("opacity"), stringIDToTypeID("percentUnit"), 100);
|
||||
d.putEnumerated(stringIDToTypeID("mode"), stringIDToTypeID("blendMode"), stringIDToTypeID("normal"));
|
||||
executeAction(stringIDToTypeID("fill"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 填充() //填充
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("fillContents"), stringIDToTypeID("foregroundColor"));
|
||||
d.putUnitDouble(stringIDToTypeID("opacity"), stringIDToTypeID("percentUnit"), 100);
|
||||
d.putEnumerated(stringIDToTypeID("mode"), stringIDToTypeID("blendMode"), stringIDToTypeID("normal"));
|
||||
executeAction(stringIDToTypeID("fill"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
function 隐藏图层() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var list = new ActionList();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
list.putReference(r);
|
||||
d.putList(stringIDToTypeID("null"), list);
|
||||
executeAction(stringIDToTypeID("hide"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 新建文档() //复制图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("document"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("using"), r1);
|
||||
d.putInteger(stringIDToTypeID("version"), 5);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
906
psmark/JSX17.py
Normal file
906
psmark/JSX17.py
Normal file
@@ -0,0 +1,906 @@
|
||||
dxf17_jscode = """
|
||||
|
||||
function 定位码批量化替换外链新(){
|
||||
|
||||
var dialog = new Window("dialog");
|
||||
dialog.text = "定位码批量快速换图 ";
|
||||
dialog.orientation = "row";
|
||||
dialog.alignChildren = ["left","top"];
|
||||
dialog.spacing = 10;
|
||||
dialog.margins = 16;
|
||||
|
||||
// GROUP1
|
||||
// ======
|
||||
var group1 = dialog.add("group", undefined, {name: "group1"});
|
||||
group1.preferredSize.width = 183;
|
||||
group1.orientation = "column";
|
||||
group1.alignChildren = ["fill","top"];
|
||||
group1.spacing = 10;
|
||||
group1.margins = 0;
|
||||
|
||||
// PANEL1
|
||||
// ======
|
||||
var panel1 = group1.add("panel", undefined, undefined, {name: "panel1"});
|
||||
panel1.text = "文件夹选择";
|
||||
panel1.preferredSize.height = 205;
|
||||
panel1.orientation = "column";
|
||||
panel1.alignChildren = ["left","top"];
|
||||
panel1.spacing = 10;
|
||||
panel1.margins = 10;
|
||||
|
||||
var statictext1 = panel1.add("statictext", undefined, undefined, {name: "statictext1"});
|
||||
statictext1.text = "大货齐码裁片模板路径:";
|
||||
|
||||
var button1 = panel1.add("button", undefined, undefined, {name: "button1"});
|
||||
button1.text = "路径选择";
|
||||
button1.preferredSize.width = 300;
|
||||
|
||||
var statictext2 = panel1.add("statictext", undefined, undefined, {name: "statictext2"});
|
||||
statictext2.text = "待套花样路径选择:";
|
||||
|
||||
var button2 = panel1.add("button", undefined, undefined, {name: "button2"});
|
||||
button2.text = "路径选择";
|
||||
button2.preferredSize.width = 300;
|
||||
|
||||
|
||||
var statictext3 = panel1.add("statictext", undefined, undefined, {name: "statictext3"});
|
||||
statictext3.text = "缓存切片裁片路径选择:";
|
||||
|
||||
var button3 = panel1.add("button", undefined, undefined, {name: "button3"});
|
||||
button3.text = "路径选择";
|
||||
button3.preferredSize.width = 300;
|
||||
|
||||
var statictext4= panel1.add("statictext", undefined, undefined, {name: "statictext4"});
|
||||
statictext4.text = "大货成品路径选择:";
|
||||
|
||||
var button4 = panel1.add("button", undefined, undefined, {name: "button4"});
|
||||
button4.text = "路径选择";
|
||||
button4.preferredSize.width = 300;
|
||||
|
||||
// PANEL2
|
||||
// ======
|
||||
var panel2 = panel1.add("panel", undefined, undefined, {name: "panel2"});
|
||||
panel2.text = "款号修改:";
|
||||
panel2.orientation = "column";
|
||||
panel2.alignChildren = ["left","top"];
|
||||
panel2.spacing = 10;
|
||||
panel2.margins = 10;
|
||||
|
||||
|
||||
|
||||
// PANEL4
|
||||
// ======
|
||||
|
||||
|
||||
var statictext11 = panel2.add("statictext", undefined, undefined, {name: "statictext11"});
|
||||
statictext11.text = "是否拼合裁片组:";
|
||||
|
||||
var checkbox1 =panel2.add("checkbox", undefined, undefined, {name: "checkbox1"});
|
||||
checkbox1.value = true;
|
||||
checkbox1.text = "拼合";
|
||||
|
||||
|
||||
|
||||
var statictext13 = panel2.add("statictext", undefined, undefined, {name: "statictext13"});
|
||||
statictext13.text = "存储位置:";
|
||||
|
||||
var checkbox3 =panel2.add("checkbox", undefined, undefined, {name: "checkbox3"});
|
||||
checkbox3.value = false;
|
||||
checkbox3.text = "模板位置";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// GROUP2
|
||||
// ======
|
||||
var group2 = dialog.add("group", undefined, {name: "group2"});
|
||||
group2.orientation = "column";
|
||||
group2.alignChildren = ["fill","top"];
|
||||
group2.spacing = 10;
|
||||
group2.margins = 0;
|
||||
|
||||
var ok = group2.add("button", undefined, undefined, {name: "ok"});
|
||||
ok.text = "执行";
|
||||
|
||||
var cancel = group2.add("button", undefined, undefined, {name: "cancel"});
|
||||
cancel.text = "取消";
|
||||
|
||||
var button8 = group2.add("button", undefined, undefined, {name: "button8"});
|
||||
button8.text = "关于我们";
|
||||
|
||||
button1.onClick=function(){
|
||||
|
||||
button1.text =Folder.selectDialog ("大货齐码裁片模板路径:").fsName;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
button2.onClick=function(){
|
||||
|
||||
button2.text =Folder.selectDialog ("待套花样路径选择:").fsName;
|
||||
|
||||
}
|
||||
button3.onClick=function(){
|
||||
|
||||
button3.text =Folder.selectDialog ("缓存切片裁片路径选择:").fsName;
|
||||
|
||||
|
||||
}
|
||||
button4.onClick=function(){
|
||||
|
||||
button4.text =Folder.selectDialog ("大货成品路径选择:").fsName;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
button8.onClick = function () {
|
||||
|
||||
alert("自由花型工作室 17520145271 脚本开发 裁片排版 花型开发 ",dialog.text+"----关于我们");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ok .onClick=function(){
|
||||
|
||||
|
||||
var 大货齐码裁片模板路径 = new Folder(button1.text);
|
||||
var 待套花样路径选择 =new Folder(button2.text);
|
||||
var 大货文件存放位置 =new Folder(button4.text);
|
||||
var 缓存切片裁片路径选择 = new Folder(button3.text);
|
||||
|
||||
var myFiles1 =大货齐码裁片模板路径.getFiles("*.tif*");
|
||||
var myFiles2 =待套花样路径选择.getFiles("*.tif*");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (var i = 0; i <myFiles2.length; i++)
|
||||
{
|
||||
|
||||
app.open(myFiles2[i])
|
||||
文档名称1=activeDocument.name.replace(/(?:\.[^.]*$|$)/, '');
|
||||
var 大货成品文件夹 =文档名称1
|
||||
//花样标准化(80);
|
||||
// 文档另存(缓存切片裁片路径选择);
|
||||
花样图层导出为TIF透明底(缓存切片裁片路径选择)
|
||||
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES)
|
||||
|
||||
|
||||
var parentFolderPath =大货文件存放位置
|
||||
var folderNames = 文档名称1
|
||||
|
||||
var folderPath = parentFolderPath + "/" + 文档名称1;
|
||||
var folderObj = new Folder(folderPath);
|
||||
$.writeln(folderObj);
|
||||
folderObj.create();
|
||||
|
||||
|
||||
for (var j = 0; j <myFiles1.length; j++) {
|
||||
app.open(myFiles1[j])
|
||||
|
||||
|
||||
更换当前文档裁片组外链(缓存切片裁片路径选择);
|
||||
图层选择();
|
||||
app.activeDocument.activeLayer.textItem.contents = 文档名称1;
|
||||
选择裁片图层();
|
||||
|
||||
// if (checkbox1.value == true) {
|
||||
合并图层();
|
||||
try {
|
||||
素材填充=app.activeDocument.layers.getByName("填充底图");
|
||||
app.activeDocument.activeLayer = 素材填充;
|
||||
载入选区()
|
||||
图案名称=文档名称1+"-填充底图"
|
||||
填充图案(图案名称)
|
||||
} catch (e) {
|
||||
// 捕获异常并输出错误信息
|
||||
//alert("发生错误: " + e.message);
|
||||
}
|
||||
|
||||
|
||||
另存为(folderObj,文档名称1)
|
||||
|
||||
|
||||
|
||||
|
||||
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 载入选区() //载入选区
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 填充图案(图案名称) //新建图案填充图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("contentLayer"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
var d2 = new ActionDescriptor();
|
||||
var d3 = new ActionDescriptor();
|
||||
d3.putString(stringIDToTypeID("name"), 图案名称);
|
||||
d3.putString(stringIDToTypeID("ID"), 图案名称);
|
||||
d2.putObject(stringIDToTypeID("pattern"), stringIDToTypeID("pattern"), d3);
|
||||
d1.putObject(stringIDToTypeID("type"), stringIDToTypeID("patternLayer"), d2);
|
||||
d.putObject(stringIDToTypeID("using"), stringIDToTypeID("contentLayer"), d1);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 花样图层导出为TIF透明底(导出目录) {
|
||||
|
||||
app.preferences.rulerUnits = Units.MM;
|
||||
var doc = app.activeDocument;
|
||||
var 扩展毫米数=80
|
||||
|
||||
// 获取文档中的所有图层
|
||||
var allLayers = doc.layers;
|
||||
|
||||
// 循环遍历所有图层
|
||||
for (var i = 0; i < allLayers.length; i++) {
|
||||
// 检查图层是否是图层组
|
||||
if (allLayers[i] instanceof LayerSet) {
|
||||
// 获取图层组中的所有子图层
|
||||
subLayers = allLayers[i].layers;
|
||||
图层组名称=allLayers[i].name
|
||||
文档名称=app.activeDocument.name
|
||||
文档名称去除后缀 = 文档名称.replace(/\.[^\.]+$/, "");
|
||||
// 检查图层组是否包含子图层
|
||||
if (subLayers.length > 0) {
|
||||
// 获取图层组中最后一个子图层的名称
|
||||
var lastSubLayer = subLayers[subLayers.length - 1];
|
||||
var lastSubLayerName = lastSubLayer.name;
|
||||
FastSubLayer = subLayers[0];
|
||||
FastSubLayername= FastSubLayer.name
|
||||
// 输出图层组名称和最后一个子图层的名称
|
||||
|
||||
|
||||
if (图层组名称 === "填充底图") {
|
||||
填充底图裁片模板 = app.activeDocument.layerSets.getByName("填充底图")
|
||||
app.activeDocument.activeLayer = 填充底图裁片模板;
|
||||
新建文档()
|
||||
合并图层()
|
||||
载入选区()
|
||||
裁剪()
|
||||
名称=文档名称去除后缀 +"-填充底图"
|
||||
制作图案预设(名称)
|
||||
var 文件路径 = 导出目录 + "/" + 文档名称去除后缀 +"-填充底图"+ ".tif";
|
||||
tiffOptions = new TiffSaveOptions();
|
||||
app.activeDocument.saveAs(new File(文件路径), tiffOptions);
|
||||
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
|
||||
app.activeDocument=doc
|
||||
// 执行某一个操作(例如,设置图层组的可见性)
|
||||
// alert("测试")
|
||||
} else {
|
||||
// 执行别的操作(例如,隐藏其他图层组)
|
||||
|
||||
|
||||
|
||||
空白裁片模板 = app.activeDocument.layerSets.getByName(图层组名称).layers.getByName(lastSubLayerName);
|
||||
app.activeDocument.activeLayer = 空白裁片模板;
|
||||
新建图层()
|
||||
app.activeDocument.activeLayer.name="最大白边值"
|
||||
裁片边界 = lastSubLayer.bounds;
|
||||
扩展值 = 毫米转像素(扩展毫米数); //50cm
|
||||
裁片边界_左 = 毫米转像素(裁片边界[0]) - 扩展值;
|
||||
|
||||
裁片边界_上 = 毫米转像素(裁片边界[1]) - 扩展值;
|
||||
裁片边界_右 = 毫米转像素(裁片边界[2]) + 扩展值;
|
||||
裁片边界_下 = 毫米转像素(裁片边界[3]) + 扩展值;
|
||||
|
||||
var selRegion = [
|
||||
[裁片边界_左,裁片边界_上],
|
||||
[裁片边界_右,裁片边界_上],
|
||||
[裁片边界_右,裁片边界_下],
|
||||
[裁片边界_左,裁片边界_下]
|
||||
];
|
||||
app.activeDocument.selection.select(selRegion, SelectionType.REPLACE);
|
||||
背景切换();
|
||||
恢复白底();
|
||||
填充();
|
||||
隐藏图层();
|
||||
裁片图层组 = app.activeDocument.layerSets.getByName(图层组名称)
|
||||
app.activeDocument.activeLayer = 裁片图层组 ;
|
||||
新建文档()
|
||||
空白裁片模板 = app.activeDocument.layerSets.getByName(图层组名称).layers.getByName(lastSubLayerName);
|
||||
app.activeDocument.activeLayer = 空白裁片模板;
|
||||
删除图层()
|
||||
最大白边值=app.activeDocument.layerSets.getByName(图层组名称).layers.getByName("最大白边值");
|
||||
app.activeDocument.activeLayer = 最大白边值;
|
||||
app.activeDocument.crop(最大白边值.bounds, 0);
|
||||
// 保存为TIF
|
||||
var 文件路径 = 导出目录 + "/" + 图层组名称 + ".tif";
|
||||
tiffOptions = new TiffSaveOptions();
|
||||
app.activeDocument.saveAs(new File(文件路径), tiffOptions);
|
||||
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
|
||||
app.activeDocument=doc
|
||||
最大白边值=app.activeDocument.layerSets.getByName(图层组名称).layers.getByName(FastSubLayername);
|
||||
app.activeDocument.activeLayer = 最大白边值;
|
||||
//上移图层()
|
||||
多选图层()
|
||||
转换为智能对象()
|
||||
添加图层蒙版()
|
||||
// 向下合并()
|
||||
转换为智能对象()
|
||||
// 重新链接到文件(文件路径)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
function 恢复白底() //删除图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("color"), stringIDToTypeID("colors"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("exchange"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 制作图案预设(名称) //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("pattern"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putProperty(stringIDToTypeID("property"), stringIDToTypeID("selection"));
|
||||
r1.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("using"), r1);
|
||||
d.putString(stringIDToTypeID("name"), 名称);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 合并图层() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("mergeLayersNew"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 背景切换() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("color"), stringIDToTypeID("colors"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("reset"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 裁剪() //裁剪
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putBoolean(stringIDToTypeID("delete"), true);
|
||||
executeAction(stringIDToTypeID("crop"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 重新链接到文件(文件路径) //重新链接到文件
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putPath(stringIDToTypeID("null"), new File(文件路径));
|
||||
d.putInteger(stringIDToTypeID("layerID"), 94);
|
||||
executeAction(stringIDToTypeID("placedLayerRelinkToFile"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 转换为智能对象() //转换为智能对象
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("newPlacedLayer"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 载入选区() //载入选区
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 向下合并() //向下合并
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("mergeLayersNew"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 添加图层蒙版() //添加图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("at"), r);
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("userMaskEnabled"), stringIDToTypeID("revealSelection"));
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function 上移图层() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("forwardEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(11);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 毫米转像素(毫米)
|
||||
{
|
||||
//厘米转像素
|
||||
doc_w = app.activeDocument.width;
|
||||
//用户设定的厘米数 支持小数
|
||||
user_mm = UnitValue(毫米,"mm");
|
||||
user_px = user_mm.as("px")*app.activeDocument.resolution/72;
|
||||
return user_px;
|
||||
}
|
||||
|
||||
|
||||
function 删除图层() //删除图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var list = new ActionList();
|
||||
list.putInteger(22);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 多选图层() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putName(stringIDToTypeID("layer"), "最大白边值");
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("selectionModifier"), stringIDToTypeID("selectionModifierType"), stringIDToTypeID("addToSelectionContinuous"));
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
|
||||
list.putInteger(115);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
function 新建图层() //新建图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("layer"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putBoolean(stringIDToTypeID("group"), true);
|
||||
d.putObject(stringIDToTypeID("using"), stringIDToTypeID("layer"), d1);
|
||||
d.putInteger(stringIDToTypeID("layerID"), 22);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 填充() //填充
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("fillContents"), stringIDToTypeID("foregroundColor"));
|
||||
d.putUnitDouble(stringIDToTypeID("opacity"), stringIDToTypeID("percentUnit"), 100);
|
||||
d.putEnumerated(stringIDToTypeID("mode"), stringIDToTypeID("blendMode"), stringIDToTypeID("normal"));
|
||||
executeAction(stringIDToTypeID("fill"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
function 隐藏图层() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var list = new ActionList();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
list.putReference(r);
|
||||
d.putList(stringIDToTypeID("null"), list);
|
||||
executeAction(stringIDToTypeID("hide"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 新建文档() //复制图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("document"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("using"), r1);
|
||||
d.putInteger(stringIDToTypeID("version"), 5);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 更换当前文档裁片组外链(缓存切片裁片路径选择)
|
||||
{
|
||||
try
|
||||
{
|
||||
裁片组 = app.activeDocument.layerSets.getByName("裁片").layers;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
alert("找不到裁片组");
|
||||
|
||||
}
|
||||
|
||||
for(var k=0;k<裁片组.length;k++)
|
||||
{
|
||||
裁片 = 裁片组[k];
|
||||
app.activeDocument.activeLayer = 裁片;
|
||||
if(裁片.kind == LayerKind.SMARTOBJECT)
|
||||
{
|
||||
更换链接智能对象路径(缓存切片裁片路径选择);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function 更换链接智能对象路径(缓存切片裁片路径选择)
|
||||
{
|
||||
//获取当前图层外链的智能对象路径
|
||||
//先获取链接的文件名
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
//~ r.putName(charIDToTypeID("Lyr "), "◆左袖口"); //按名称查找
|
||||
descLayer = executeActionGet(r);
|
||||
res = descLayer.getObjectValue(stringIDToTypeID("smartObject"));
|
||||
|
||||
链接文件名 = res.getString(stringIDToTypeID("fileReference"));
|
||||
//$.writeln(链接文件名);
|
||||
|
||||
//~ 链接文件路径 = res.getPath(stringIDToTypeID("link"));
|
||||
//~ $.writeln(链接文件路径);
|
||||
|
||||
图片路径 = 缓存切片裁片路径选择 + "/" + 链接文件名;
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putPath(stringIDToTypeID("null"), new File(图片路径));
|
||||
executeAction(stringIDToTypeID("placedLayerRelinkToFile"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 另存为(folderObj,文档名称1)
|
||||
{
|
||||
文档名称=activeDocument.name.replace(/(?:\.[^.]*$|$)/, '');
|
||||
saveIn=File(folderObj+ "/"+文档名称1+"-"+文档名称);
|
||||
tifSaveOpt = new TiffSaveOptions();
|
||||
tifSaveOpt.imageCompression = TIFFEncoding.TIFFLZW;
|
||||
tifSaveOpt.byteOrder = ByteOrder.IBM;
|
||||
asCopy=true
|
||||
app.activeDocument.saveAs(saveIn,tifSaveOpt,asCopy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 图层选择() //a
|
||||
{
|
||||
try {
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putName(stringIDToTypeID("layer"), "款号");
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(74);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
}
|
||||
catch (e) {
|
||||
alert("找不到款号图层",dialog.text+"----关于");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
function 合并图层() //合并图层
|
||||
{
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("mergeLayersNew"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 选择裁片图层() //
|
||||
{
|
||||
try {
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putName(stringIDToTypeID("layer"), "裁片");
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(74);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
}
|
||||
catch (e) {
|
||||
alert("找不到裁片图层",dialog.text+"----关于");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 存储在原来位置(myFolder)
|
||||
{
|
||||
tiffOptions = new TiffSaveOptions();
|
||||
|
||||
try
|
||||
{
|
||||
app.activeDocument.saveAs(new File(文件路径), tiffOptions);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
alert(文件太大无法保存)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function 花样标准化(扩展毫米数)
|
||||
{
|
||||
var 扩展毫米数=80
|
||||
app.preferences.rulerUnits = Units.MM;
|
||||
|
||||
裁片组 = app.activeDocument.layerSets;
|
||||
|
||||
for(var z=0;z<裁片组.length;z++)
|
||||
{
|
||||
当前裁片组 = 裁片组[z];
|
||||
花样图层 = 当前裁片组.layers[0];
|
||||
裁片图层 = 当前裁片组.layers[1];
|
||||
|
||||
裁片边界 = 裁片图层.bounds;
|
||||
//~ alert(毫米转像素(50))
|
||||
//~ 扩展值 = 毫米转像素(50); //50cm
|
||||
扩展值 = 毫米转像素(扩展毫米数); //50cm
|
||||
裁片边界_左 = 毫米转像素(裁片边界[0]) - 扩展值;
|
||||
裁片边界_上 = 毫米转像素(裁片边界[1]) - 扩展值;
|
||||
裁片边界_右 = 毫米转像素(裁片边界[2]) + 扩展值;
|
||||
裁片边界_下 = 毫米转像素(裁片边界[3]) + 扩展值;
|
||||
|
||||
|
||||
//左上右下点XY坐标
|
||||
var selRegion = [
|
||||
[裁片边界_左,裁片边界_上],
|
||||
[裁片边界_右,裁片边界_上],
|
||||
[裁片边界_右,裁片边界_下],
|
||||
[裁片边界_左,裁片边界_下]
|
||||
];
|
||||
|
||||
app.activeDocument.activeLayer = 花样图层;
|
||||
app.activeDocument.selection.select(selRegion, SelectionType.REPLACE);
|
||||
按选区添加蒙版();
|
||||
|
||||
//制作一个白底衬底图
|
||||
//新建一个图层
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("layer"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putInteger(stringIDToTypeID("layerID"), 198);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
白底图层 = app.activeDocument.activeLayer;
|
||||
白底图层.name = "白底";
|
||||
|
||||
app.activeDocument.selection.select(selRegion, SelectionType.REPLACE);
|
||||
|
||||
var c = new SolidColor();
|
||||
c.rgb.hexValue = "FFFFFF";
|
||||
app.activeDocument.selection.fill(c);
|
||||
|
||||
花样图层.grouped = false;
|
||||
白底图层.move(花样图层,ElementPlacement.PLACEAFTER);
|
||||
|
||||
|
||||
app.activeDocument.activeLayer = 花样图层;
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putName(stringIDToTypeID("layer"), "白底");
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("selectionModifier"), stringIDToTypeID("selectionModifierType"), stringIDToTypeID("addToSelectionContinuous"));
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
app.activeDocument.activeLayer.merge(); //合并当前选择图层
|
||||
app.activeDocument.activeLayer.grouped = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 毫米转像素(毫米)
|
||||
{
|
||||
//厘米转像素
|
||||
doc_w = app.activeDocument.width;
|
||||
//用户设定的厘米数 支持小数
|
||||
user_mm = UnitValue(毫米,"mm");
|
||||
user_px = user_mm.as("px")*app.activeDocument.resolution/72;
|
||||
return user_px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 按选区添加蒙版() //先创建出选区 然后按选区添加出一个蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("at"), r);
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("userMaskEnabled"), stringIDToTypeID("revealSelection"));
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 文档另存(缓存切片裁片路径选择){
|
||||
|
||||
var 导出目录 =缓存切片裁片路径选择;
|
||||
var 裁片组 = app.activeDocument.layerSets;
|
||||
|
||||
|
||||
|
||||
for(var i=0;i<裁片组.length;i++)
|
||||
{
|
||||
|
||||
app.activeDocument.duplicate("temp");
|
||||
|
||||
复制文档裁片组 = app.activeDocument.layerSets;
|
||||
当前裁片组 = 复制文档裁片组[i];
|
||||
当前裁片组名 = 当前裁片组.name;
|
||||
花样图层 = 当前裁片组.layers[0];
|
||||
裁片图层 = 当前裁片组.layers[1];
|
||||
|
||||
app.activeDocument.activeLayer = 花样图层;
|
||||
//把花样图层导出
|
||||
花样图层.grouped = false; //取消图层链接
|
||||
|
||||
仅当前图层可见();
|
||||
|
||||
//按花样图层大小裁剪文档
|
||||
app.activeDocument.crop(花样图层.bounds,0);
|
||||
|
||||
//拼合图像只保留花样图层
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("flattenImage"), d, DialogModes.NO);
|
||||
|
||||
//保存为TIF
|
||||
var 文件路径 = 导出目录 + "/" + 当前裁片组名 + ".tif";
|
||||
tiffOptions = new TiffSaveOptions();
|
||||
app.activeDocument.saveAs(new File(文件路径), tiffOptions);
|
||||
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 仅当前图层可见()
|
||||
{
|
||||
var d = new ActionDescriptor();
|
||||
var list = new ActionList();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
list.putReference(r);
|
||||
d.putList(stringIDToTypeID("null"), list);
|
||||
d.putBoolean(stringIDToTypeID("toggleOptionsPalette"), true);
|
||||
executeAction(stringIDToTypeID("show"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
dialog.show()
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
"""
|
||||
284
psmark/JSX18.py
Normal file
284
psmark/JSX18.py
Normal file
@@ -0,0 +1,284 @@
|
||||
dxf18_jscode = """
|
||||
|
||||
function 龙服的快速换图(){
|
||||
// 强制使用 UTF-8 编码
|
||||
#target photoshop
|
||||
$.localize = true;
|
||||
|
||||
// 创建对话框
|
||||
var dialog = new Window("dialog");
|
||||
dialog.text = "快速换图特定版本";
|
||||
dialog.orientation = "column";
|
||||
dialog.alignChildren = ["left","top"];
|
||||
dialog.spacing = 10;
|
||||
dialog.margins = 16;
|
||||
|
||||
// 大货模板文件夹选择面板
|
||||
var templatePanel = dialog.add("panel", undefined, "大货模板文件夹选择");
|
||||
templatePanel.orientation = "row";
|
||||
templatePanel.alignChildren = ["left","center"];
|
||||
templatePanel.spacing = 10;
|
||||
templatePanel.margins = 10;
|
||||
|
||||
// 大货模板文件夹路径文本框
|
||||
var templatePathEditText = templatePanel.add('edittext', undefined, '', { properties: { readonly: true } });
|
||||
templatePathEditText.preferredSize.width = 300;
|
||||
|
||||
// 大货模板路径选择按钮
|
||||
var selectTemplateButton = templatePanel.add("button", undefined, "选择文件夹");
|
||||
selectTemplateButton.onClick = function() {
|
||||
var selectedFolder = Folder.selectDialog("选择大货模板文件夹");
|
||||
if (selectedFolder != null) {
|
||||
templatePathEditText.text = selectedFolder.fsName;
|
||||
// alert( templatePathEditText.text)
|
||||
updateFileNames(selectedFolder);
|
||||
}
|
||||
};
|
||||
|
||||
// 切片裁片文件夹选择面板
|
||||
var slicePanel = dialog.add("panel", undefined, "切片裁片文件夹选择");
|
||||
slicePanel.orientation = "row";
|
||||
slicePanel.alignChildren = ["left","center"];
|
||||
slicePanel.spacing = 10;
|
||||
slicePanel.margins = 10;
|
||||
|
||||
// 切片裁片文件夹路径文本框
|
||||
var slicePathEditText = slicePanel.add('edittext', undefined, '', { properties: { readonly: true } });
|
||||
slicePathEditText.preferredSize.width = 300;
|
||||
|
||||
// 切片裁片路径选择按钮
|
||||
var selectSliceButton = slicePanel.add("button", undefined, "选择文件夹");
|
||||
selectSliceButton.onClick = function() {
|
||||
var selectedFolder = Folder.selectDialog("选择切片裁片文件夹");
|
||||
if (selectedFolder != null) {
|
||||
slicePathEditText.text = selectedFolder.fsName;
|
||||
// 可以在这里执行切片裁片相关的操作
|
||||
}
|
||||
};
|
||||
|
||||
// 大货裁片名称面板
|
||||
var fileNamesPanel = dialog.add("panel", undefined, "大货裁片名称数量");
|
||||
fileNamesPanel.orientation = "column";
|
||||
fileNamesPanel.alignChildren = ["left","top"];
|
||||
fileNamesPanel.spacing = 10;
|
||||
fileNamesPanel.margins = 10;
|
||||
|
||||
// 存储文件名和输入框内容的数组
|
||||
var userInputData = [];
|
||||
|
||||
// 更新文件名和输入框显示
|
||||
function updateFileNames(folder) {
|
||||
// 移除之前的所有元素
|
||||
for (var i = fileNamesPanel.children.length - 1; i >= 0; i--) {
|
||||
fileNamesPanel.children[i].remove();
|
||||
}
|
||||
|
||||
// 清空数组
|
||||
userInputData = [];
|
||||
|
||||
var files = folder.getFiles();
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
// 使用正则表达式提取文件名(去掉路径和后缀)
|
||||
完整文件路径=files[i].fsName
|
||||
var fileName = new File(files[i]).name.replace(/\.\w+$/, "");
|
||||
|
||||
// 创建新的静态文本框
|
||||
var fileNameStaticText = fileNamesPanel.add('statictext', undefined, fileName);
|
||||
fileNameStaticText.preferredSize.width = 200;
|
||||
|
||||
// 创建新的输入框
|
||||
var inputEditText = fileNamesPanel.add('edittext', undefined, '');
|
||||
inputEditText.preferredSize.width = 100;
|
||||
|
||||
// 存储文件名和输入框内容
|
||||
userInputData.push({
|
||||
fileName: fileName,
|
||||
inputText: ''
|
||||
});
|
||||
}
|
||||
|
||||
// 重新绘制对话框
|
||||
dialog.layout.layout(true);
|
||||
dialog.layout.resize();
|
||||
}
|
||||
|
||||
// OK 和 Cancel 按钮
|
||||
var buttonsGroup = dialog.add("group");
|
||||
buttonsGroup.orientation = "row";
|
||||
buttonsGroup.alignChildren = ["fill","top"];
|
||||
buttonsGroup.spacing = 10;
|
||||
buttonsGroup.margins = 0;
|
||||
|
||||
var okButton = buttonsGroup.add("button", undefined, "执行");
|
||||
okButton.onClick = function() {
|
||||
// 在这里执行 OK 按钮的操作
|
||||
updateUserData();
|
||||
alertUserInput();
|
||||
dialog.close();
|
||||
};
|
||||
|
||||
var cancelButton = buttonsGroup.add("button", undefined, "取消");
|
||||
cancelButton.onClick = function() {
|
||||
// 在这里执行 Cancel 按钮的操作
|
||||
dialog.close();
|
||||
};
|
||||
|
||||
// 显示对话框
|
||||
dialog.show();
|
||||
|
||||
// 更新用户输入数据
|
||||
function updateUserData() {
|
||||
for (var i = 1; i < fileNamesPanel.children.length; i += 2) {
|
||||
userInputData[(i - 1) / 2].inputText = fileNamesPanel.children[i].text;
|
||||
}
|
||||
}
|
||||
// 弹出用户输入的内容
|
||||
function alertUserInput() {
|
||||
var userInput = "";
|
||||
for (var i = 0; i < userInputData.length; i++) {
|
||||
var 文件路径=templatePathEditText.text
|
||||
var 文件名=userInputData[i].fileName
|
||||
var 完整文件路径=文件路径+"/"+文件名+".tif"
|
||||
// alert( 完整文件路径)
|
||||
var 文件数量= userInputData[i].inputText
|
||||
var 文件夹路径=slicePathEditText.text
|
||||
var 文件对象 = new File(完整文件路径);
|
||||
if (文件对象.exists) {
|
||||
app.open(文件对象);
|
||||
} else {
|
||||
//alert("文件不存在:" + 完整文件路径);
|
||||
}
|
||||
|
||||
更换当前文档裁片组外链(文件夹路径)
|
||||
图层选择()
|
||||
activeDocument.activeLayer.textItem.contents=文件数量
|
||||
选择裁片图层()
|
||||
合并图层()
|
||||
另存为(文件夹路径)
|
||||
|
||||
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
alert("换图完成,请检查好文件进行打印大货!!!",dialog.text+"----关于");
|
||||
|
||||
dialog.close();
|
||||
|
||||
|
||||
|
||||
function 另存为(文件夹路径)
|
||||
{
|
||||
文档名称=activeDocument.name.replace(/(?:\.[^.]*$|$)/, '');
|
||||
saveIn=File(文件夹路径+ "/"+文档名称);
|
||||
tifSaveOpt = new TiffSaveOptions();
|
||||
tifSaveOpt.imageCompression = TIFFEncoding.TIFFLZW;
|
||||
tifSaveOpt.byteOrder = ByteOrder.IBM;
|
||||
asCopy=true
|
||||
app.activeDocument.saveAs(saveIn,tifSaveOpt,asCopy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 选择裁片图层() //
|
||||
{
|
||||
try {
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putName(stringIDToTypeID("layer"), "裁片");
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(74);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
}
|
||||
catch (e) {
|
||||
alert("找不到裁片图层",dialog.text+"----关于");
|
||||
|
||||
}
|
||||
}
|
||||
function 合并图层() //合并图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("mergeLayersNew"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
function 更换当前文档裁片组外链(文件夹路径)
|
||||
{
|
||||
try
|
||||
{
|
||||
裁片组 = app.activeDocument.layerSets.getByName("裁片").layers;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
alert("找不到裁片组",dialog.text+"----提示");
|
||||
|
||||
}
|
||||
|
||||
for(var i=0;i<裁片组.length;i++)
|
||||
{
|
||||
裁片 = 裁片组[i];
|
||||
app.activeDocument.activeLayer = 裁片;
|
||||
if(裁片.kind == LayerKind.SMARTOBJECT)
|
||||
{
|
||||
更换链接智能对象路径(文件夹路径);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function 更换链接智能对象路径(文件夹路径)
|
||||
{
|
||||
//获取当前图层外链的智能对象路径
|
||||
//先获取链接的文件名
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
//~ r.putName(charIDToTypeID("Lyr "), "◆左袖口"); //按名称查找
|
||||
descLayer = executeActionGet(r);
|
||||
res = descLayer.getObjectValue(stringIDToTypeID("smartObject"));
|
||||
|
||||
链接文件名 = res.getString(stringIDToTypeID("fileReference"));
|
||||
//$.writeln(链接文件名);
|
||||
|
||||
//~ 链接文件路径 = res.getPath(stringIDToTypeID("link"));
|
||||
//~ $.writeln(链接文件路径);
|
||||
|
||||
图片路径 = 文件夹路径 + "/" + 链接文件名;
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putPath(stringIDToTypeID("null"), new File(图片路径));
|
||||
executeAction(stringIDToTypeID("placedLayerRelinkToFile"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 图层选择() //
|
||||
{
|
||||
try {
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putName(stringIDToTypeID("layer"), "数量");
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(74);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
}
|
||||
catch (e) {
|
||||
alert("找不到数量图层",dialog.text+"----关于");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
"""
|
||||
166
psmark/JSX19.py
Normal file
166
psmark/JSX19.py
Normal file
@@ -0,0 +1,166 @@
|
||||
dxf19_jscode = """
|
||||
|
||||
// 文件夹路径
|
||||
|
||||
function 裁片抓取新的() {
|
||||
app.activeDocument.suspendHistory("裁片抓取", "置入对象()");
|
||||
}
|
||||
|
||||
function 置入对象() {
|
||||
var folderPath = "D:/MarkTemp/Pdfmarktemp";
|
||||
|
||||
|
||||
var folder = new Folder(folderPath);
|
||||
|
||||
// 获取文件夹中的文件
|
||||
var files = folder.getFiles();
|
||||
|
||||
// 新建一个数组来存储文件名称
|
||||
var fileNamesArray = [];
|
||||
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
if (files[i] instanceof File) {
|
||||
var doc = app.activeDocument;
|
||||
var fileName = files[i].name;
|
||||
var newDocumentName = fileName.replace(/\.pdf$/, '');
|
||||
var modifiedString = newDocumentName.replace(/-\d+_\d+/, '');
|
||||
var newmodifiedString = modifiedString.split("-");
|
||||
|
||||
// 检查是否存在相同的文件名
|
||||
var duplicate = false;
|
||||
for (var j = 0; j < fileNamesArray.length; j++) {
|
||||
if (fileNamesArray[j] === modifiedString) {
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (duplicate) {
|
||||
$.writeln("文件名重复,跳过: " + fileName);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 将新的文档名添加到文件名数组中
|
||||
fileNamesArray.push(modifiedString);
|
||||
$.writeln("文档名称: " + fileName);
|
||||
|
||||
var 文件路径 = folderPath + "/" + fileName;
|
||||
|
||||
// 调用你的函数
|
||||
var match = newDocumentName.match(/_(\d+)/);
|
||||
var 角度信息 = match ? match[1] : "";
|
||||
|
||||
if (角度信息 === "180" || 角度信息 === "-180") {
|
||||
置入对象180度(文件路径);
|
||||
} else {
|
||||
// 如果角度信息不是 "180" 或 "-180",执行默认逻辑
|
||||
置入对象0度(文件路径);
|
||||
}
|
||||
|
||||
var extractedPart = newmodifiedString[0];
|
||||
var 大货裁片组名 = extractedPart + "-大货裁片";
|
||||
|
||||
// var 当前花样图层 = app.activeDocument.layers.getByName(newDocumentName);
|
||||
// app.activeDocument.activeLayer = 当前花样图层;
|
||||
|
||||
var 大货裁片组;
|
||||
try {
|
||||
大货裁片组 = app.activeDocument.layerSets.getByName(大货裁片组名);
|
||||
} catch (e) {
|
||||
大货裁片组 = app.activeDocument.layerSets.add();
|
||||
大货裁片组.name = 大货裁片组名;
|
||||
}
|
||||
|
||||
// 将当前图层移动到大货裁片图层组内
|
||||
app.activeDocument.activeLayer.move(大货裁片组, ElementPlacement.INSIDE);
|
||||
栅格化图层智能对象();
|
||||
// modifiedString = fileName.replace(/-\d+_\d+/, '');
|
||||
app.activeDocument.activeLayer.name = modifiedString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function 栅格化图层智能对象() {
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("rasterizeLayer"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 栅格化图层智能对象() //栅格化图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("rasterizeLayer"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 置入对象0度(文件路径)
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putEnumerated(stringIDToTypeID("selection"), stringIDToTypeID("pdfSelection"), stringIDToTypeID("page"));
|
||||
d1.putInteger(stringIDToTypeID("pageNumber"), 1);
|
||||
d1.putEnumerated(stringIDToTypeID("crop"), stringIDToTypeID("cropTo"), stringIDToTypeID("boundingBox"));
|
||||
d1.putBoolean(stringIDToTypeID("suppressWarnings"), false);
|
||||
d1.putBoolean(stringIDToTypeID("antiAlias"), true);
|
||||
d1.putBoolean(stringIDToTypeID("clippingPath"), true);
|
||||
d.putObject(stringIDToTypeID("as"), stringIDToTypeID("PDFGenericFormat"), d1);
|
||||
d.putInteger(stringIDToTypeID("ID"), 4);
|
||||
d.putPath(stringIDToTypeID("null"), new File(文件路径));
|
||||
d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));
|
||||
var d2 = new ActionDescriptor();
|
||||
d2.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d2.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), d2);
|
||||
//d.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("percentUnit"), -100);
|
||||
// d.putUnitDouble(stringIDToTypeID("height"), stringIDToTypeID("percentUnit"), -100);
|
||||
d.putBoolean(stringIDToTypeID("antiAlias"), false);
|
||||
executeAction(stringIDToTypeID("placeEvent"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 置入对象180度(文件路径)
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putEnumerated(stringIDToTypeID("selection"), stringIDToTypeID("pdfSelection"), stringIDToTypeID("page"));
|
||||
d1.putInteger(stringIDToTypeID("pageNumber"), 1);
|
||||
d1.putEnumerated(stringIDToTypeID("crop"), stringIDToTypeID("cropTo"), stringIDToTypeID("boundingBox"));
|
||||
d1.putBoolean(stringIDToTypeID("suppressWarnings"), false);
|
||||
d1.putBoolean(stringIDToTypeID("antiAlias"), true);
|
||||
d1.putBoolean(stringIDToTypeID("clippingPath"), true);
|
||||
d.putObject(stringIDToTypeID("as"), stringIDToTypeID("PDFGenericFormat"), d1);
|
||||
d.putInteger(stringIDToTypeID("ID"), 4);
|
||||
d.putPath(stringIDToTypeID("null"), new File(文件路径));
|
||||
d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));
|
||||
var d2 = new ActionDescriptor();
|
||||
d2.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d2.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), d2);
|
||||
d.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("percentUnit"), -100);
|
||||
d.putUnitDouble(stringIDToTypeID("height"), stringIDToTypeID("percentUnit"), -100);
|
||||
d.putBoolean(stringIDToTypeID("antiAlias"), false);
|
||||
executeAction(stringIDToTypeID("placeEvent"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
1910
psmark/JSX2.py
Normal file
1910
psmark/JSX2.py
Normal file
File diff suppressed because it is too large
Load Diff
136
psmark/JSX20.py
Normal file
136
psmark/JSX20.py
Normal file
@@ -0,0 +1,136 @@
|
||||
dxf20_jscode = """
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 混排通码延申导出() {
|
||||
var 主文档 = app.activeDocument;
|
||||
var 主文档路径 = 主文档.path;
|
||||
var 新文件夹 = (主文档路径 + "/小片裁片"); // 在桌面上创建一个名为"导出目录"的文件夹
|
||||
var 导出目录 = Folder(新文件夹);
|
||||
if (!导出目录.exists) {
|
||||
导出目录.create();
|
||||
}
|
||||
|
||||
var doc = app.activeDocument;
|
||||
|
||||
// 获取所有图层
|
||||
var layers = doc.layers;
|
||||
|
||||
// 存储符合条件的图层组
|
||||
var matchingLayerSets = [];
|
||||
|
||||
// 遍历每个图层
|
||||
for (var i = 0; i < layers.length; i++) {
|
||||
var layer = layers[i];
|
||||
|
||||
// 如果是图层组,检查名称是否包含 "大货裁片"
|
||||
if (layer.typename == "LayerSet" && layer.name.indexOf("大货裁片") !== -1) {
|
||||
matchingLayerSets.push(layer);
|
||||
|
||||
// 输出图层组名称
|
||||
$.writeln("图层组名称:" + layer.name);
|
||||
图层组名称=layer.name
|
||||
// 输出图层组内子图层的名称
|
||||
for (var j = 0; j < layer.layers.length; j++) {
|
||||
var subLayer = layer.layers[j];
|
||||
$.writeln(" 子图层名称:" + subLayer.name);
|
||||
子图层名称=subLayer.name
|
||||
子图层名称分割=子图层名称.split("-")
|
||||
素材图名称=子图层名称分割[0]
|
||||
空白裁片模板 = app.activeDocument.layerSets.getByName(图层组名称).layers.getByName(子图层名称);
|
||||
app.activeDocument.activeLayer = 空白裁片模板;
|
||||
载入选区()
|
||||
素材名称 = app.activeDocument.layers.getByName(素材图名称);
|
||||
app.activeDocument.activeLayer = 素材名称;
|
||||
添加图层蒙版()
|
||||
新建文档()
|
||||
当前花样图层 = app.activeDocument.activeLayer
|
||||
app.activeDocument.crop( 当前花样图层.bounds, 0);
|
||||
var 文件路径 = 导出目录 + "/" + 子图层名称 + ".tif";
|
||||
tiffOptions = new TiffSaveOptions();
|
||||
app.activeDocument.saveAs(new File(文件路径), tiffOptions);
|
||||
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
|
||||
app.activeDocument=doc
|
||||
|
||||
历史记录回退3()
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 输出符合条件的图层组数量
|
||||
//$.writeln("符合条件的图层组数量:" + matchingLayerSets.length);
|
||||
|
||||
}
|
||||
|
||||
function 载入选区() //载入选区
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 添加图层蒙版() //添加图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("at"), r);
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("userMaskEnabled"), stringIDToTypeID("revealSelection"));
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 新建文档() //复制图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("document"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("using"), r1);
|
||||
d.putInteger(stringIDToTypeID("version"), 5);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
function 历史记录回退3() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putOffset(stringIDToTypeID("historyState"), -2);
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
39
psmark/JSX21.py
Normal file
39
psmark/JSX21.py
Normal file
@@ -0,0 +1,39 @@
|
||||
dxf21_jscode = """
|
||||
|
||||
function 创建裁片排版文档(画布宽,画布高,分辨率,文档名称)
|
||||
{
|
||||
app.preferences.rulerUnits = Units.MM; //修改指定单位为毫米
|
||||
app.documents.add(画布宽, 画布高,分辨率, 文档名称, NewDocumentMode.CMYK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 置入链接的智能对象(dir, DXFname) {
|
||||
图片路径 = dir + "/" + DXFname + ".tif"
|
||||
var d = new ActionDescriptor();
|
||||
d.putInteger(stringIDToTypeID("ID"), 16);
|
||||
d.putPath(stringIDToTypeID("null"), new File(图片路径));
|
||||
d.putBoolean(stringIDToTypeID("linked"), true);
|
||||
d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));
|
||||
var d1 = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("placeEvent"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
function 裁片排版_lay(中心x_mm, 中心y_mm) {
|
||||
ps中心x_mm = 中心x_mm;
|
||||
ps中心y_mm = 中心y_mm;
|
||||
|
||||
alb = app.activeDocument.activeLayer.bounds;
|
||||
当前x = (alb[0] + alb[2]) / 2; //mm数
|
||||
当前y = (alb[1] + alb[3]) / 2; //mm数
|
||||
|
||||
app.activeDocument.activeLayer.translate(ps中心x_mm - Number(当前x), ps中心y_mm - Number(当前y)); //全局单位设置为mm即可
|
||||
}
|
||||
|
||||
function 裁片角度(角度) {
|
||||
app.activeDocument.activeLayer.rotate(角度);
|
||||
//app.refresh()
|
||||
}
|
||||
|
||||
"""
|
||||
2203
psmark/JSX3.py
Normal file
2203
psmark/JSX3.py
Normal file
File diff suppressed because it is too large
Load Diff
1909
psmark/JSX4.py
Normal file
1909
psmark/JSX4.py
Normal file
File diff suppressed because it is too large
Load Diff
2468
psmark/JSX5.py
Normal file
2468
psmark/JSX5.py
Normal file
File diff suppressed because it is too large
Load Diff
778
psmark/JSX6.py
Normal file
778
psmark/JSX6.py
Normal file
@@ -0,0 +1,778 @@
|
||||
dxf6_jscode = """
|
||||
|
||||
|
||||
function 前景色修改() //取消选择
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("color"), stringIDToTypeID("foregroundColor"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putDouble(stringIDToTypeID("cyan"), 30);
|
||||
d1.putDouble(stringIDToTypeID("magenta"), 0);
|
||||
d1.putDouble(stringIDToTypeID("yellowColor"), 0);
|
||||
d1.putDouble(stringIDToTypeID("black"), 0);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("CMYKColorClass"), d1);
|
||||
d.putString(stringIDToTypeID("source"), "photoshopPicker");
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 图像切割2() {
|
||||
|
||||
app.activeDocument.suspendHistory("图像切割", "图像切割()");
|
||||
}
|
||||
|
||||
|
||||
function 图像切割() {
|
||||
画布大小()
|
||||
app.preferences.rulerUnits = Units.PIXELS
|
||||
var currentDocument = app.activeDocument;
|
||||
var matchCount = 0; // 匹配到的数值计数
|
||||
var existingPatternSet = false;
|
||||
var layerNames = []; // 保存匹配到的图层名称的数组
|
||||
|
||||
// 遍历图层
|
||||
for (var j = 0; j < currentDocument.layers.length; j++) {
|
||||
var layer = currentDocument.layers[j];
|
||||
var layerName = layer.name;
|
||||
|
||||
// 检查图层名称是否以P开头并且后面跟着数字
|
||||
if (/^P\d+$/.test(layerName)) {
|
||||
matchCount++;
|
||||
layerNames.push(layer); // 将匹配到的图层添加到数组中
|
||||
}
|
||||
}
|
||||
|
||||
// 输出匹配到的数值个数
|
||||
// $.writeln("匹配到的数值个数:" + matchCount);
|
||||
|
||||
// 遍历匹配到的图层名称
|
||||
for (var i = 0; i < layerNames.length; i++) {
|
||||
var layerName = layerNames[i].name;
|
||||
$.writeln("匹配到的图层名称:" + layerName);
|
||||
var 当前花样图层 = app.activeDocument.layers.getByName(layerName);
|
||||
app.activeDocument.activeLayer = 当前花样图层;
|
||||
切换mask()
|
||||
载入选区()
|
||||
var 边距 = 获取当前选区四边距();
|
||||
var 毫米 = 130;
|
||||
var 每英寸像素数 = app.activeDocument.resolution; // 获取当前文档的分辨率(每英寸像素数)
|
||||
var 扩展像素 = 毫米转像素(毫米, 每英寸像素数);
|
||||
|
||||
var 裁切上边距= 边距.top-扩展像素
|
||||
var 裁切左边距= 边距.left-扩展像素
|
||||
var 裁切下边距= 边距.bottom+扩展像素
|
||||
var 裁切右边距= 边距.right+扩展像素
|
||||
|
||||
var selRegion = [
|
||||
[裁切左边距,裁切上边距],
|
||||
[裁切右边距,裁切上边距],
|
||||
[裁切右边距,裁切下边距],
|
||||
[裁切左边距,裁切下边距]
|
||||
];
|
||||
|
||||
app.activeDocument.selection.select(selRegion, SelectionType.REPLACE);
|
||||
新建图层()
|
||||
app.activeDocument.selection.select(selRegion, SelectionType.REPLACE);
|
||||
|
||||
var c = new SolidColor();
|
||||
c.rgb.hexValue = "FFFFFF";
|
||||
app.activeDocument.selection.fill(c);
|
||||
后移一层()
|
||||
app.activeDocument.activeLayer = 当前花样图层;
|
||||
切换mask()
|
||||
载入选区()
|
||||
删除图层蒙版()
|
||||
创建剪贴蒙版()
|
||||
向下合并()
|
||||
添加图层蒙版()
|
||||
当前图层=app.activeDocument.activeLayer
|
||||
当前图层.name=layerName
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 切换mask() //取消选择
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 毫米转像素(毫米, 每英寸像素数) {
|
||||
var 每英寸毫米数 = 25.4;
|
||||
var 英寸 = 毫米 / 每英寸毫米数;
|
||||
return Math.round(英寸 * 每英寸像素数);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 画布大小() //画布大小
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putBoolean(stringIDToTypeID("relative"), true);
|
||||
d.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("distanceUnit"), 850.56);
|
||||
d.putUnitDouble(stringIDToTypeID("height"), stringIDToTypeID("distanceUnit"), 850.56);
|
||||
d.putEnumerated(stringIDToTypeID("horizontal"), stringIDToTypeID("horizontalLocation"), stringIDToTypeID("center"));
|
||||
d.putEnumerated(stringIDToTypeID("vertical"), stringIDToTypeID("verticalLocation"), stringIDToTypeID("center"));
|
||||
executeAction(stringIDToTypeID("canvasSize"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 载入选区() //载入选区
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 获取当前选区四边距() {
|
||||
var currentDocument = app.activeDocument;
|
||||
var selectionBounds = currentDocument.selection.bounds;
|
||||
|
||||
var top = selectionBounds[1].value;
|
||||
var left = selectionBounds[0].value;
|
||||
var bottom = selectionBounds[3].value;
|
||||
var right = selectionBounds[2].value;
|
||||
|
||||
return {
|
||||
top: top,
|
||||
left: left,
|
||||
bottom: bottom,
|
||||
right: right
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 新建图层() //新建图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("layer"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putInteger(stringIDToTypeID("layerID"), 135);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 后移一层() //后移一层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("previous"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("move"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 删除图层蒙版() //删除图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 载入选区() //载入选区
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 删除图层蒙版() //删除图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 向下合并() //向下合并
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("mergeLayersNew"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 添加图层蒙版() //添加图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("at"), r);
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("userMaskEnabled"), stringIDToTypeID("revealSelection"));
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 创建剪贴蒙版() //创建剪贴蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("groupEvent"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 右下对齐2() {
|
||||
|
||||
app.activeDocument.suspendHistory("右下对齐", "右下对齐()");
|
||||
}
|
||||
|
||||
|
||||
function 右下对齐() {
|
||||
var groupName = 获取当前图层组名称();
|
||||
if (groupName !== null) {
|
||||
app.preferences.rulerUnits = Units.PIXELS;
|
||||
var splitGroupName = groupName.split("-");
|
||||
var firstPart = splitGroupName[0];
|
||||
} else {
|
||||
// 如果未获取到当前图层组名称,退出程序
|
||||
// alert("未获取到当前图层组名称!");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
当前花样图层 = app.activeDocument.layers.getByName(firstPart);
|
||||
} catch (e) {
|
||||
// 处理异常情况
|
||||
alert("没有找到对应的花样裁片: ");
|
||||
return; // 中断函数执行
|
||||
}
|
||||
|
||||
app.activeDocument.activeLayer = 当前花样图层;
|
||||
|
||||
切换mask();
|
||||
载入选区蒙版()
|
||||
// 应用图层蒙版();
|
||||
// 载入选区();
|
||||
|
||||
var 边距 = 获取当前选区四边距();
|
||||
var 获取左右的中心坐标 = (边距.right - 边距.left) / 2 + 边距.left;
|
||||
var 获取右上的坐标 = 边距.right
|
||||
$.writeln("中心坐标=:" + 获取左右的中心坐标);
|
||||
|
||||
var currentDocument = app.activeDocument;
|
||||
var height = currentDocument.height.value;
|
||||
|
||||
var 上边距新 = 0;
|
||||
var 左边距新 = 获取右上的坐标-1 ;
|
||||
var 下边距新 = height;
|
||||
var 右边距新 = 获取右上的坐标 + 1;
|
||||
|
||||
var 边距 = 获取当前选区四边距();
|
||||
$.writeln("上边距:" + 边距.top);
|
||||
$.writeln("左边距:" + 边距.left);
|
||||
$.writeln("下边距:" + 边距.bottom);
|
||||
$.writeln("右边距:" + 边距.right);
|
||||
|
||||
//历史记录回退领口函数();
|
||||
新建选区(上边距新, 左边距新, 下边距新, 右边距新);
|
||||
app.activeDocument.activeLayer = 当前花样图层;
|
||||
切换mask();
|
||||
选区减去();
|
||||
|
||||
获取右上的坐标 = 获取当前选区四边距();
|
||||
获取右上的坐标y坐标信息 = 获取右上的坐标.bottom; //////////////////////以上的是获取花样的的中心坐标信息
|
||||
|
||||
获取右上的坐标x坐标信息 = 获取右上的坐标.left;
|
||||
// $.writeln("居中领口y坐标信息" + 获取到花样图层当前居中领口y坐标信息);
|
||||
//$.writeln("居中领口x坐标信息" + 获取到花样图层当前居中领口x坐标信息);
|
||||
|
||||
//////////////////////以上的是获取花样的的中心坐标信息
|
||||
|
||||
|
||||
var currentDocument = app.activeDocument;
|
||||
var targetLayerSet = currentDocument.layerSets.getByName(groupName);
|
||||
|
||||
if (targetLayerSet) {
|
||||
var layers = targetLayerSet.layers;
|
||||
|
||||
if (layers.length > 0) {
|
||||
for (var i = 0; i < layers.length; i++) {
|
||||
var layer = layers[i];
|
||||
var 裁片图层 = layer.name;
|
||||
$.writeln("裁片图层坐标信息=" + 裁片图层);
|
||||
|
||||
try {
|
||||
var 当前裁片图层 = app.activeDocument.layerSets.getByName(groupName).layers.getByName(裁片图层);
|
||||
} catch (e) {
|
||||
// 处理异常情况
|
||||
alert("没有找到对应的花样裁片 " );
|
||||
return; // 中断函数执行
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
app.activeDocument.activeLayer = 当前裁片图层;
|
||||
载入选区11()
|
||||
//var selectedLayer = app.activeDocument.activeLayer;
|
||||
// var bounds = selectedLayer.bounds;
|
||||
/*
|
||||
图层上边距新 = 0;
|
||||
图层左边距新 = 右right ;
|
||||
图层下边距新 = height;
|
||||
图层右边距新 = 右right +1;
|
||||
|
||||
|
||||
左left = bounds[0].value;
|
||||
上top = bounds[1].value;
|
||||
右right = bounds[2].value;
|
||||
下bottom = bounds[3].value;
|
||||
中心坐标centerX = (bounds[2].value - bounds[0].value) / 2 + bounds[0].value;
|
||||
|
||||
中心坐标centerY = (bounds[3].value - bounds[1].value) / 2 + bounds[1].value;
|
||||
*/
|
||||
// $.writeln("中心坐标centerX" + 中心坐标centerX);
|
||||
// $.writeln("中心坐标centerY" +中心坐标cent*erY);
|
||||
|
||||
获取花样右上的坐标裁片位置坐标 = 获取当前选区四边距();
|
||||
|
||||
图层上边距新 = 0;
|
||||
图层左边距新 = 获取花样右上的坐标裁片位置坐标.right-1 ;
|
||||
图层下边距新 = height;
|
||||
图层右边距新 = 获取花样右上的坐标裁片位置坐标.right +1;
|
||||
|
||||
|
||||
新建选区(图层上边距新, 图层左边距新, 图层下边距新, 图层右边距新);
|
||||
app.activeDocument.activeLayer = 当前裁片图层;
|
||||
载入选区交叉图层()
|
||||
获取右上的坐标裁片位置坐标 = 获取当前选区四边距();
|
||||
获取右上的坐标裁片位置坐标x=获取右上的坐标裁片位置坐标.left
|
||||
获取右上的坐标裁片位置坐标y=获取右上的坐标裁片位置坐标.bottom
|
||||
|
||||
位移距离PXy = 获取右上的坐标y坐标信息 - 获取右上的坐标裁片位置坐标y;
|
||||
位移距离PXx = 获取右上的坐标x坐标信息 - 获取右上的坐标裁片位置坐标x;
|
||||
$.writeln(位移距离PXy);
|
||||
$.writeln(位移距离PXx);
|
||||
取消选择()
|
||||
自由变换2(位移距离PXy,位移距离PXx)
|
||||
//alert("移动")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
取消选择();
|
||||
}
|
||||
|
||||
function 获取当前图层组名称() {
|
||||
var currentDocument = app.activeDocument;
|
||||
var currentLayer = currentDocument.activeLayer;
|
||||
|
||||
if (currentLayer.typename === "LayerSet") {
|
||||
var groupName = currentLayer.name;
|
||||
return groupName;
|
||||
} else {
|
||||
alert("当前图层不是图层组。");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 载入选区交叉图层() //载入选区
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("with"), r1);
|
||||
executeAction(charIDToTypeID("Intr"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
function 载入选区蒙版() //载入选区
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 遍历图层组内的图层(图层组名称) {
|
||||
var currentDocument = app.activeDocument;
|
||||
var targetLayerSet = currentDocument.layerSets.getByName(图层组名称);
|
||||
|
||||
if (targetLayerSet) {
|
||||
var layers = targetLayerSet.layers;
|
||||
|
||||
if (layers.length > 0) {
|
||||
for (var i = 0; i < layers.length; i++) {
|
||||
var layer = layers[i];
|
||||
// 在这里对每个图层进行进一步的操作
|
||||
$.writeln("图层名称:" + layer.name);
|
||||
}
|
||||
} else {
|
||||
$.writeln("图层组中没有任何图层。");
|
||||
}
|
||||
} else {
|
||||
$.writeln("找不到指定名称的图层组。");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 新建选区(上边距, 左边距, 下边距, 右边距) {
|
||||
var currentDocument = app.activeDocument;
|
||||
var top = 上边距;
|
||||
var left = 左边距;
|
||||
var bottom = 下边距;
|
||||
var right = 右边距;
|
||||
|
||||
var selectionRegion = Array(Array(left, top), Array(right, top), Array(right, bottom), Array(left, bottom));
|
||||
currentDocument.selection.select(selectionRegion);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 选区减去() //载入选区
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("with"), r1);
|
||||
executeAction(charIDToTypeID("Intr"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 将像素转换为毫米
|
||||
function pixelsToMillimeters(pixels) {
|
||||
// 获取当前文档
|
||||
var doc = app.activeDocument;
|
||||
|
||||
// 获取图像的分辨率(像素/英寸)
|
||||
var resolution = doc.resolution;
|
||||
|
||||
// 计算像素转换为毫米
|
||||
var inches = pixels / resolution;
|
||||
var millimeters = inches * 25.4;
|
||||
|
||||
return millimeters.toFixed(2); // 保留两位小数
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 切换mask() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 获取当前选区四边距() {
|
||||
var currentDocument = app.activeDocument;
|
||||
var selectionBounds = currentDocument.selection.bounds;
|
||||
|
||||
var top = selectionBounds[1].value;
|
||||
var left = selectionBounds[0].value;
|
||||
var bottom = selectionBounds[3].value;
|
||||
var right = selectionBounds[2].value;
|
||||
|
||||
return {
|
||||
top: top,
|
||||
left: left,
|
||||
bottom: bottom,
|
||||
right: right
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function 获取当前文档四边距() {
|
||||
var currentDocument = app.activeDocument;
|
||||
var documentBounds = currentDocument.bounds;
|
||||
|
||||
var top = documentBounds[1].value;
|
||||
var left = documentBounds[0].value;
|
||||
var bottom = documentBounds[3].value;
|
||||
var right = documentBounds[2].value;
|
||||
|
||||
return {
|
||||
top: top,
|
||||
left: left,
|
||||
bottom: bottom,
|
||||
right: right
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function 选区减去2() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("with"), r1);
|
||||
executeAction(charIDToTypeID("Intr"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 遍历图层组内的图层(图层组名称) {
|
||||
var currentDocument = app.activeDocument;
|
||||
var targetLayerSet = currentDocument.layerSets.getByName(图层组名称);
|
||||
|
||||
if (targetLayerSet) {
|
||||
var layers = targetLayerSet.layers;
|
||||
|
||||
if (layers.length > 0) {
|
||||
for (var i = 0; i < layers.length; i++) {
|
||||
var layer = layers[i];
|
||||
// 在这里对每个图层进行进一步的操作
|
||||
$.writeln("图层名称:" + layer.name);
|
||||
}
|
||||
} else {
|
||||
$.writeln("图层组中没有任何图层。");
|
||||
}
|
||||
} else {
|
||||
$.writeln("找不到指定名称的图层组。");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function 自由变换2(位移距离PXy,位移距离PXx) //自由变换
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 位移距离PXx);
|
||||
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 位移距离PXy);
|
||||
d.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), d1);
|
||||
d.putBoolean(stringIDToTypeID("linked"), true);
|
||||
d.putEnumerated(charIDToTypeID("Intr"), stringIDToTypeID("interpolationType"), stringIDToTypeID("nearestNeighbor"));
|
||||
executeAction(stringIDToTypeID("transform"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function 历史记录回退领口函数() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putOffset(stringIDToTypeID("historyState"), -2 );
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
function 取消选择() //取消选择
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("to"), stringIDToTypeID("ordinal"), stringIDToTypeID("none"));
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 历史记录回退1领口函数() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putOffset(stringIDToTypeID("historyState"), -1 );
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function 载入选区11() //载入选区
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
function 取消选择() //取消选择
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("to"), stringIDToTypeID("ordinal"), stringIDToTypeID("none"));
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1628
psmark/JSX7.py
Normal file
1628
psmark/JSX7.py
Normal file
File diff suppressed because it is too large
Load Diff
1633
psmark/JSX8.py
Normal file
1633
psmark/JSX8.py
Normal file
File diff suppressed because it is too large
Load Diff
983
psmark/JSX9.py
Normal file
983
psmark/JSX9.py
Normal file
@@ -0,0 +1,983 @@
|
||||
dxf9_jscode = """
|
||||
|
||||
|
||||
function 裁片射出比例缩放按中心点() {
|
||||
app.preferences.rulerUnits = Units.PIXELS
|
||||
var 主文档 = app.activeDocument;
|
||||
var 主文档名称 = 主文档.name;
|
||||
|
||||
// 遍历当前打开的文档
|
||||
for (var i = 0; i < app.documents.length; i++) {
|
||||
var document = app.documents[i];
|
||||
var documentName = document.name;
|
||||
|
||||
// 判断文档名称是否与主文档名称不相同
|
||||
if (documentName !== 主文档名称) {
|
||||
app.activeDocument = document;
|
||||
遍历图层();
|
||||
}
|
||||
}
|
||||
|
||||
function 遍历图层() {
|
||||
var layerNames = []; // 用于存储图层名称的数组
|
||||
var currentDocument = app.activeDocument;
|
||||
|
||||
for (var j = 0; j < currentDocument.layers.length; j++) {
|
||||
var layer = currentDocument.layers[j];
|
||||
var layerName = layer.name;
|
||||
layerNames.push(layerName);
|
||||
}
|
||||
|
||||
// 逐个处理图层
|
||||
for (var k = 0; k < layerNames.length; k++) {
|
||||
var 当前图层名称 = layerNames[k];
|
||||
// $.writeln("图层名称:" + 当前图层名称);
|
||||
// alert(当前图层名称);
|
||||
|
||||
var parts = 当前图层名称.split("-");
|
||||
if (parts.length > 0) {
|
||||
var 裁片名称 = parts[0];
|
||||
app.activeDocument = 主文档;
|
||||
$.writeln(裁片名称);
|
||||
初始化模板裁片名称 = 当前图层名称.split("-");
|
||||
初始化码数裁片名称 = 当前图层名称.split("_");
|
||||
大货组名称 =初始化模板裁片名称[0]+("-大货裁片")
|
||||
实际裁片名称 = 初始化模板裁片名称[0]+"-"+初始化码数裁片名称[2]
|
||||
$.writeln(大货组名称);
|
||||
$.writeln(实际裁片名称);
|
||||
var 空白裁片模板 = app.activeDocument.layerSets.getByName(大货组名称).layers.getByName(实际裁片名称 );
|
||||
app.activeDocument.activeLayer = 空白裁片模板;
|
||||
载入选区()
|
||||
|
||||
var 边距 = 获取当前选区四边距();
|
||||
var 当前选区高度=边距.bottom-边距.top
|
||||
var 当前选区宽度=边距.right-边距.left
|
||||
var 高度转毫米 = pixelsToMillimeters(当前选区高度);
|
||||
var 宽度转毫米 = pixelsToMillimeters(当前选区宽度);
|
||||
|
||||
var 搜索词 = 裁片名称;
|
||||
var 匹配图层数组 = 匹配图层名(搜索词);
|
||||
|
||||
// 显示匹配的图层列表
|
||||
if (匹配图层数组.length > 0) {
|
||||
var 图层列表文本 = "匹配的图层列表:";
|
||||
for (var i = 0; i < 匹配图层数组.length; i++) {
|
||||
if (i !== 0) {
|
||||
图层列表文本 += " ";
|
||||
}
|
||||
图层列表文本 += 匹配图层数组[i].name;
|
||||
}
|
||||
var 数据解析分割=图层列表文本.split("_");
|
||||
//var 实际套花名称=名称部分[0]
|
||||
var 基码图层宽度 = parseFloat(数据解析分割[1]);
|
||||
var 基码图层高度 = parseFloat(数据解析分割[2]);
|
||||
var 缩放比例高度=高度转毫米/基码图层高度*100
|
||||
var 缩放比例宽度=宽度转毫米/基码图层宽度*100
|
||||
// alert(基码图层宽度);
|
||||
} else {
|
||||
alert("没有找到匹配的图层。");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
$.writeln("上边距:" + 边距.top);
|
||||
$.writeln("左边距:" + 边距.left);
|
||||
$.writeln("下边距:" + 边距.bottom);
|
||||
$.writeln("右边距:" + 边距.right);
|
||||
*/8
|
||||
// 示例用法:
|
||||
var 毫米 = 300;
|
||||
var 每英寸像素数 = app.activeDocument.resolution; // 获取当前文档的分辨率(每英寸像素数)
|
||||
var 扩展像素 = 毫米转像素(毫米, 每英寸像素数);
|
||||
|
||||
var 裁切上边距= 边距.top-扩展像素
|
||||
var 裁切左边距= 边距.left-扩展像素
|
||||
var 裁切下边距= 边距.bottom+扩展像素
|
||||
var 裁切右边距= 边距.right+扩展像素
|
||||
$.writeln(裁切上边距);
|
||||
$.writeln(裁切左边距);
|
||||
$.writeln(裁切下边距);
|
||||
$.writeln(裁切右边距);
|
||||
裁切图层(裁切上边距,裁切左边距,裁切下边距,裁切右边距)
|
||||
|
||||
var 空白裁片模板 = app.activeDocument.layerSets.getByName(大货组名称).layers.getByName(实际裁片名称 );
|
||||
app.activeDocument.activeLayer = 空白裁片模板;
|
||||
载入选区()
|
||||
var 缩放定位点的中心坐标=获取当前缩放定位点选区四边距()
|
||||
var 缩放定位点的Y轴坐标=缩放定位点的中心坐标.top2+(缩放定位点的中心坐标.bottom2-缩放定位点的中心坐标.top2)/2
|
||||
var 缩放定位点的X轴坐标=缩放定位点的中心坐标.left2+(缩放定位点的中心坐标.right2-缩放定位点的中心坐标.left2)/2
|
||||
$.writeln("Y轴中心坐标"+缩放定位点的Y轴坐标);
|
||||
$.writeln("X轴中心坐标"+缩放定位点的X轴坐标);
|
||||
|
||||
var 裁片 = app.activeDocument.layers.getByName(裁片名称);
|
||||
app.activeDocument.activeLayer = 裁片
|
||||
//var 空白裁片模板 = app.activeDocument.layerSets.getByName(大货组名称).layers.getByName(实际裁片名称 );
|
||||
//app.activeDocument.activeLayer = 空白裁片模板;
|
||||
取消选择()
|
||||
图层按照缩放定位点进行宽高缩放(缩放定位点的X轴坐标,缩放定位点的Y轴坐标, 缩放比例高度)
|
||||
|
||||
// var 裁片 = app.activeDocument.layers.getByName(裁片名称);
|
||||
// app.activeDocument.activeLayer = 裁片;
|
||||
|
||||
var 空白裁片模板 = app.activeDocument.layerSets.getByName(大货组名称).layers.getByName(实际裁片名称 );
|
||||
app.activeDocument.activeLayer = 空白裁片模板;
|
||||
载入选区()
|
||||
var 裁片 = app.activeDocument.layers.getByName(裁片名称);
|
||||
app.activeDocument.activeLayer = 裁片
|
||||
添加图层蒙版()
|
||||
应用图层蒙版()
|
||||
裁片.copy();
|
||||
历史记录回退()
|
||||
app.activeDocument = currentDocument;
|
||||
图层选择(当前图层名称);
|
||||
载入选区();
|
||||
粘贴图层();
|
||||
|
||||
取消选择();
|
||||
// app.refresh();
|
||||
|
||||
|
||||
var 裁片名称 = 当前图层名称.split("_");
|
||||
if (裁片名称.length > 1) {
|
||||
var 角度信息 = 裁片名称[1];
|
||||
|
||||
if (角度信息 === "180" || 角度信息 === "-180") {
|
||||
自由变换();
|
||||
} else if (角度信息 === "-90") {
|
||||
逆时针90旋转()
|
||||
|
||||
} else if (角度信息 === "90") {
|
||||
|
||||
顺时针90旋转()
|
||||
} else {
|
||||
// 如果以上条件都不满足,则执行默认的代码
|
||||
}
|
||||
|
||||
|
||||
|
||||
//历史记录回退缩放函数()
|
||||
}
|
||||
app.activeDocument = 主文档;
|
||||
历史记录回退缩放函数()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
app.activeDocument = currentDocument;
|
||||
烧花线添加()//alert("当前码拍好")///////////////////////////////////这里可以填写添加烧花线函数
|
||||
|
||||
}
|
||||
//alert("排版完成,请检查文件!!!")
|
||||
app.activeDocument = 主文档;
|
||||
}
|
||||
|
||||
|
||||
// 将像素转换为毫米
|
||||
function pixelsToMillimeters(pixels) {
|
||||
// 获取当前文档
|
||||
var doc = app.activeDocument;
|
||||
|
||||
// 获取图像的分辨率(像素/英寸)
|
||||
var resolution = doc.resolution;
|
||||
|
||||
// 计算像素转换为毫米
|
||||
var inches = pixels / resolution;
|
||||
var millimeters = inches * 25.4;
|
||||
|
||||
return millimeters.toFixed(2); // 保留两位小数
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 顺时针90旋转() //自由变换
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), d1);
|
||||
d.putUnitDouble(stringIDToTypeID("angle"), stringIDToTypeID("angleUnit"), 90);
|
||||
d.putBoolean(stringIDToTypeID("linked"), true);
|
||||
d.putEnumerated(charIDToTypeID("Intr"), stringIDToTypeID("interpolationType"), stringIDToTypeID("nearestNeighbor"));
|
||||
executeAction(stringIDToTypeID("transform"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 逆时针90旋转() //自由变换
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), d1);
|
||||
d.putUnitDouble(stringIDToTypeID("angle"), stringIDToTypeID("angleUnit"), -90);
|
||||
d.putBoolean(stringIDToTypeID("linked"), true);
|
||||
d.putEnumerated(charIDToTypeID("Intr"), stringIDToTypeID("interpolationType"), stringIDToTypeID("nearestNeighbor"));
|
||||
executeAction(stringIDToTypeID("transform"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 匹配图层名(搜索词) {
|
||||
// 获取指定图层组中的所有图层
|
||||
function 获取组中所有图层(组) {
|
||||
var 图层数组 = [];
|
||||
var 图层组中图层 = 组.layers;
|
||||
|
||||
for (var i = 0; i < 图层组中图层.length; i++) {
|
||||
var 图层 = 图层组中图层[i];
|
||||
图层数组.push(图层);
|
||||
if (图层.typename === "LayerSet") {
|
||||
var 子图层 = 获取组中所有图层(图层);
|
||||
图层数组 = 图层数组.concat(子图层);
|
||||
}
|
||||
}
|
||||
|
||||
return 图层数组;
|
||||
}
|
||||
|
||||
// 获取指定名称的图层组
|
||||
function 根据名称获取图层组(文档, 组名称) {
|
||||
var 组 = null;
|
||||
var 所有图层 = 文档.layers;
|
||||
|
||||
for (var i = 0; i < 所有图层.length; i++) {
|
||||
var 图层 = 所有图层[i];
|
||||
if (图层.typename === "LayerSet" && 图层.name === 组名称) {
|
||||
组 = 图层;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 组;
|
||||
}
|
||||
|
||||
var 文档 = app.activeDocument;
|
||||
var 组名称 = "图层基础信息"; // 指定要匹配的图层组名称
|
||||
var 组 = 根据名称获取图层组(文档, 组名称);
|
||||
|
||||
if (组) {
|
||||
var 图层数组 = 获取组中所有图层(组);
|
||||
var 模糊匹配图层数组 = [];
|
||||
|
||||
// 首先进行模糊匹配
|
||||
for (var i = 0; i < 图层数组.length; i++) {
|
||||
var 图层 = 图层数组[i];
|
||||
if (图层.name.indexOf(搜索词) !== -1) {
|
||||
模糊匹配图层数组.push(图层);
|
||||
}
|
||||
}
|
||||
|
||||
// 在模糊匹配结果中进行图层基础信息数组分割过滤
|
||||
var 精确匹配图层数组 = [];
|
||||
for (var j = 0; j < 模糊匹配图层数组.length; j++) {
|
||||
var 模糊匹配图层 = 模糊匹配图层数组[j];
|
||||
// 进行图层基础信息数组分割过滤
|
||||
var 图层基础信息数组 = 模糊匹配图层.name.split("_"); // 假设分割符是 "_"
|
||||
if (图层基础信息数组[0] === 搜索词) {
|
||||
精确匹配图层数组.push(模糊匹配图层);
|
||||
}
|
||||
}
|
||||
|
||||
// 返回匹配的图层数组
|
||||
return 精确匹配图层数组;
|
||||
} else {
|
||||
alert('未找到名为"' + 组名称 + '"的图层组。');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 毫米转像素(毫米, 每英寸像素数) {
|
||||
var 每英寸毫米数 = 25.4;
|
||||
var 英寸 = 毫米 / 每英寸毫米数;
|
||||
return Math.round(英寸 * 每英寸像素数);
|
||||
}
|
||||
|
||||
function 图层按照缩放定位点进行宽高缩放(缩放定位点的X轴坐标,缩放定位点的Y轴坐标,缩放比例高度) //自由变换
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSIndependent"));
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 缩放定位点的X轴坐标);
|
||||
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 缩放定位点的Y轴坐标);
|
||||
d.putObject(stringIDToTypeID("position"), stringIDToTypeID("point"), d1);
|
||||
var d2 = new ActionDescriptor();
|
||||
d2.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d2.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d2.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 0);
|
||||
d.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), d2);
|
||||
d.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("percentUnit"), 缩放比例高度);
|
||||
d.putUnitDouble(stringIDToTypeID("height"), stringIDToTypeID("percentUnit"), 缩放比例高度);
|
||||
|
||||
d.putEnumerated(charIDToTypeID("Intr"), stringIDToTypeID("interpolationType"), stringIDToTypeID("nearestNeighbor"));
|
||||
executeAction(stringIDToTypeID("transform"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 裁切图层(裁切上边距,裁切左边距,裁切下边距,裁切右边距) //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("top"), stringIDToTypeID("pixelsUnit"), 裁切上边距);
|
||||
d1.putUnitDouble(stringIDToTypeID("left"), stringIDToTypeID("pixelsUnit"), 裁切左边距);
|
||||
d1.putUnitDouble(stringIDToTypeID("bottom"), stringIDToTypeID("pixelsUnit"),裁切下边距);
|
||||
d1.putUnitDouble(stringIDToTypeID("right"), stringIDToTypeID("pixelsUnit"), 裁切右边距);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("rectangle"), d1);
|
||||
d.putUnitDouble(stringIDToTypeID("angle"), stringIDToTypeID("angleUnit"), 0);
|
||||
d.putBoolean(stringIDToTypeID("delete"), true);
|
||||
d.putEnumerated(stringIDToTypeID("cropAspectRatioModeKey"), stringIDToTypeID("cropAspectRatioModeClass"), stringIDToTypeID("pureAspectRatio"));
|
||||
d.putBoolean(stringIDToTypeID("constrainProportions"), false);
|
||||
executeAction(stringIDToTypeID("crop"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 获取当前缩放定位点选区四边距() {
|
||||
var currentDocument = app.activeDocument;
|
||||
var selectionBounds = currentDocument.selection.bounds;
|
||||
|
||||
var top2 = selectionBounds[1].value;
|
||||
var left2 = selectionBounds[0].value;
|
||||
var bottom2 = selectionBounds[3].value;
|
||||
var right2 = selectionBounds[2].value;
|
||||
|
||||
return {
|
||||
top2: top2,
|
||||
left2: left2,
|
||||
bottom2: bottom2,
|
||||
right2: right2
|
||||
};
|
||||
}
|
||||
|
||||
function 获取当前选区四边距() {
|
||||
var currentDocument = app.activeDocument;
|
||||
var selectionBounds = currentDocument.selection.bounds;
|
||||
|
||||
var top = selectionBounds[1].value;
|
||||
var left = selectionBounds[0].value;
|
||||
var bottom = selectionBounds[3].value;
|
||||
var right = selectionBounds[2].value;
|
||||
|
||||
return {
|
||||
top: top,
|
||||
left: left,
|
||||
bottom: bottom,
|
||||
right: right
|
||||
};
|
||||
}
|
||||
|
||||
function 历史记录回退缩放函数() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putOffset(stringIDToTypeID("historyState"), -5 );
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 粘贴图层() //粘贴图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("paste"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 复制图层() //复制图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("copyEvent"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 载入选区() //载入选区
|
||||
{
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 取消选择() //取消选择
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("to"), stringIDToTypeID("ordinal"), stringIDToTypeID("none"));
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 图层选择(当前图层名称) //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putName(stringIDToTypeID("layer"), 当前图层名称);
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(6);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 自由变换() //自由变换
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), d1);
|
||||
d.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("percentUnit"), -100);
|
||||
d.putUnitDouble(stringIDToTypeID("height"), stringIDToTypeID("percentUnit"), -100);
|
||||
d.putBoolean(stringIDToTypeID("linked"), true);
|
||||
d.putEnumerated(charIDToTypeID("Intr"), stringIDToTypeID("interpolationType"), stringIDToTypeID("nearestNeighbor"));
|
||||
executeAction(stringIDToTypeID("transform"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 选择上一图层() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("forwardEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(8);
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 添加图层蒙版() //添加图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("at"), r);
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("userMaskEnabled"), stringIDToTypeID("revealSelection"));
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 应用图层蒙版() //应用图层蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("apply"), true);
|
||||
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 拼合所有蒙版() //拼合所有蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("e805a6ee-6d75-4b62-b6fe-f5873b5fdf20"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 选择蒙版() //选择蒙版
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 历史记录回退() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putOffset(stringIDToTypeID("historyState"), -5);
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function 烧花线添加() {
|
||||
|
||||
app.activeDocument.suspendHistory("烧花线添加", "烧花线()");
|
||||
|
||||
|
||||
function 烧花线() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 遍历当前文档图层
|
||||
|
||||
var doc = app.activeDocument;
|
||||
var layers = doc.layers;
|
||||
var filteredLayers = [];
|
||||
|
||||
// 遍历图层,筛选以P开头的图层
|
||||
for (var i = 0; i < layers.length; i++) {
|
||||
var layer = layers[i];
|
||||
if (layer.name.charAt(0) === 'P') {
|
||||
filteredLayers.push(layer);
|
||||
}
|
||||
}
|
||||
|
||||
空置图层()
|
||||
// 输出图层名称
|
||||
for (var j = 0; j < filteredLayers.length; j++) {
|
||||
var filteredLayer = filteredLayers[j];
|
||||
|
||||
var 裁片底图名称=filteredLayer.name;
|
||||
|
||||
多选图层(裁片底图名称);
|
||||
|
||||
// alert(filteredLayer.name);
|
||||
|
||||
}
|
||||
合并图层();
|
||||
置为顶层();
|
||||
画布大小();
|
||||
var layer = app.activeDocument.activeLayer;
|
||||
layer.name = "底图";
|
||||
恢复默认颜色()
|
||||
矩形选框像素点()
|
||||
//色彩范围()
|
||||
填充();
|
||||
魔棒烧花线()
|
||||
新建图层()
|
||||
var layer2 = app.activeDocument.activeLayer;
|
||||
layer2.name = "剪口";
|
||||
扩展2();
|
||||
恢复止口线默认颜色()
|
||||
填充();
|
||||
矩形选框准备删除()
|
||||
清除();
|
||||
魔棒();
|
||||
扩展();
|
||||
选择反向();
|
||||
清除();
|
||||
var 底图 = app.activeDocument.layers.getByName( "底图");
|
||||
app.activeDocument.activeLayer=底图;
|
||||
矩形选框准备删除()
|
||||
清除();
|
||||
置为底层()
|
||||
图层样式()
|
||||
取消选择()
|
||||
|
||||
function 多选图层(裁片底图名称) //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putName(stringIDToTypeID("layer"), 裁片底图名称);
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("selectionModifier"), stringIDToTypeID("selectionModifierType"), stringIDToTypeID("addToSelection"));
|
||||
d.putBoolean(stringIDToTypeID("makeVisible"), false);
|
||||
var list = new ActionList();
|
||||
list.putInteger(4);
|
||||
|
||||
d.putList(stringIDToTypeID("layerID"), list);
|
||||
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 空置图层() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("selectNoLayers"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 恢复止口线默认颜色() //取消选择
|
||||
{
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("color"), stringIDToTypeID("foregroundColor"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putDouble(stringIDToTypeID("cyan"), 30);
|
||||
d1.putDouble(stringIDToTypeID("magenta"), 0);
|
||||
d1.putDouble(stringIDToTypeID("yellowColor"), 0);
|
||||
d1.putDouble(stringIDToTypeID("black"), 0);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("CMYKColorClass"), d1);
|
||||
d.putString(stringIDToTypeID("source"), "photoshopPicker");
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 合并图层() //合并图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("mergeLayersNew"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 恢复默认颜色() //
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("color"), stringIDToTypeID("colors"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
executeAction(stringIDToTypeID("reset"), d, DialogModes.NO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 魔棒烧花线() //魔棒
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("point"), d1);
|
||||
d.putInteger(stringIDToTypeID("tolerance"), 6);
|
||||
d.putBoolean(stringIDToTypeID("contiguous"), false);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
function 矩形选框像素点() //矩形选框
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("top"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("left"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("bottom"), stringIDToTypeID("distanceUnit"), 0.48);
|
||||
d1.putUnitDouble(stringIDToTypeID("right"), stringIDToTypeID("distanceUnit"), 0.48);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("rectangle"), d1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 置为底层() //置为底层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("back"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("move"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 置为顶层() //置为顶层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var r1 = new ActionReference();
|
||||
r1.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("front"));
|
||||
d.putReference(stringIDToTypeID("to"), r1);
|
||||
executeAction(stringIDToTypeID("move"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function 色彩范围() //色彩范围
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putInteger(stringIDToTypeID("fuzziness"), 40);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putDouble(stringIDToTypeID("luminance"), 0);
|
||||
d1.putDouble(stringIDToTypeID("a"), 0);
|
||||
d1.putDouble(stringIDToTypeID("b"), 0);
|
||||
d.putObject(stringIDToTypeID("minimum"), stringIDToTypeID("labColor"), d1);
|
||||
var d2 = new ActionDescriptor();
|
||||
d2.putDouble(stringIDToTypeID("luminance"), 0);
|
||||
d2.putDouble(stringIDToTypeID("a"), 0);
|
||||
d2.putDouble(stringIDToTypeID("b"), 0);
|
||||
d.putObject(stringIDToTypeID("maximum"), stringIDToTypeID("labColor"), d2);
|
||||
d.putInteger(stringIDToTypeID("colorModel"), 0);
|
||||
executeAction(stringIDToTypeID("colorRange"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 新建图层() //新建图层
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putClass(stringIDToTypeID("layer"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putInteger(stringIDToTypeID("layerID"), 33);
|
||||
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 扩展2() //扩展
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putUnitDouble(stringIDToTypeID("by"), stringIDToTypeID("pixelsUnit"), 1);
|
||||
d.putBoolean(stringIDToTypeID("selectionModifyEffectAtCanvasBounds"), false);
|
||||
executeAction(stringIDToTypeID("expand"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 填充() //填充
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("fillContents"), stringIDToTypeID("foregroundColor"));
|
||||
d.putUnitDouble(stringIDToTypeID("opacity"), stringIDToTypeID("percentUnit"), 100);
|
||||
d.putEnumerated(stringIDToTypeID("mode"), stringIDToTypeID("blendMode"), stringIDToTypeID("normal"));
|
||||
executeAction(stringIDToTypeID("fill"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function 画布大小() //画布大小
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putBoolean(stringIDToTypeID("relative"), true);
|
||||
d.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("distanceUnit"), 40);
|
||||
d.putUnitDouble(stringIDToTypeID("height"), stringIDToTypeID("distanceUnit"), 40);
|
||||
d.putEnumerated(stringIDToTypeID("horizontal"), stringIDToTypeID("horizontalLocation"), stringIDToTypeID("center"));
|
||||
d.putEnumerated(stringIDToTypeID("vertical"), stringIDToTypeID("verticalLocation"), stringIDToTypeID("center"));
|
||||
executeAction(stringIDToTypeID("canvasSize"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 魔棒() //魔棒
|
||||
{
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 3);
|
||||
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 3);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("point"), d1);
|
||||
d.putInteger(stringIDToTypeID("tolerance"), 6);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
function 矩形选框准备删除() //矩形选框
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("top"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("left"), stringIDToTypeID("distanceUnit"), 0);
|
||||
d1.putUnitDouble(stringIDToTypeID("bottom"), stringIDToTypeID("distanceUnit"), 0.96);
|
||||
d1.putUnitDouble(stringIDToTypeID("right"), stringIDToTypeID("distanceUnit"), 0.96);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("rectangle"), d1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 扩展() //扩展
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
d.putUnitDouble(stringIDToTypeID("by"), stringIDToTypeID("pixelsUnit"), 25);
|
||||
d.putBoolean(stringIDToTypeID("selectionModifyEffectAtCanvasBounds"), false);
|
||||
executeAction(stringIDToTypeID("expand"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 选择反向() //选择反向
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
executeAction(stringIDToTypeID("inverse"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 清除() //清除
|
||||
{
|
||||
app.activeDocument.selection.clear();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 图层样式() //图层样式
|
||||
{
|
||||
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerEffects"));
|
||||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
var d1 = new ActionDescriptor();
|
||||
d1.putUnitDouble(stringIDToTypeID("scale"), stringIDToTypeID("percentUnit"), 12);
|
||||
var d2 = new ActionDescriptor();
|
||||
d2.putBoolean(stringIDToTypeID("enabled"), true);
|
||||
d2.putBoolean(stringIDToTypeID("present"), true);
|
||||
d2.putBoolean(stringIDToTypeID("showInDialog"), true);
|
||||
d2.putEnumerated(stringIDToTypeID("style"), stringIDToTypeID("frameStyle"), stringIDToTypeID("outsetFrame"));
|
||||
d2.putEnumerated(stringIDToTypeID("paintType"), stringIDToTypeID("frameFill"), stringIDToTypeID("solidColor"));
|
||||
d2.putEnumerated(stringIDToTypeID("mode"), stringIDToTypeID("blendMode"), stringIDToTypeID("normal"));
|
||||
d2.putUnitDouble(stringIDToTypeID("opacity"), stringIDToTypeID("percentUnit"), 100);
|
||||
d2.putUnitDouble(stringIDToTypeID("size"), stringIDToTypeID("pixelsUnit"), 16);
|
||||
var d3 = new ActionDescriptor();
|
||||
d3.putDouble(stringIDToTypeID("red"), 90);
|
||||
d3.putDouble(stringIDToTypeID("green"), 79);
|
||||
d3.putDouble(stringIDToTypeID("blue"), 74);
|
||||
d2.putObject(stringIDToTypeID("color"), stringIDToTypeID("RGBColor"), d3);
|
||||
d2.putBoolean(stringIDToTypeID("overprint"), false);
|
||||
d1.putObject(stringIDToTypeID("frameFX"), stringIDToTypeID("frameFX"), d2);
|
||||
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("layerEffects"), d1);
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function 取消选择() //取消选择
|
||||
{
|
||||
var d = new ActionDescriptor();
|
||||
var r = new ActionReference();
|
||||
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
||||
d.putReference(stringIDToTypeID("null"), r);
|
||||
d.putEnumerated(stringIDToTypeID("to"), stringIDToTypeID("ordinal"), stringIDToTypeID("none"));
|
||||
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
335
psmark/Tab1.py
Normal file
335
psmark/Tab1.py
Normal file
@@ -0,0 +1,335 @@
|
||||
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QApplication, QMainWindow, QSpinBox, QFormLayout, QTabWidget, QPushButton, QLabel, QVBoxLayout, QWidget, QHBoxLayout, QGroupBox, QLineEdit, QCheckBox, QMessageBox
|
||||
from PyQt5.QtGui import QIcon
|
||||
import piece_decorative
|
||||
import re
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
|
||||
class ImportPDFDialog(QMainWindow):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle('Import Multiple PDF pages')
|
||||
self.setWindowIcon(QIcon('icon.png'))
|
||||
|
||||
main_widget = QWidget()
|
||||
self.setCentralWidget(main_widget)
|
||||
main_layout = QVBoxLayout()
|
||||
main_widget.setLayout(main_layout)
|
||||
psd_group = QGroupBox('PSD裁片预处理')
|
||||
psd_layout = QVBoxLayout(psd_group)
|
||||
self.spin_box = QSpinBox()
|
||||
self.spin_box.setMinimum(0)
|
||||
self.spin_box.setMaximum(100)
|
||||
self.spin_box.setValue(1)
|
||||
psd_layout.addWidget(self.spin_box)
|
||||
self.number_button = QPushButton('名称赋予')
|
||||
self.number_button.clicked.connect(self.number_button_clicked)
|
||||
psd_layout.addWidget(self.number_button)
|
||||
form_layout = QFormLayout()
|
||||
# fabric_break_button = QPushButton('设置裁片组')
|
||||
# fabric_break_button.clicked.connect(self.break_fabric_line)
|
||||
# psd_layout.addWidget(fabric_break_button)
|
||||
|
||||
# self.shrink_width_line_edit = QLineEdit()
|
||||
# form_layout.addRow('缩水值宽:', self.shrink_width_line_edit)
|
||||
# self.shrink_height_line_edit = QLineEdit()
|
||||
# form_layout.addRow('缩水值高:', self.shrink_height_line_edit)
|
||||
#
|
||||
# psd_layout.addLayout(form_layout)
|
||||
# psd_pattern_button = QPushButton('缩水修改')
|
||||
# psd_pattern_button.clicked.connect(self.set_psd_pattern)
|
||||
# psd_layout.addWidget(psd_pattern_button)
|
||||
psd_place_button = QPushButton('角度校准')
|
||||
psd_place_button.clicked.connect(self.place_psd_pieces)
|
||||
psd_layout.addWidget(psd_place_button)
|
||||
psdcut_grab_button = QPushButton('花样裁切')
|
||||
psdcut_grab_button.clicked.connect(self.psdcut)
|
||||
psd_layout.addWidget(psdcut_grab_button)
|
||||
psd_grab_button = QPushButton('裁片抓取')
|
||||
psd_grab_button.clicked.connect(self.grab_psd_pieces)
|
||||
psd_layout.addWidget(psd_grab_button)
|
||||
psd_grab_button1 = QPushButton('花型对齐')
|
||||
psd_grab_button1.clicked.connect(self.grab_psd_pieces1)
|
||||
psd_layout.addWidget(psd_grab_button1)
|
||||
|
||||
|
||||
main_layout.addWidget(psd_group)
|
||||
|
||||
psd_group2 = QGroupBox('缩水修改')
|
||||
psd_layout = QVBoxLayout(psd_group2)
|
||||
# self.spin_box = QSpinBox()
|
||||
# self.spin_box.setMinimum(0)
|
||||
# self.spin_box.setMaximum(100)
|
||||
# self.spin_box.setValue(1)
|
||||
# psd_layout.addWidget(self.spin_box)
|
||||
# self.number_button = QPushButton('名称赋予')
|
||||
# self.number_button.clicked.connect(self.number_button_clicked)
|
||||
# psd_layout.addWidget(self.number_button)
|
||||
# form_layout = QFormLayout()
|
||||
# fabric_break_button = QPushButton('设置裁片组')
|
||||
# fabric_break_button.clicked.connect(self.break_fabric_line)
|
||||
# psd_layout.addWidget(fabric_break_button)
|
||||
|
||||
self.shrink_width_line_edit = QLineEdit()
|
||||
form_layout.addRow('缩水值宽:', self.shrink_width_line_edit)
|
||||
self.shrink_height_line_edit = QLineEdit()
|
||||
form_layout.addRow('缩水值高:', self.shrink_height_line_edit)
|
||||
|
||||
psd_layout.addLayout(form_layout)
|
||||
psd_pattern_button = QPushButton('缩水修改')
|
||||
psd_pattern_button.clicked.connect(self.set_psd_pattern)
|
||||
psd_layout.addWidget(psd_pattern_button)
|
||||
# psd_place_button = QPushButton('角度校准')
|
||||
# psd_place_button.clicked.connect(self.place_psd_pieces)
|
||||
# psd_layout.addWidget(psd_place_button)
|
||||
# psdcut_grab_button = QPushButton('花样裁切')
|
||||
# psdcut_grab_button.clicked.connect(self.psdcut)
|
||||
# psd_layout.addWidget(psdcut_grab_button)
|
||||
# psd_grab_button = QPushButton('裁片抓取')
|
||||
# psd_grab_button.clicked.connect(self.grab_psd_pieces)
|
||||
# psd_layout.addWidget(psd_grab_button)
|
||||
|
||||
main_layout.addWidget(psd_group2)
|
||||
|
||||
|
||||
|
||||
|
||||
# 添加六个按钮,每行三个按钮
|
||||
align_group = QGroupBox('裁片对齐')
|
||||
align_layout = QVBoxLayout(align_group)
|
||||
|
||||
# 创建水平布局用于放置每行的按钮
|
||||
row_layout = QHBoxLayout()
|
||||
|
||||
# 创建第一个按钮
|
||||
neckline_align_button = QPushButton('左上对齐')
|
||||
neckline_align_button.clicked.connect(self.align_neckline1)
|
||||
row_layout.addWidget(neckline_align_button)
|
||||
|
||||
# 创建第二个按钮
|
||||
button2 = QPushButton('领口对齐')
|
||||
button2.clicked.connect(self.another_function2)
|
||||
row_layout.addWidget(button2)
|
||||
|
||||
# 创建第三个按钮
|
||||
button3 = QPushButton('右上对齐')
|
||||
button3.clicked.connect(self.another_function3)
|
||||
row_layout.addWidget(button3)
|
||||
|
||||
# 将第一行按钮添加到垂直布局
|
||||
align_layout.addLayout(row_layout)
|
||||
|
||||
# 创建水平布局用于放置第二行的按钮
|
||||
row_layout = QHBoxLayout()
|
||||
|
||||
# 创建第四个按钮
|
||||
button4 = QPushButton('左下对齐')
|
||||
button4.clicked.connect(self.another_function4)
|
||||
row_layout.addWidget(button4)
|
||||
|
||||
# 创建第五个按钮
|
||||
button5 = QPushButton('下摆对齐')
|
||||
button5.clicked.connect(self.another_function5)
|
||||
row_layout.addWidget(button5)
|
||||
|
||||
# 创建第六个按钮
|
||||
button6 = QPushButton('右下对齐')
|
||||
button6.clicked.connect(self.another_function6)
|
||||
row_layout.addWidget(button6)
|
||||
|
||||
# 将第二行按钮添加到垂直布局
|
||||
align_layout.addLayout(row_layout)
|
||||
|
||||
main_layout.addWidget(align_group)
|
||||
|
||||
main_layout.addWidget(align_group)
|
||||
info_group = QGroupBox('信息写入')
|
||||
info_layout = QVBoxLayout(info_group)
|
||||
size_add_button = QPushButton('添加定位点')
|
||||
size_add_button.clicked.connect(self.add_sizes)
|
||||
info_layout.addWidget(size_add_button)
|
||||
# material_count_button = QPushButton('缩放信息写入')
|
||||
# material_count_button.clicked.connect(self.count_materials)
|
||||
# info_layout.addWidget(material_count_button)
|
||||
|
||||
material_count_button2 = QPushButton('重写缩放信息')
|
||||
material_count_button2.clicked.connect(self.count_materials2)
|
||||
info_layout.addWidget(material_count_button2)
|
||||
|
||||
|
||||
|
||||
main_layout.addWidget(info_group)
|
||||
pattern_group = QGroupBox('自动套花')
|
||||
pattern_layout = QVBoxLayout(pattern_group)
|
||||
pattern_extend_button = QPushButton('通码延申')
|
||||
pattern_extend_button.clicked.connect(self.extend_pattern)
|
||||
pattern_layout.addWidget(pattern_extend_button)
|
||||
scale_button = QPushButton('宽高缩放')
|
||||
scale_button.clicked.connect(self.scale_dimensions)
|
||||
pattern_layout.addWidget(scale_button)
|
||||
proportional_scale_button = QPushButton('比例缩放')
|
||||
proportional_scale_button.clicked.connect(self.proportional_scale)
|
||||
pattern_layout.addWidget(proportional_scale_button)
|
||||
|
||||
bigproportional_scale_button = QPushButton('定位点比例缩放')
|
||||
bigproportional_scale_button.clicked.connect(self.bigproportional_scale)
|
||||
pattern_layout.addWidget(bigproportional_scale_button)
|
||||
|
||||
# self.checkbox1 = QCheckBox('混排套图方法', self)
|
||||
# pattern_layout.addWidget(self.checkbox1)
|
||||
|
||||
main_layout.addWidget(pattern_group)
|
||||
save_group = QGroupBox('文档保存')
|
||||
save_layout = QVBoxLayout(save_group)
|
||||
# add_size_button = QPushButton('尺码激活')
|
||||
# add_size_button.clicked.connect(self.add_size_to_layers)
|
||||
# save_layout.addWidget(add_size_button)
|
||||
form_layout = QFormLayout()
|
||||
self.prefix_line_edit = QLineEdit()
|
||||
form_layout.addRow('前缀添加:', self.prefix_line_edit)
|
||||
save_layout.addLayout(form_layout)
|
||||
save_button = QPushButton('保存')
|
||||
save_button.clicked.connect(self.save_document2)
|
||||
save_layout.addWidget(save_button)
|
||||
main_layout.addWidget(save_group)
|
||||
|
||||
|
||||
def align_neckline1(self):
|
||||
|
||||
piece_decorative.PS_DXF7_jscode_fun('左上对齐2()')
|
||||
pass
|
||||
|
||||
def another_function2(self):
|
||||
|
||||
piece_decorative.PS_DXF3_jscode_fun('领口对齐2()')
|
||||
pass
|
||||
|
||||
def another_function3(self):
|
||||
piece_decorative.PS_DXF2_jscode_fun('右上对齐2()')
|
||||
# piece_decorative.PS_DXF2_jscode_fun(f'文档保存最新("{前缀}");')
|
||||
pass
|
||||
|
||||
|
||||
def another_function4(self):
|
||||
piece_decorative.PS_DXF4_jscode_fun('左下对齐2()')
|
||||
# piece_decorative.PS_DXF2_jscode_fun(f'文档保存最新("{前缀}");')
|
||||
pass
|
||||
|
||||
def another_function5(self):
|
||||
piece_decorative.PS_DXF5_jscode_fun('下摆对齐2()')
|
||||
# piece_decorative.PS_DXF2_jscode_fun(f'文档保存最新("{前缀}");')
|
||||
pass
|
||||
|
||||
def another_function6(self):
|
||||
piece_decorative.PS_DXF6_jscode_fun('右下对齐2()')
|
||||
# piece_decorative.PS_DXF2_jscode_fun(f'文档保存最新("{前缀}");')
|
||||
pass
|
||||
|
||||
def save_document2(self):
|
||||
前缀 = self.prefix_line_edit.text()
|
||||
piece_decorative.PS_DXF2_jscode_fun(f'文档保存最新("{前缀}");')
|
||||
|
||||
def add_size_to_layers(self):
|
||||
piece_decorative.PS_DXF2_jscode_fun('信息激活2();')
|
||||
|
||||
def psdcut(self):
|
||||
piece_decorative.PS_DXF6_jscode_fun('图像切割2();')
|
||||
def number_button_clicked(self):
|
||||
current_value = self.spin_box.value()
|
||||
piece_decorative.PS_DXF_jscode_fun(f"名称赋予({current_value});")
|
||||
new_value = current_value + 1
|
||||
self.spin_box.setValue(new_value)
|
||||
|
||||
def another_function(self):
|
||||
# 在这里定义按钮点击事件的处理逻辑
|
||||
pass
|
||||
def set_psd_pattern(self):
|
||||
高度值 = self.shrink_height_line_edit.text()
|
||||
宽度值 = self.shrink_width_line_edit.text()
|
||||
|
||||
number_pattern = re.compile(r'^\d+(\.\d+)?$') # 正则表达式匹配数字格式
|
||||
|
||||
if number_pattern.match(高度值) and number_pattern.match(宽度值):
|
||||
# 如果两个值都是数字,执行批量缩水操作
|
||||
# piece_decorative.PS_DXF2_jscode_fun('设置花样组删除图层设置名称();')
|
||||
piece_decorative.PS_DXF2_jscode_fun(f"批量缩水值修改({宽度值},{高度值});")
|
||||
else:
|
||||
# 如果至少有一个值不是数字,显示警告
|
||||
QMessageBox.warning(self, '错误', '缩水值只能是数字!')
|
||||
|
||||
def grab_psd_pieces(self):
|
||||
piece_decorative.PS_DXF2_jscode_fun('设置花样组删除图层设置名称();')
|
||||
piece_decorative.PS_DXF12_jscode_fun('批量套数写入();')
|
||||
piece_decorative.PS_DXF2_jscode_fun('设置花样组2();')
|
||||
piece_decorative.PS_DXF_jscode_fun('裁片吸取2();')
|
||||
piece_decorative.PS_DXF2_jscode_fun('设置花样组顺序居中();')
|
||||
piece_decorative.PS_DXF_jscode_fun('信息写入();')
|
||||
piece_decorative.PS_DXF3_jscode_fun('裁片视图检查2();')
|
||||
|
||||
|
||||
def grab_psd_pieces1(self):
|
||||
|
||||
piece_decorative.PS_DXF2_jscode_fun('设置花样组顺序居中();')
|
||||
piece_decorative.PS_DXF_jscode_fun('信息写入();')
|
||||
piece_decorative.PS_DXF3_jscode_fun('裁片视图检查2();')
|
||||
|
||||
|
||||
def place_psd_pieces(self):
|
||||
piece_decorative.PS_DXF3_jscode_fun('角度旋转();')
|
||||
|
||||
def align_neckline(self):
|
||||
piece_decorative.PS_DXF2_jscode_fun('领口对齐();')
|
||||
|
||||
|
||||
def extend_pattern(self):
|
||||
|
||||
# if self.checkbox1.isChecked():
|
||||
# piece_decorative.PS_DXF_jscode_fun('删除指定名称蒙版();')
|
||||
# piece_decorative.PS_DXF20_jscode_fun('混排通码延申导出();')
|
||||
# print('按下')
|
||||
#
|
||||
# else:
|
||||
# print('没有按下')
|
||||
piece_decorative.PS_DXF6_jscode_fun('前景色修改();')
|
||||
piece_decorative.PS_DXF_jscode_fun('删除指定名称蒙版();')
|
||||
piece_decorative.PS_DXF_jscode_fun('裁片射出();')
|
||||
piece_decorative.PS_DXF2_jscode_fun('信息激活2();')
|
||||
|
||||
def scale_dimensions(self):
|
||||
piece_decorative.PS_DXF6_jscode_fun('前景色修改();')
|
||||
piece_decorative.PS_DXF_jscode_fun('删除指定名称蒙版();')
|
||||
piece_decorative.PS_DXF13_jscode_fun('裁片射出宽高缩放();')
|
||||
piece_decorative.PS_DXF2_jscode_fun('信息激活2();')
|
||||
|
||||
def proportional_scale(self):
|
||||
piece_decorative.PS_DXF6_jscode_fun('前景色修改();')
|
||||
piece_decorative.PS_DXF_jscode_fun('删除指定名称蒙版();')
|
||||
piece_decorative.PS_DXF9_jscode_fun('裁片射出比例缩放按中心点();')
|
||||
piece_decorative.PS_DXF2_jscode_fun('信息激活2();')
|
||||
|
||||
def bigproportional_scale(self):
|
||||
piece_decorative.PS_DXF6_jscode_fun('前景色修改();')
|
||||
piece_decorative.PS_DXF_jscode_fun('删除指定名称蒙版();')
|
||||
piece_decorative.PS_DXF11_jscode_fun('裁片射出缩放();')
|
||||
piece_decorative.PS_DXF2_jscode_fun('信息激活2();')
|
||||
|
||||
|
||||
|
||||
def add_sizes(self):
|
||||
piece_decorative.PS_DXF_jscode_fun('添加缩放定位点();')
|
||||
|
||||
def count_materials(self):
|
||||
piece_decorative.PS_DXF_jscode_fun('信息写入();')
|
||||
|
||||
def count_materials2(self):
|
||||
piece_decorative.PS_DXF3_jscode_fun('重写基码信息2();')
|
||||
piece_decorative.PS_DXF_jscode_fun('信息写入();')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app2 = QApplication(sys.argv)
|
||||
dialog = ImportPDFDialog()
|
||||
dialog.show()
|
||||
sys.exit(app2.exec_())
|
||||
427
psmark/Tab2.py
Normal file
427
psmark/Tab2.py
Normal file
@@ -0,0 +1,427 @@
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QLabel, QPushButton, QFileDialog, \
|
||||
QLineEdit, QScrollArea, QGroupBox, QHBoxLayout, QMessageBox, QProgressDialog
|
||||
from PyQt5.QtGui import QIntValidator
|
||||
from PyQt5.QtCore import QTimer
|
||||
import re
|
||||
import os
|
||||
import ezdxf
|
||||
import ezdxf.tools
|
||||
import ezdxf.bbox
|
||||
import ezdxf.units
|
||||
import ezdxf.math
|
||||
from coreldraw_checker import is_coreldraw_running
|
||||
from functools import partial
|
||||
import win32com.client
|
||||
import os
|
||||
import shutil
|
||||
import threading
|
||||
from clear_folder import another_function
|
||||
|
||||
|
||||
class YourMainWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.setWindowTitle("RUNDXF")
|
||||
|
||||
layout = QVBoxLayout()
|
||||
|
||||
self.button1 = QPushButton("DXF文件路径")
|
||||
self.button1.setFixedWidth(200)
|
||||
self.button1.clicked.connect(self.showDxfFileDialog)
|
||||
|
||||
self.button2 = QPushButton("PLT文件路径")
|
||||
self.button2.setFixedWidth(200)
|
||||
self.button2.clicked.connect(self.showPltFileDialog)
|
||||
|
||||
self.initial_button1_text = self.button1.text()
|
||||
self.initial_button2_text = self.button2.text()
|
||||
|
||||
panel1 = QGroupBox("文件路径")
|
||||
panel1_layout = QVBoxLayout(panel1)
|
||||
panel1_layout.setSpacing(10)
|
||||
panel1_layout.setContentsMargins(10, 10, 10, 10)
|
||||
panel1_layout.addWidget(self.button1)
|
||||
panel1_layout.addWidget(self.button2)
|
||||
layout.addWidget(panel1)
|
||||
|
||||
self.label5 = QLabel('单码片数')
|
||||
self.lineEdit3 = QLineEdit()
|
||||
self.lineEdit3.setValidator(QIntValidator())
|
||||
self.lineEdit3.setFixedSize(120, 30)
|
||||
layout.addWidget(self.label5)
|
||||
layout.addWidget(self.lineEdit3)
|
||||
|
||||
self.scrollWidget = QWidget()
|
||||
self.scrollWidgetLayout = QVBoxLayout(self.scrollWidget)
|
||||
self.scrollArea = QScrollArea()
|
||||
self.scrollArea.setWidget(self.scrollWidget)
|
||||
self.scrollArea.setWidgetResizable(True)
|
||||
layout.addWidget(self.scrollArea)
|
||||
|
||||
self.clearButton = QPushButton("清空信息")
|
||||
self.clearButton.clicked.connect(self.clearScrollArea)
|
||||
layout.addWidget(self.clearButton)
|
||||
|
||||
confirm_button = QPushButton("分割")
|
||||
confirm_button.clicked.connect(self.updateScrollArea)
|
||||
#confirm_button.clicked.connect(self.freezeAndParse) # 连接按钮点击事件
|
||||
layout.addWidget(confirm_button)
|
||||
|
||||
|
||||
central_widget = QWidget()
|
||||
central_widget.setLayout(layout)
|
||||
self.setCentralWidget(central_widget)
|
||||
|
||||
self.dxfLineEdits = {}
|
||||
|
||||
self.allowButtonActions = True # 标志变量,控制是否允许按钮行为
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def run_coreldraw_macros(self):
|
||||
try:
|
||||
dogms = win32com.client.DispatchEx("CorelDRAW.Application.23")
|
||||
|
||||
macros_to_run = [
|
||||
"RUN.OpenDXFFilesInFolder",
|
||||
"RUN.RotateSelectionClockwise",
|
||||
"RUN.DeleteUnnamedSublayers",
|
||||
"RUN.StToFront",
|
||||
"RUN.IterateSublayerNames",
|
||||
|
||||
|
||||
]
|
||||
|
||||
for macro in macros_to_run:
|
||||
dogms.GMSManager.RunMacro("RUNDXF", macro)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
QMessageBox.warning(self, "警告", "缺少CDR模块,请载入CDR模块", QMessageBox.Ok)
|
||||
# print("缺少CDR模块,请载入CDR模块")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def showPltFileDialog(self):
|
||||
options = QFileDialog.Options()
|
||||
file_path, _ = QFileDialog.getOpenFileName(self, "选择PLT文件", "", "PLT Files (*.plt);;All Files (*)",
|
||||
options=options)
|
||||
if file_path:
|
||||
print("Selected PLT file:", file_path)
|
||||
extracted_content = self.extract_content_from_plt_path(file_path)
|
||||
print(extracted_content)
|
||||
self.sizes = self.fill_sizes_from_extracted_content(extracted_content)
|
||||
|
||||
# 更新尺寸字典后,清空并填充滚动区域
|
||||
self.clearScrollArea()
|
||||
self.populateScrollArea()
|
||||
|
||||
self.initial_plt_path = file_path # 更新初始路径而不更新按钮文本
|
||||
|
||||
else:
|
||||
print("No PLT file selected")
|
||||
QMessageBox.warning(self, "警告", "没有选择文件夹。请重新选择文件夹。", QMessageBox.Ok)
|
||||
|
||||
pass
|
||||
|
||||
def showDxfFileDialog(self):
|
||||
options = QFileDialog.Options()
|
||||
file_path, _ = QFileDialog.getOpenFileName(self, "选择DXF文件", "", "DXF Files (*.dxf);;All Files (*)",
|
||||
options=options)
|
||||
if file_path:
|
||||
print("Selected DXF file:", file_path)
|
||||
self.initial_dxf_path = file_path # 更新初始路径而不更新按钮文本
|
||||
else:
|
||||
print("No DXF file selected")
|
||||
QMessageBox.warning(self, "警告", "没有选择文件夹。请重新选择文件夹。", QMessageBox.Ok)
|
||||
# 在此处添加提醒逻辑,例如使用 QMessageBox 提示用户没有选择文件
|
||||
|
||||
def extract_content_from_plt_path(self, plt_path):
|
||||
match = re.search(r'\((.*?)\)', plt_path)
|
||||
if match:
|
||||
extracted_content = match.group(1)
|
||||
return extracted_content
|
||||
else:
|
||||
return "No content in parentheses found"
|
||||
|
||||
def fill_sizes_from_extracted_content(self, extracted_content):
|
||||
sizes = extracted_content.split("+")
|
||||
size_dict = {}
|
||||
for size in sizes:
|
||||
size_dict[size] = ""
|
||||
return size_dict
|
||||
|
||||
def process_dxf_file(self, file_path, extracted_content):
|
||||
doc = ezdxf.readfile(file_path)
|
||||
msp = doc.modelspace()
|
||||
mspBox = ezdxf.bbox.extents(msp)
|
||||
|
||||
print("=====", os.path.basename(file_path))
|
||||
print("左上角坐标:", mspBox.extmin)
|
||||
print("画布宽:", mspBox.size[0], "画布高:", mspBox.size[1])
|
||||
print()
|
||||
|
||||
for entity in msp.query():
|
||||
if entity.dxftype() == "INSERT":
|
||||
temp = []
|
||||
rotation = None
|
||||
block = doc.blocks[entity.dxf.name]
|
||||
|
||||
for e in block:
|
||||
if e.dxftype() != "TEXT":
|
||||
temp.append(e)
|
||||
else:
|
||||
rotation = e.dxf.rotation
|
||||
|
||||
if rotation is not None:
|
||||
rotation %= 360
|
||||
if 45 <= rotation < 135:
|
||||
rotation = 90
|
||||
elif 135 <= rotation < 225:
|
||||
rotation = 180
|
||||
elif 225 <= rotation < 315:
|
||||
rotation = -90
|
||||
else:
|
||||
rotation = 0
|
||||
|
||||
print("=====", entity.dxf.name)
|
||||
print("大小:", ezdxf.bbox.extents(temp).size)
|
||||
print("文字角度:", rotation)
|
||||
|
||||
center = ezdxf.bbox.extents(temp).center
|
||||
center = (center.x, mspBox.extmax.y - center.y) # 调整center y值
|
||||
|
||||
print("中心坐标:", center)
|
||||
|
||||
center = (center[1], mspBox.size[0] - center[0]) # 旋转后中心坐标
|
||||
print("旋转后中心坐标:", center)
|
||||
|
||||
separator = "_" # 分隔符
|
||||
entity.dxf.name += separator + str(rotation)
|
||||
block.name += separator + str(rotation)
|
||||
|
||||
new_file_path = os.path.join(r"D:\marktemp", "{}.dxf".format(extracted_content))
|
||||
doc.saveas(new_file_path)
|
||||
def getSinglePieceCount(self):
|
||||
return self.lineEdit3.text()
|
||||
|
||||
def recreate_folders(self):
|
||||
# 定义文件夹路径
|
||||
folder_paths = [r"D:\PSMARKtemp", r"D:\marktemp"]
|
||||
|
||||
# 删除文件夹及其内容
|
||||
for folder_path in folder_paths:
|
||||
if os.path.exists(folder_path):
|
||||
shutil.rmtree(folder_path)
|
||||
print(f"Deleted folder: {folder_path}")
|
||||
|
||||
# 重新创建文件夹
|
||||
for folder_path in folder_paths:
|
||||
os.makedirs(folder_path)
|
||||
print(f"Recreated folder: {folder_path}")
|
||||
|
||||
def freezeAndParse(self):
|
||||
self.parse_button.setEnabled(False) # 冻结按钮
|
||||
QTimer.singleShot(10000, self.unfreezeButton) # 10秒后解冻按钮
|
||||
|
||||
def unfreezeButton(self):
|
||||
self.parse_button.setEnabled(True) # 解冻按钮
|
||||
|
||||
|
||||
def updateScrollArea(self):
|
||||
|
||||
another_function()
|
||||
|
||||
if not is_coreldraw_running():
|
||||
QMessageBox.warning(self, "警告", "CorelDRAW未运行,无法执行操作。")
|
||||
return
|
||||
|
||||
plt_file_path = self.initial_plt_path
|
||||
|
||||
# 获取DXF文件路径
|
||||
dxf_file_path = self.initial_dxf_path
|
||||
extracted_content = self.extract_content_from_plt_path(plt_file_path)
|
||||
|
||||
if dxf_file_path:
|
||||
# 去掉括号内内容后的PLT文件名作为DXF文件名
|
||||
plt_filename = os.path.basename(plt_file_path)
|
||||
# dxf_filename = re.sub(r'\(.*?\)', '', plt_filename)
|
||||
self.process_dxf_file(dxf_file_path, extracted_content) # 调用解析函数并传入单码片数和新的DXF文件名
|
||||
print("DXF文件解析完成!")
|
||||
else:
|
||||
QMessageBox.warning(self, "警告", "没有选择DXF文件。请先选择一个DXF文件。", QMessageBox.Ok)
|
||||
print()
|
||||
|
||||
|
||||
|
||||
self.run_coreldraw_macros()
|
||||
single_code_pieces = int(self.getSinglePieceCount()) # 获取单码片数
|
||||
print(single_code_pieces)
|
||||
# 打印滚动区域中的输入框内容
|
||||
code_quantities = {} # 创建一个新的字典用于存储数据
|
||||
|
||||
for label, line_edit in self.dxfLineEdits.items():
|
||||
text = line_edit.text()
|
||||
if text.isdigit():
|
||||
value = int(text) # 尝试将文本转换为整数
|
||||
else:
|
||||
try:
|
||||
value = float(text) # 尝试将文本转换为浮点数
|
||||
except ValueError:
|
||||
print(f"Invalid value for {label}: {text}")
|
||||
continue # 转换失败,跳过当前循环迭代
|
||||
|
||||
code_quantities[label] = value # 存储转换后的数字到字典
|
||||
|
||||
print(code_quantities)
|
||||
length = len(code_quantities)
|
||||
print(length) # 输出 3,因为字典中有三对键值对
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
corel_app = win32com.client.Dispatch("CorelDRAW.Application.23")
|
||||
|
||||
# 获取当前活动文档
|
||||
active_document = corel_app.ActiveDocument
|
||||
|
||||
# 获取当前页面中所有图层的名称,排除特定名称的图层
|
||||
layer_names = [layer.Name for layer in active_document.ActivePage.Layers
|
||||
if layer.Name not in ["辅助线", "1", "0", "Defpoints"]]
|
||||
|
||||
p_numbers = [] # 初始化存储 P 数字的列表
|
||||
|
||||
for code, quantity in code_quantities.items():
|
||||
for i in range(1, single_code_pieces + 1):
|
||||
p_numbers.extend([f"P{i}"] * int(quantity))
|
||||
|
||||
print(p_numbers)
|
||||
|
||||
|
||||
# 循环遍历不同的码
|
||||
# p_numbers = [] # 初始化存储 P 数字的列表
|
||||
#
|
||||
# for code, quantity in code_quantities.items():
|
||||
# for i in range(1, single_code_pieces + 1):
|
||||
# # 根据码的数量分别生成对应数量的 P 数字,并添加到列表中
|
||||
# p_numbers.extend([f"P{i}"] * quantity)
|
||||
# print(p_numbers)
|
||||
new_layer_names = []
|
||||
index = 0
|
||||
for old_name in layer_names:
|
||||
parts = old_name.split("-") # 根据"-"分割字符串
|
||||
if len(parts) > 1:
|
||||
new_name = f"{p_numbers[index]}-{parts[1]}" # 使用数组中的 P 数字
|
||||
new_layer_names.append(new_name)
|
||||
index += 1
|
||||
|
||||
# 在新的图层名数组中遍历,对图层进行修改
|
||||
modified_names = [] # 创建一个列表来存储修改后的名称
|
||||
modified_names2 = []
|
||||
for i, new_name in enumerate(new_layer_names):
|
||||
active_document.ActivePage.Layers(layer_names[i]).Name = new_name
|
||||
modified_names2.append(new_name)
|
||||
modified_names.append(new_name)
|
||||
print(f"Modified: {layer_names[i]} -> {new_name}")
|
||||
|
||||
|
||||
|
||||
# print(modified_names)
|
||||
|
||||
|
||||
def delete_layers_by_names(names_to_delete, active_document):
|
||||
corel_app = win32com.client.Dispatch("CorelDRAW.Application.23")
|
||||
|
||||
# 获取当前活动文档
|
||||
active_document = corel_app.ActiveDocument
|
||||
for target_layer_name in names_to_delete:
|
||||
for layer in active_document.ActivePage.Layers:
|
||||
if layer.Name == target_layer_name:
|
||||
layer.Delete()
|
||||
break # 找到目标图层后中断循环
|
||||
|
||||
|
||||
|
||||
modified_names_list = [] # 用于存储每次循环中的 modified_names 列表
|
||||
|
||||
Index = 0
|
||||
for code in code_quantities:
|
||||
quantity = code_quantities[code]
|
||||
total_pieces = quantity * single_code_pieces
|
||||
|
||||
# 获取数组的前 total_pieces 个元素
|
||||
newmodified_names_filtered = modified_names[:total_pieces]
|
||||
# print(newmodified_names_filtered)
|
||||
|
||||
result_array = [fruit for fruit in modified_names2 if fruit not in newmodified_names_filtered]
|
||||
result_array_length = len(result_array)
|
||||
print(result_array_length)
|
||||
|
||||
delete_layers_by_names(result_array, active_document.ActivePage)
|
||||
# modified_names_list.append(modified_names) # 将 modified_names 添加到数组中
|
||||
|
||||
|
||||
dogms = win32com.client.DispatchEx("CorelDRAW.Application.23")
|
||||
|
||||
dogms.GMSManager.RunMacro("RUNDXF", "RUN.ExportSelectionToPSD", Index)
|
||||
|
||||
dogms.GMSManager.RunMacro("RUNDXF", "RUN.HOURUN", result_array_length)
|
||||
|
||||
modified_names = modified_names[total_pieces:]
|
||||
|
||||
Index += 1
|
||||
|
||||
|
||||
corel_app = win32com.client.Dispatch("CorelDRAW.Application.23")
|
||||
|
||||
corel_app .GMSManager.RunMacro("RUNDXF", "RUN.ActiveDocumentClose")
|
||||
|
||||
QMessageBox.warning(self, "提醒", "分割完成,请进行裁片套版操作。")
|
||||
|
||||
def updateLineEditsFromSizes(self):
|
||||
for size_label, line_edit in self.dxfLineEdits.items():
|
||||
self.sizes[size_label] = line_edit.text()
|
||||
|
||||
def populateScrollArea(self):
|
||||
self.clearScrollArea()
|
||||
for size_label, size_text in self.sizes.items():
|
||||
size_layout = QHBoxLayout()
|
||||
size_layout.addWidget(QLabel(size_label))
|
||||
|
||||
line_edit = QLineEdit()
|
||||
line_edit.setValidator(QIntValidator())
|
||||
line_edit.setFixedSize(100, 30)
|
||||
line_edit.setText(size_text)
|
||||
|
||||
self.dxfLineEdits[size_label] = line_edit
|
||||
size_layout.addWidget(line_edit)
|
||||
|
||||
self.scrollWidgetLayout.addLayout(size_layout)
|
||||
|
||||
def clearScrollArea(self):
|
||||
for i in reversed(range(self.scrollWidgetLayout.count())):
|
||||
item = self.scrollWidgetLayout.itemAt(i)
|
||||
if isinstance(item, QHBoxLayout) or isinstance(item, QVBoxLayout):
|
||||
while item.count():
|
||||
widget = item.takeAt(0).widget()
|
||||
if widget:
|
||||
widget.deleteLater()
|
||||
self.dxfLineEdits.clear() # 清空部件引用
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
mainWindow = YourMainWindow()
|
||||
mainWindow.show()
|
||||
sys.exit(app.exec_())
|
||||
283
psmark/Tab3.py
Normal file
283
psmark/Tab3.py
Normal file
@@ -0,0 +1,283 @@
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QVBoxLayout, QPushButton, QGroupBox, QLabel, QLineEdit, QFormLayout
|
||||
import piece_decorative
|
||||
|
||||
class ImportPDFDialog2(QMainWindow):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle('Import Multiple PDF pages')
|
||||
|
||||
main_widget = QWidget()
|
||||
self.setCentralWidget(main_widget)
|
||||
main_layout = QVBoxLayout()
|
||||
main_widget.setLayout(main_layout)
|
||||
|
||||
|
||||
new_group_box5 = QGroupBox('打版联动')
|
||||
new_group_layout5 = QVBoxLayout(new_group_box5)
|
||||
|
||||
# 创建4个按钮并连接到槽函数
|
||||
Dbtn4_1 = QPushButton('图层分割')
|
||||
Dbtn4_2 = QPushButton('批量图层编组')
|
||||
Dbtn4_3 = QPushButton('快速超链接')
|
||||
# Dbtn4_4 = QPushButton('定位点比例缩放(模板)')
|
||||
|
||||
Dbtn4_1.clicked.connect(self.on_Dbtn4_1_clicked)
|
||||
Dbtn4_2.clicked.connect(self.on_Dbtn4_2_clicked)
|
||||
Dbtn4_3.clicked.connect(self.on_Dbtn4_3_clicked)
|
||||
# Dbtn4_4.clicked.connect(self.on_Dbtn4_4_clicked)
|
||||
|
||||
# 将按钮添加到新的盒子1中
|
||||
new_group_layout5.addWidget(Dbtn4_1)
|
||||
new_group_layout5.addWidget(Dbtn4_2)
|
||||
new_group_layout5.addWidget(Dbtn4_3)
|
||||
# new_group_layout5.addWidget(Dbtn4_4)
|
||||
# 将新的盒子1添加到主布局中
|
||||
main_layout.addWidget(new_group_box5)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# 快速换图
|
||||
quick_change_group = QGroupBox('快速换图')
|
||||
quick_change_layout = QVBoxLayout(quick_change_group)
|
||||
# bigbtn_standardize_pattern = QPushButton('图像切割')
|
||||
btn_standardize_pattern = QPushButton('花样标准化')
|
||||
|
||||
btn_pattern_to_external = QPushButton('花样转外链')
|
||||
btn_quick_change = QPushButton('快速换图')
|
||||
btn_batch_quick_change = QPushButton('批量快速换图')
|
||||
btn_Kbatch_quick_change = QPushButton('特定版本快速换图')
|
||||
# 为每个按钮连接槽函数
|
||||
btn_standardize_pattern.clicked.connect(self.on_standardize_pattern_clicked)
|
||||
btn_pattern_to_external.clicked.connect(self.on_pattern_to_external_clicked)
|
||||
btn_quick_change.clicked.connect(self.on_quick_change_clicked)
|
||||
btn_batch_quick_change.clicked.connect(self.on_batch_quick_change_clicked)
|
||||
btn_Kbatch_quick_change.clicked.connect(self.on_kbatch_quick_change_clicked)
|
||||
# bigbtn_standardize_pattern.clicked.connect(self.on_bigstandardize_pattern_clicked)
|
||||
|
||||
quick_change_layout.addWidget(btn_standardize_pattern)
|
||||
# quick_change_layout.addWidget(bigbtn_standardize_pattern)
|
||||
quick_change_layout.addWidget(btn_pattern_to_external)
|
||||
quick_change_layout.addWidget(btn_quick_change)
|
||||
quick_change_layout.addWidget(btn_batch_quick_change)
|
||||
quick_change_layout.addWidget(btn_Kbatch_quick_change)
|
||||
|
||||
main_layout.addWidget(quick_change_group)
|
||||
|
||||
# 初始化界面
|
||||
|
||||
# 创建一个新的盒子
|
||||
new_group_box1 = QGroupBox('模板生成')
|
||||
new_group_layout1 = QVBoxLayout(new_group_box1)
|
||||
|
||||
# 创建4个按钮并连接到槽函数
|
||||
btn4_1 = QPushButton('通码延申(模板)')
|
||||
btn4_2 = QPushButton('宽高缩放(模板)')
|
||||
btn4_3 = QPushButton('比例缩放(模板)')
|
||||
btn4_4 = QPushButton('定位点比例缩放(模板)')
|
||||
|
||||
btn4_1.clicked.connect(self.on_btn4_1_clicked)
|
||||
btn4_2.clicked.connect(self.on_btn4_2_clicked)
|
||||
btn4_3.clicked.connect(self.on_btn4_3_clicked)
|
||||
btn4_4.clicked.connect(self.on_btn4_4_clicked)
|
||||
|
||||
# 将按钮添加到新的盒子1中
|
||||
new_group_layout1.addWidget(btn4_1)
|
||||
new_group_layout1.addWidget(btn4_2)
|
||||
new_group_layout1.addWidget(btn4_3)
|
||||
new_group_layout1.addWidget(btn4_4)
|
||||
# 将新的盒子1添加到主布局中
|
||||
main_layout.addWidget(new_group_box1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##############################################
|
||||
|
||||
new_group_box5 = QGroupBox('定位码快速换图')
|
||||
new_group_layout5 = QVBoxLayout(new_group_box5)
|
||||
|
||||
# 创建4个按钮并连接到槽函数
|
||||
Kbtn4_1 = QPushButton('定位码快速超链接')
|
||||
Kbtn4_2 = QPushButton('定位码快速换图')
|
||||
|
||||
# Dbtn4_4 = QPushButton('定位点比例缩放(模板)')
|
||||
|
||||
Kbtn4_1.clicked.connect(self.on_Kbtn4_1_clicked)
|
||||
Kbtn4_2.clicked.connect(self.on_Kbtn4_2_clicked)
|
||||
#Dbtn4_3.clicked.connect(self.on_Dbtn4_3_clicked)
|
||||
# Dbtn4_4.clicked.connect(self.on_Dbtn4_4_clicked)
|
||||
|
||||
# 将按钮添加到新的盒子1中
|
||||
new_group_layout5.addWidget(Kbtn4_1)
|
||||
new_group_layout5.addWidget(Kbtn4_2)
|
||||
# new_group_layout5.addWidget(Dbtn4_3)
|
||||
# new_group_layout5.addWidget(Dbtn4_4)
|
||||
# 将新的盒子1添加到主布局中
|
||||
main_layout.addWidget(new_group_box5)
|
||||
|
||||
|
||||
|
||||
##############################################
|
||||
|
||||
new_group_box2 = QGroupBox('批量化工具')
|
||||
new_group_layout2 = QVBoxLayout(new_group_box2)
|
||||
|
||||
# 创建4个按钮并连接到槽函数
|
||||
Pbtn4_1 = QPushButton('小码标添加')
|
||||
Pbtn4_2 = QPushButton('批量修改分辨率')
|
||||
Pbtn4_3 = QPushButton('批量加款号')
|
||||
# Pbtn4_4 = QPushButton('PNG图像分割')
|
||||
#Pbtn4_5 = QPushButton('幅宽扩展')
|
||||
|
||||
|
||||
Pbtn4_1.clicked.connect(self.on_Pbtn4_1_clicked)
|
||||
Pbtn4_2.clicked.connect(self.on_Pbtn4_2_clicked)
|
||||
Pbtn4_3.clicked.connect(self.on_Pbtn4_3_clicked)
|
||||
# Pbtn4_4.clicked.connect(self.on_Pbtn4_4_clicked)
|
||||
# Pbtn4_5.clicked.connect(self.on_Pbtn4_5_clicked)
|
||||
# 将按钮添加到新的盒子1中
|
||||
new_group_layout2.addWidget(Pbtn4_1)
|
||||
new_group_layout2.addWidget(Pbtn4_2)
|
||||
new_group_layout2.addWidget(Pbtn4_3)
|
||||
# new_group_layout2.addWidget(Pbtn4_4)
|
||||
# new_group_layout2.addWidget(Pbtn4_5)
|
||||
# 将新的盒子1添加到主布局中
|
||||
main_layout.addWidget(new_group_box2)
|
||||
|
||||
def on_kbatch_quick_change_clicked(self):
|
||||
piece_decorative.PS_DXF18_jscode_fun('龙服的快速换图();')
|
||||
|
||||
print("按钮被点击")
|
||||
pass
|
||||
|
||||
def on_Kbtn4_1_clicked(self):
|
||||
piece_decorative.PS_DXF16_jscode_fun('快速定位码链接();')
|
||||
|
||||
print("按钮被点击")
|
||||
pass
|
||||
|
||||
|
||||
def on_Kbtn4_2_clicked(self):
|
||||
piece_decorative.PS_DXF17_jscode_fun('定位码批量化替换外链新();')
|
||||
|
||||
print("按钮被点击")
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
def on_Dbtn4_1_clicked(self):
|
||||
piece_decorative.PS_DXF8_jscode_fun('图像分割();')
|
||||
|
||||
print("按钮被点击")
|
||||
pass
|
||||
|
||||
def on_Dbtn4_2_clicked(self):
|
||||
piece_decorative.PS_DXF15_jscode_fun('图层自动编组2();')
|
||||
|
||||
print("按钮被点击")
|
||||
pass
|
||||
|
||||
def on_Dbtn4_3_clicked(self):
|
||||
piece_decorative.PS_DXF15_jscode_fun('快速超级链接2();')
|
||||
|
||||
print("按钮被点击")
|
||||
pass
|
||||
|
||||
# def on_Dbtn4_4_clicked(self):
|
||||
# piece_decorative.PS_DXF8_jscode_fun('码标添加2();')
|
||||
#
|
||||
# print("按钮被点击")
|
||||
# pass
|
||||
|
||||
def on_Pbtn4_1_clicked(self):
|
||||
piece_decorative.PS_DXF8_jscode_fun('码标添加2();')
|
||||
|
||||
print("按钮被点击")
|
||||
pass
|
||||
|
||||
def on_Pbtn4_2_clicked(self):
|
||||
piece_decorative.PS_DXF8_jscode_fun('批量分辨率修改();')
|
||||
print("按钮被点击")
|
||||
pass
|
||||
|
||||
|
||||
def on_Pbtn4_3_clicked(self):
|
||||
piece_decorative.PS_DXF8_jscode_fun('批量款号添加();')
|
||||
print("按钮被点击")
|
||||
pass
|
||||
# 槽函数示例
|
||||
def on_standardize_pattern_clicked(self):
|
||||
piece_decorative.PS_DXF5_jscode_fun('花样标准化3();')
|
||||
print("花样标准化按钮被点击")
|
||||
|
||||
|
||||
def on_pattern_to_external_clicked(self):
|
||||
piece_decorative.PS_DXF5_jscode_fun('花样图层导出();')
|
||||
print("花样转外链按钮被点击")
|
||||
|
||||
def on_quick_change_clicked(self):
|
||||
piece_decorative.PS_DXF5_jscode_fun('替换外链新();')
|
||||
print("快速换图按钮被点击")
|
||||
|
||||
|
||||
|
||||
|
||||
def on_batch_quick_change_clicked(self):
|
||||
piece_decorative.PS_DXF8_jscode_fun('批量化替换外链新();')
|
||||
print("批量快速换图按钮被点击")
|
||||
|
||||
def on_btn4_1_clicked(self):
|
||||
# 处理新盒子1中按钮4_1的点击事件
|
||||
piece_decorative.PS_DXF_jscode_fun('删除指定名称蒙版();')
|
||||
piece_decorative.PS_DXF5_jscode_fun('裁片射出模板();')
|
||||
piece_decorative.PS_DXF2_jscode_fun('信息激活2();')
|
||||
pass
|
||||
|
||||
def on_btn4_2_clicked(self):
|
||||
# 处理新盒子1中按钮4_2的点击事件
|
||||
piece_decorative.PS_DXF_jscode_fun('删除指定名称蒙版();')
|
||||
piece_decorative.PS_DXF4_jscode_fun('裁片射出宽高缩放模板();')
|
||||
piece_decorative.PS_DXF2_jscode_fun('信息激活2();')
|
||||
pass
|
||||
|
||||
def on_btn4_3_clicked(self):
|
||||
# 处理新盒子1中按钮4_3的点击事件
|
||||
piece_decorative.PS_DXF_jscode_fun('删除指定名称蒙版();')
|
||||
piece_decorative.PS_DXF14_jscode_fun('裁片射出宽高缩放模板按中心();')
|
||||
piece_decorative.PS_DXF2_jscode_fun('信息激活2();')
|
||||
pass
|
||||
|
||||
def on_btn4_4_clicked(self):
|
||||
# 处理新盒子1中按钮4_3的点击事件
|
||||
piece_decorative.PS_DXF_jscode_fun('删除指定名称蒙版();')
|
||||
piece_decorative.PS_DXF7_jscode_fun('裁片射出缩放模板();')
|
||||
piece_decorative.PS_DXF2_jscode_fun('信息激活2();')
|
||||
pass
|
||||
|
||||
|
||||
# def on_Dbtn4_1_clicked(self):
|
||||
# # 处理新盒子1中按钮4_4的点击事件
|
||||
# piece_decorative.PS_DXF8_jscode_fun('图像分割();')
|
||||
# pass
|
||||
|
||||
def on_Pbtn4_5_clicked(self):
|
||||
# 处理新盒子1中按钮4_4的点击事件
|
||||
piece_decorative.PS_DXF11_jscode_fun('批量重设画布幅宽();')
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
dialog = ImportPDFDialog2()
|
||||
dialog.show()
|
||||
sys.exit(app.exec_())
|
||||
81
psmark/Tab4.py
Normal file
81
psmark/Tab4.py
Normal file
@@ -0,0 +1,81 @@
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QVBoxLayout, QPushButton, QGroupBox, QLabel, QFrame
|
||||
from PyQt5 import QtGui
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QApplication, QLabel, QVBoxLayout, QWidget
|
||||
from PyQt5.QtGui import QPixmap
|
||||
import os
|
||||
class ImportPDFDialog4(QMainWindow):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle('Import Multiple PDF pages')
|
||||
|
||||
main_widget = QWidget()
|
||||
self.setCentralWidget(main_widget)
|
||||
main_layout = QVBoxLayout()
|
||||
main_widget.setLayout(main_layout)
|
||||
|
||||
# 快速换图
|
||||
quick_change_group = QGroupBox('版本介绍')
|
||||
quick_change_layout = QVBoxLayout(quick_change_group)
|
||||
|
||||
# 创建图像标签1并调整大小
|
||||
image_label1 = QLabel()
|
||||
# 获取当前脚本所在目录的绝对路径
|
||||
current_directory = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# 构建相对路径
|
||||
image_filename = "img/微信图片_20230906013631.jpg"
|
||||
relative_path = os.path.join(current_directory, image_filename)
|
||||
|
||||
# 创建 QPixmap 对象
|
||||
pixmap1 = QtGui.QPixmap(relative_path)
|
||||
pixmap1 = pixmap1.scaledToWidth(200) # 设置宽度限制为200像素
|
||||
image_label1.setPixmap(pixmap1)
|
||||
quick_change_layout.addWidget(image_label1)
|
||||
|
||||
# 创建文本标签
|
||||
text_label1 = QLabel('关注抖音查看视频教程')
|
||||
text_label1.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
quick_change_layout.addWidget(text_label1)
|
||||
|
||||
# 创建分隔线
|
||||
divider1 = QFrame()
|
||||
divider1.setFrameShape(QFrame.HLine)
|
||||
quick_change_layout.addWidget(divider1)
|
||||
|
||||
# 创建图像标签2并调整大小
|
||||
image_label2 = QLabel()
|
||||
image_filename2 = "img/微信图片_20230906013548.jpg"
|
||||
relative_path2 = os.path.join(current_directory, image_filename2)
|
||||
|
||||
# 创建另一个 QPixmap 对象,使用不同的变量名
|
||||
pixmap2 = QtGui.QPixmap(relative_path2)
|
||||
pixmap2 = pixmap2.scaledToWidth(200) # 设置宽度限制为200像素
|
||||
image_label2.setPixmap(pixmap2)
|
||||
quick_change_layout.addWidget(image_label2)
|
||||
|
||||
# 创建文本标签
|
||||
text_label2 = QLabel('BUG提交 功能开发 使用反馈 请联系微信')
|
||||
text_label2.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
quick_change_layout.addWidget(text_label2)
|
||||
|
||||
# 创建分隔线
|
||||
divider2 = QFrame()
|
||||
divider2.setFrameShape(QFrame.HLine)
|
||||
quick_change_layout.addWidget(divider2)
|
||||
|
||||
# 创建文本标签
|
||||
text_label3 = QLabel('PS Mark 版本号1.8(2023.10.4) by:jimi')
|
||||
text_label3.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
quick_change_layout.addWidget(text_label3)
|
||||
|
||||
quick_change_group.setLayout(quick_change_layout)
|
||||
main_layout.addWidget(quick_change_group)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
dialog = ImportPDFDialog4()
|
||||
dialog.show()
|
||||
sys.exit(app.exec_())
|
||||
449
psmark/Tab5.py
Normal file
449
psmark/Tab5.py
Normal file
@@ -0,0 +1,449 @@
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QLabel, QPushButton, QFileDialog, \
|
||||
QLineEdit, QScrollArea, QGroupBox, QHBoxLayout, QMessageBox, QProgressDialog
|
||||
from PyQt5.QtGui import QIntValidator
|
||||
from PyQt5.QtCore import QTimer
|
||||
import re
|
||||
import os
|
||||
import ezdxf
|
||||
import ezdxf.tools
|
||||
import ezdxf.bbox
|
||||
import ezdxf.units
|
||||
import ezdxf.math
|
||||
from coreldraw_checker import is_coreldraw_running
|
||||
from functools import partial
|
||||
import win32com.client
|
||||
import os
|
||||
import shutil
|
||||
import threading
|
||||
from clear_folder import another_function
|
||||
|
||||
|
||||
class YourMainWindow5(QMainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.setWindowTitle("多码混排")
|
||||
|
||||
layout = QVBoxLayout()
|
||||
|
||||
self.button1 = QPushButton("DXF文件路径")
|
||||
self.button1.setFixedWidth(200)
|
||||
self.button1.clicked.connect(self.showDxfFileDialog)
|
||||
|
||||
self.button2 = QPushButton("PLT文件路径")
|
||||
self.button2.setFixedWidth(200)
|
||||
self.button2.clicked.connect(self.showPltFileDialog)
|
||||
|
||||
self.initial_button1_text = self.button1.text()
|
||||
self.initial_button2_text = self.button2.text()
|
||||
|
||||
panel1 = QGroupBox("文件路径")
|
||||
panel1_layout = QVBoxLayout(panel1)
|
||||
panel1_layout.setSpacing(10)
|
||||
panel1_layout.setContentsMargins(10, 10, 10, 10)
|
||||
panel1_layout.addWidget(self.button1)
|
||||
panel1_layout.addWidget(self.button2)
|
||||
layout.addWidget(panel1)
|
||||
|
||||
self.label5 = QLabel('单码片数')
|
||||
self.lineEdit3 = QLineEdit()
|
||||
self.lineEdit3.setValidator(QIntValidator())
|
||||
self.lineEdit3.setFixedSize(120, 30)
|
||||
layout.addWidget(self.label5)
|
||||
layout.addWidget(self.lineEdit3)
|
||||
|
||||
self.scrollWidget = QWidget()
|
||||
self.scrollWidgetLayout = QVBoxLayout(self.scrollWidget)
|
||||
self.scrollArea = QScrollArea()
|
||||
self.scrollArea.setWidget(self.scrollWidget)
|
||||
self.scrollArea.setWidgetResizable(True)
|
||||
layout.addWidget(self.scrollArea)
|
||||
|
||||
self.clearButton = QPushButton("清空信息")
|
||||
self.clearButton.clicked.connect(self.clearScrollArea)
|
||||
layout.addWidget(self.clearButton)
|
||||
|
||||
confirm_button = QPushButton("分割")
|
||||
confirm_button.clicked.connect(self.updateScrollArea)
|
||||
#confirm_button.clicked.connect(self.freezeAndParse) # 连接按钮点击事件
|
||||
layout.addWidget(confirm_button)
|
||||
|
||||
|
||||
central_widget = QWidget()
|
||||
central_widget.setLayout(layout)
|
||||
self.setCentralWidget(central_widget)
|
||||
|
||||
self.dxfLineEdits = {}
|
||||
|
||||
self.allowButtonActions = True # 标志变量,控制是否允许按钮行为
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def run_coreldraw_macros(self):
|
||||
try:
|
||||
dogms = win32com.client.DispatchEx("CorelDRAW.Application.23")
|
||||
|
||||
macros_to_run = [
|
||||
"RUN.OpenDXFFilesInFolder",
|
||||
"RUN.RotateSelectionClockwise",
|
||||
"RUN.DeleteUnnamedSublayers",
|
||||
"RUN.StToFront",
|
||||
"RUN.IterateSublayerNames",
|
||||
|
||||
|
||||
]
|
||||
|
||||
for macro in macros_to_run:
|
||||
dogms.GMSManager.RunMacro("RUNDXF", macro)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
QMessageBox.warning(self, "警告", "缺少CDR模块,请载入CDR模块", QMessageBox.Ok)
|
||||
# print("缺少CDR模块,请载入CDR模块")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def showPltFileDialog(self):
|
||||
options = QFileDialog.Options()
|
||||
file_path, _ = QFileDialog.getOpenFileName(self, "选择PLT文件", "", "PLT Files (*.plt);;All Files (*)",
|
||||
options=options)
|
||||
if file_path:
|
||||
print("Selected PLT file:", file_path)
|
||||
extracted_content = self.extract_content_from_plt_path(file_path)
|
||||
print(extracted_content)
|
||||
self.sizes = self.fill_sizes_from_extracted_content(extracted_content)
|
||||
|
||||
# 更新尺寸字典后,清空并填充滚动区域
|
||||
self.clearScrollArea()
|
||||
self.populateScrollArea()
|
||||
|
||||
self.initial_plt_path = file_path # 更新初始路径而不更新按钮文本
|
||||
|
||||
else:
|
||||
print("No PLT file selected")
|
||||
QMessageBox.warning(self, "警告", "没有选择文件夹。请重新选择文件夹。", QMessageBox.Ok)
|
||||
|
||||
pass
|
||||
|
||||
def showDxfFileDialog(self):
|
||||
options = QFileDialog.Options()
|
||||
file_path, _ = QFileDialog.getOpenFileName(self, "选择DXF文件", "", "DXF Files (*.dxf);;All Files (*)",
|
||||
options=options)
|
||||
if file_path:
|
||||
print("Selected DXF file:", file_path)
|
||||
self.initial_dxf_path = file_path # 更新初始路径而不更新按钮文本
|
||||
else:
|
||||
print("No DXF file selected")
|
||||
QMessageBox.warning(self, "警告", "没有选择文件夹。请重新选择文件夹。", QMessageBox.Ok)
|
||||
# 在此处添加提醒逻辑,例如使用 QMessageBox 提示用户没有选择文件
|
||||
|
||||
def extract_content_from_plt_path(self, plt_path):
|
||||
match = re.search(r'\((.*?)\)', plt_path)
|
||||
if match:
|
||||
extracted_content = match.group(1)
|
||||
return extracted_content
|
||||
else:
|
||||
return "No content in parentheses found"
|
||||
|
||||
def fill_sizes_from_extracted_content(self, extracted_content):
|
||||
sizes = extracted_content.split("+")
|
||||
size_dict = {}
|
||||
for size in sizes:
|
||||
size_dict[size] = ""
|
||||
return size_dict
|
||||
|
||||
def process_dxf_file(self, file_path, extracted_content):
|
||||
doc = ezdxf.readfile(file_path)
|
||||
msp = doc.modelspace()
|
||||
mspBox = ezdxf.bbox.extents(msp)
|
||||
|
||||
print("=====", os.path.basename(file_path))
|
||||
print("左上角坐标:", mspBox.extmin)
|
||||
print("画布宽:", mspBox.size[0], "画布高:", mspBox.size[1])
|
||||
print()
|
||||
|
||||
for entity in msp.query():
|
||||
if entity.dxftype() == "INSERT":
|
||||
temp = []
|
||||
rotation = None
|
||||
block = doc.blocks[entity.dxf.name]
|
||||
|
||||
for e in block:
|
||||
if e.dxftype() != "TEXT":
|
||||
temp.append(e)
|
||||
else:
|
||||
rotation = e.dxf.rotation
|
||||
|
||||
if rotation is not None:
|
||||
rotation %= 360
|
||||
if 45 <= rotation < 135:
|
||||
rotation = 90
|
||||
elif 135 <= rotation < 225:
|
||||
rotation = 180
|
||||
elif 225 <= rotation < 315:
|
||||
rotation = -90
|
||||
else:
|
||||
rotation = 0
|
||||
|
||||
print("=====", entity.dxf.name)
|
||||
print("大小:", ezdxf.bbox.extents(temp).size)
|
||||
print("文字角度:", rotation)
|
||||
|
||||
center = ezdxf.bbox.extents(temp).center
|
||||
center = (center.x, mspBox.extmax.y - center.y) # 调整center y值
|
||||
|
||||
print("中心坐标:", center)
|
||||
|
||||
center = (center[1], mspBox.size[0] - center[0]) # 旋转后中心坐标
|
||||
print("旋转后中心坐标:", center)
|
||||
|
||||
separator = "_" # 分隔符
|
||||
entity.dxf.name += separator + str(rotation)
|
||||
block.name += separator + str(rotation)
|
||||
|
||||
new_file_path = os.path.join(r"D:\marktemp", "{}.dxf".format(extracted_content))
|
||||
doc.saveas(new_file_path)
|
||||
def getSinglePieceCount(self):
|
||||
return self.lineEdit3.text()
|
||||
|
||||
def recreate_folders(self):
|
||||
# 定义文件夹路径
|
||||
folder_paths = [r"D:\PSMARKtemp", r"D:\marktemp"]
|
||||
|
||||
# 删除文件夹及其内容
|
||||
for folder_path in folder_paths:
|
||||
if os.path.exists(folder_path):
|
||||
shutil.rmtree(folder_path)
|
||||
print(f"Deleted folder: {folder_path}")
|
||||
|
||||
# 重新创建文件夹
|
||||
for folder_path in folder_paths:
|
||||
os.makedirs(folder_path)
|
||||
print(f"Recreated folder: {folder_path}")
|
||||
|
||||
def freezeAndParse(self):
|
||||
self.parse_button.setEnabled(False) # 冻结按钮
|
||||
QTimer.singleShot(10000, self.unfreezeButton) # 10秒后解冻按钮
|
||||
|
||||
def unfreezeButton(self):
|
||||
self.parse_button.setEnabled(True) # 解冻按钮
|
||||
|
||||
|
||||
def updateScrollArea(self):
|
||||
|
||||
another_function()
|
||||
|
||||
if not is_coreldraw_running():
|
||||
QMessageBox.warning(self, "警告", "CorelDRAW未运行,无法执行操作。")
|
||||
return
|
||||
|
||||
plt_file_path = self.initial_plt_path
|
||||
|
||||
# 获取DXF文件路径
|
||||
dxf_file_path = self.initial_dxf_path
|
||||
extracted_content = self.extract_content_from_plt_path(plt_file_path)
|
||||
|
||||
if dxf_file_path:
|
||||
# 去掉括号内内容后的PLT文件名作为DXF文件名
|
||||
plt_filename = os.path.basename(plt_file_path)
|
||||
# dxf_filename = re.sub(r'\(.*?\)', '', plt_filename)
|
||||
self.process_dxf_file(dxf_file_path, extracted_content) # 调用解析函数并传入单码片数和新的DXF文件名
|
||||
print("DXF文件解析完成!")
|
||||
else:
|
||||
QMessageBox.warning(self, "警告", "没有选择DXF文件。请先选择一个DXF文件。", QMessageBox.Ok)
|
||||
print()
|
||||
|
||||
|
||||
|
||||
self.run_coreldraw_macros()
|
||||
single_code_pieces = int(self.getSinglePieceCount()) # 获取单码片数
|
||||
print(single_code_pieces)
|
||||
# 打印滚动区域中的输入框内容
|
||||
code_quantities = {} # 创建一个新的字典用于存储数据
|
||||
|
||||
for label, line_edit in self.dxfLineEdits.items():
|
||||
text = line_edit.text()
|
||||
# print(f"Label: {label}, Text: {text}")
|
||||
if text.isdigit():
|
||||
value = int(text) # 尝试将文本转换为整数
|
||||
else:
|
||||
try:
|
||||
value = float(text) # 尝试将文本转换为浮点数
|
||||
except ValueError:
|
||||
print(f"Invalid value for {label}: {text}")
|
||||
continue # 转换失败,跳过当前循环迭代
|
||||
|
||||
code_quantities[label] = value # 存储转换后的数字到字典
|
||||
# print(line_edit)
|
||||
print(code_quantities)
|
||||
|
||||
keys_list = list(code_quantities.keys())
|
||||
values_list = list(code_quantities.values())
|
||||
|
||||
# length = len(code_quantities)
|
||||
# print(length) # 输出 3,因为字典中有三对键值对
|
||||
|
||||
|
||||
# 将text中的每个元素与code对应位置的元素相乘
|
||||
result = [txt * single_code_pieces for txt in values_list]
|
||||
|
||||
# 使用zip函数将label和result对应组合
|
||||
combined = zip(keys_list, result)
|
||||
|
||||
# 利用列表推导式生成结果数组
|
||||
results2 = [lbl for lbl, txt in combined for _ in range(txt)]
|
||||
|
||||
# 打印结果数组
|
||||
print(results2)
|
||||
|
||||
###############debug
|
||||
corel_app = win32com.client.Dispatch("CorelDRAW.Application.23")
|
||||
|
||||
# 获取当前活动文档
|
||||
active_document = corel_app.ActiveDocument
|
||||
|
||||
# 获取当前页面中所有图层的名称,排除特定名称的图层
|
||||
layer_names = [layer.Name for layer in active_document.ActivePage.Layers
|
||||
if layer.Name not in ["辅助线", "1", "0", "Defpoints"]]
|
||||
|
||||
p_numbers = [] # 初始化存储 P 数字的列表
|
||||
|
||||
for code, quantity in code_quantities.items():
|
||||
for i in range(1, single_code_pieces + 1):
|
||||
p_numbers.extend([f"P{i}"] * int(quantity))
|
||||
|
||||
print(p_numbers)
|
||||
|
||||
|
||||
|
||||
|
||||
# 循环遍历不同的码
|
||||
# p_numbers = [] # 初始化存储 P 数字的列表
|
||||
#
|
||||
# for code, quantity in code_quantities.items():
|
||||
# for i in range(1, single_code_pieces + 1):
|
||||
# # 根据码的数量分别生成对应数量的 P 数字,并添加到列表中
|
||||
# p_numbers.extend([f"P{i}"] * quantity)
|
||||
# print(p_numbers)
|
||||
new_layer_names = []
|
||||
index = 0
|
||||
for old_name in layer_names:
|
||||
parts = old_name.split("-") # 根据"-"分割字符串
|
||||
if len(parts) > 1:
|
||||
new_name = f"{p_numbers[index]}-{parts[1]}-{results2[index]}" # 使用数组中的 P 数字
|
||||
new_layer_names.append(new_name)
|
||||
index += 1
|
||||
|
||||
# 在新的图层名数组中遍历,对图层进行修改
|
||||
modified_names = [] # 创建一个列表来存储修改后的名称
|
||||
modified_names2 = []
|
||||
for i, new_name in enumerate(new_layer_names):
|
||||
active_document.ActivePage.Layers(layer_names[i]).Name = new_name
|
||||
modified_names2.append(new_name)
|
||||
modified_names.append(new_name)
|
||||
print(f"Modified: {layer_names[i]} -> {new_name}")
|
||||
|
||||
dogms = win32com.client.DispatchEx("CorelDRAW.Application.23")
|
||||
|
||||
#
|
||||
dogms.GMSManager.RunMacro("RUNDXF", "RUN.RUNPDF")
|
||||
#
|
||||
dogms.GMSManager.RunMacro("RUNDXF", "RUN.ActiveDocumentClose")
|
||||
###############debug
|
||||
|
||||
# print(modified_names)
|
||||
|
||||
######### ######### ######### ######### #########这里是对多码的功能 这里是删除的功能
|
||||
# def delete_layers_by_names(names_to_delete, active_document):
|
||||
# corel_app = win32com.client.Dispatch("CorelDRAW.Application.23")
|
||||
#
|
||||
# # 获取当前活动文档
|
||||
# active_document = corel_app.ActiveDocument
|
||||
# for target_layer_name in names_to_delete:
|
||||
# for layer in active_document.ActivePage.Layers:
|
||||
# if layer.Name == target_layer_name:
|
||||
# layer.Delete()
|
||||
# break # 找到目标图层后中断循环
|
||||
#
|
||||
#
|
||||
#
|
||||
# modified_names_list = [] # 用于存储每次循环中的 modified_names 列表
|
||||
# ######### ######### ######### ######### #########这里是对多码的功能 这里是导出PSD的功能 我这边要混排就对功能进行封禁
|
||||
# Index = 0
|
||||
# for code in code_quantities:
|
||||
# quantity = code_quantities[code]
|
||||
# total_pieces = quantity * single_code_pieces
|
||||
#
|
||||
# # 获取数组的前 total_pieces 个元素
|
||||
# newmodified_names_filtered = modified_names[:total_pieces]
|
||||
# # print(newmodified_names_filtered)
|
||||
#
|
||||
# result_array = [fruit for fruit in modified_names2 if fruit not in newmodified_names_filtered]
|
||||
# result_array_length = len(result_array)
|
||||
# print(result_array_length)
|
||||
#
|
||||
# delete_layers_by_names(result_array, active_document.ActivePage)
|
||||
# # modified_names_list.append(modified_names) # 将 modified_names 添加到数组中
|
||||
#
|
||||
#
|
||||
# dogms = win32com.client.DispatchEx("CorelDRAW.Application.23")
|
||||
#
|
||||
# dogms.GMSManager.RunMacro("RUNDXF", "RUN.ExportSelectionToPSD", Index)
|
||||
#
|
||||
# dogms.GMSManager.RunMacro("RUNDXF", "RUN.HOURUN", result_array_length)
|
||||
#
|
||||
# modified_names = modified_names[total_pieces:]
|
||||
#
|
||||
# Index += 1
|
||||
#
|
||||
#
|
||||
# corel_app = win32com.client.Dispatch("CorelDRAW.Application.23")
|
||||
#
|
||||
# corel_app .GMSManager.RunMacro("RUNDXF", "RUN.ActiveDocumentClose")
|
||||
#
|
||||
# QMessageBox.warning(self, "提醒", "分割完成,请进行裁片套版操作。")
|
||||
|
||||
def updateLineEditsFromSizes(self):
|
||||
for size_label, line_edit in self.dxfLineEdits.items():
|
||||
self.sizes[size_label] = line_edit.text()
|
||||
|
||||
def populateScrollArea(self):
|
||||
self.clearScrollArea()
|
||||
for size_label, size_text in self.sizes.items():
|
||||
size_layout = QHBoxLayout()
|
||||
size_layout.addWidget(QLabel(size_label))
|
||||
|
||||
line_edit = QLineEdit()
|
||||
line_edit.setValidator(QIntValidator())
|
||||
line_edit.setFixedSize(100, 30)
|
||||
line_edit.setText(size_text)
|
||||
|
||||
self.dxfLineEdits[size_label] = line_edit
|
||||
size_layout.addWidget(line_edit)
|
||||
|
||||
self.scrollWidgetLayout.addLayout(size_layout)
|
||||
|
||||
def clearScrollArea(self):
|
||||
for i in reversed(range(self.scrollWidgetLayout.count())):
|
||||
item = self.scrollWidgetLayout.itemAt(i)
|
||||
if isinstance(item, QHBoxLayout) or isinstance(item, QVBoxLayout):
|
||||
while item.count():
|
||||
widget = item.takeAt(0).widget()
|
||||
if widget:
|
||||
widget.deleteLater()
|
||||
self.dxfLineEdits.clear() # 清空部件引用
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
mainWindow = YourMainWindow5()
|
||||
mainWindow.show()
|
||||
sys.exit(app.exec_())
|
||||
33
psmark/clear_folder.py
Normal file
33
psmark/clear_folder.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
import threading
|
||||
|
||||
def clear_folder_contents(folder_paths):
|
||||
def clear_folder(folder_path):
|
||||
try:
|
||||
for filename in os.listdir(folder_path):
|
||||
file_path = os.path.join(folder_path, filename)
|
||||
try:
|
||||
if os.path.isfile(file_path):
|
||||
os.unlink(file_path)
|
||||
elif os.path.isdir(file_path):
|
||||
clear_folder(file_path)
|
||||
os.rmdir(file_path)
|
||||
except Exception as e:
|
||||
print(f"无法删除 {file_path}: {e}")
|
||||
except Exception as e:
|
||||
print(f"无法列出文件夹内容 {folder_path}: {e}")
|
||||
|
||||
for folder_path in folder_paths:
|
||||
thread = threading.Thread(target=clear_folder, args=(folder_path,))
|
||||
thread.start()
|
||||
|
||||
def another_function():
|
||||
folder1_to_clear = "D:\PSMarktemp"
|
||||
#folder2_to_clear = "D:\MarkTemp\DXFmarktemp"
|
||||
folder3_to_clear = "D:\markTemp"
|
||||
folders_to_clear = [folder1_to_clear,folder3_to_clear]
|
||||
clear_folder_contents(folders_to_clear)
|
||||
|
||||
# 在另一个函数中执行清空两个文件夹内容的操作
|
||||
|
||||
# folder_paths = [r"D:\MarkTemp\PSMarktemp", r"D:\MarkTemp\marktemp", r"D:\MarkTemp\marktemp"]
|
||||
7
psmark/coreldraw_checker.py
Normal file
7
psmark/coreldraw_checker.py
Normal file
@@ -0,0 +1,7 @@
|
||||
import psutil
|
||||
|
||||
def is_coreldraw_running():
|
||||
for process in psutil.process_iter(['pid', 'name']):
|
||||
if process.info['name'] == "CorelDRW.exe":
|
||||
return True
|
||||
return False
|
||||
31
psmark/cs.py
Normal file
31
psmark/cs.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import os
|
||||
import threading
|
||||
|
||||
def clear_folder_contents(folder_paths):
|
||||
def clear_folder(folder_path):
|
||||
try:
|
||||
for filename in os.listdir(folder_path):
|
||||
file_path = os.path.join(folder_path, filename)
|
||||
try:
|
||||
if os.path.isfile(file_path):
|
||||
os.unlink(file_path)
|
||||
elif os.path.isdir(file_path):
|
||||
clear_folder(file_path)
|
||||
os.rmdir(file_path)
|
||||
except Exception as e:
|
||||
print(f"无法删除 {file_path}: {e}")
|
||||
except Exception as e:
|
||||
print(f"无法列出文件夹内容 {folder_path}: {e}")
|
||||
|
||||
for folder_path in folder_paths:
|
||||
thread = threading.Thread(target=clear_folder, args=(folder_path,))
|
||||
thread.start()
|
||||
|
||||
def another_function():
|
||||
folder1_to_clear = "D:\PSMARKtemp"
|
||||
folder2_to_clear = "D:\marktemp"
|
||||
folders_to_clear = [folder1_to_clear, folder2_to_clear]
|
||||
clear_folder_contents(folders_to_clear)
|
||||
|
||||
# 在另一个函数中执行清空两个文件夹内容的操作
|
||||
|
||||
BIN
psmark/icons/newapp.ico
Normal file
BIN
psmark/icons/newapp.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.1 KiB |
BIN
psmark/img/微信图片_20230906013548.jpg
Normal file
BIN
psmark/img/微信图片_20230906013548.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 119 KiB |
BIN
psmark/img/微信图片_20230906013631.jpg
Normal file
BIN
psmark/img/微信图片_20230906013631.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 114 KiB |
51
psmark/main.spec
Normal file
51
psmark/main.spec
Normal file
@@ -0,0 +1,51 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
|
||||
block_cipher = None
|
||||
|
||||
|
||||
a = Analysis(
|
||||
['main.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False,
|
||||
)
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name='main',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
console=False,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
icon=['newapp.ico'],
|
||||
)
|
||||
coll = COLLECT(
|
||||
exe,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
name='main',
|
||||
)
|
||||
86
psmark/myskin_styles.py
Normal file
86
psmark/myskin_styles.py
Normal file
@@ -0,0 +1,86 @@
|
||||
from os.path import join, dirname, abspath
|
||||
from qtpy.QtGui import QPalette, QColor
|
||||
import qtpy, platform
|
||||
|
||||
QT_VERSION = tuple((int(v) for v in qtpy.QT_VERSION.split('.')))
|
||||
PLATFORM = platform.system()
|
||||
_STYLESHEET = 'black.css'
|
||||
|
||||
def _apply_base_theme(app):
|
||||
""" Apply base theme to the application.
|
||||
|
||||
Args:
|
||||
app (QApplication): QApplication instance.
|
||||
"""
|
||||
if QT_VERSION < (5, ):
|
||||
app.setStyle('plastique')
|
||||
else:
|
||||
app.setStyle('Fusion')
|
||||
with open(_STYLESHEET) as stylesheet:
|
||||
app.setStyleSheet(stylesheet.read())
|
||||
|
||||
|
||||
def dark(app):
|
||||
""" Apply Dark Theme to the Qt application instance.
|
||||
|
||||
Args:
|
||||
app (QApplication): QApplication instance.
|
||||
"""
|
||||
darkPalette = QPalette()
|
||||
darkPalette.setColor(QPalette.WindowText, QColor(180, 180, 180))
|
||||
darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
|
||||
darkPalette.setColor(QPalette.Light, QColor(180, 180, 180))
|
||||
darkPalette.setColor(QPalette.Midlight, QColor(90, 90, 90))
|
||||
darkPalette.setColor(QPalette.Dark, QColor(35, 35, 35))
|
||||
darkPalette.setColor(QPalette.Text, QColor(180, 180, 180))
|
||||
darkPalette.setColor(QPalette.BrightText, QColor(180, 180, 180))
|
||||
darkPalette.setColor(QPalette.ButtonText, QColor(180, 180, 180))
|
||||
darkPalette.setColor(QPalette.Base, QColor(42, 42, 42))
|
||||
darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
|
||||
darkPalette.setColor(QPalette.Shadow, QColor(20, 20, 20))
|
||||
darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
|
||||
darkPalette.setColor(QPalette.HighlightedText, QColor(180, 180, 180))
|
||||
darkPalette.setColor(QPalette.Link, QColor(56, 252, 196))
|
||||
darkPalette.setColor(QPalette.AlternateBase, QColor(66, 66, 66))
|
||||
darkPalette.setColor(QPalette.ToolTipBase, QColor(53, 53, 53))
|
||||
darkPalette.setColor(QPalette.ToolTipText, QColor(180, 180, 180))
|
||||
darkPalette.setColor(QPalette.Disabled, QPalette.WindowText, QColor(127, 127, 127))
|
||||
darkPalette.setColor(QPalette.Disabled, QPalette.Text, QColor(127, 127, 127))
|
||||
darkPalette.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(127, 127, 127))
|
||||
darkPalette.setColor(QPalette.Disabled, QPalette.Highlight, QColor(80, 80, 80))
|
||||
darkPalette.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(127, 127, 127))
|
||||
app.setPalette(darkPalette)
|
||||
_apply_base_theme(app)
|
||||
|
||||
|
||||
def light(app):
|
||||
""" Apply Light Theme to the Qt application instance.
|
||||
|
||||
Args:
|
||||
app (QApplication): QApplication instance.
|
||||
"""
|
||||
lightPalette = QPalette()
|
||||
lightPalette.setColor(QPalette.WindowText, QColor(0, 0, 0))
|
||||
lightPalette.setColor(QPalette.Button, QColor(240, 240, 240))
|
||||
lightPalette.setColor(QPalette.Light, QColor(180, 180, 180))
|
||||
lightPalette.setColor(QPalette.Midlight, QColor(200, 200, 200))
|
||||
lightPalette.setColor(QPalette.Dark, QColor(225, 225, 225))
|
||||
lightPalette.setColor(QPalette.Text, QColor(0, 0, 0))
|
||||
lightPalette.setColor(QPalette.BrightText, QColor(0, 0, 0))
|
||||
lightPalette.setColor(QPalette.ButtonText, QColor(0, 0, 0))
|
||||
lightPalette.setColor(QPalette.Base, QColor(237, 237, 237))
|
||||
lightPalette.setColor(QPalette.Window, QColor(240, 240, 240))
|
||||
lightPalette.setColor(QPalette.Shadow, QColor(20, 20, 20))
|
||||
lightPalette.setColor(QPalette.Highlight, QColor(76, 163, 224))
|
||||
lightPalette.setColor(QPalette.HighlightedText, QColor(0, 0, 0))
|
||||
lightPalette.setColor(QPalette.Link, QColor(0, 162, 232))
|
||||
lightPalette.setColor(QPalette.AlternateBase, QColor(225, 225, 225))
|
||||
lightPalette.setColor(QPalette.ToolTipBase, QColor(240, 240, 240))
|
||||
lightPalette.setColor(QPalette.ToolTipText, QColor(0, 0, 0))
|
||||
lightPalette.setColor(QPalette.Disabled, QPalette.WindowText, QColor(115, 115, 115))
|
||||
lightPalette.setColor(QPalette.Disabled, QPalette.Text, QColor(115, 115, 115))
|
||||
lightPalette.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(115, 115, 115))
|
||||
lightPalette.setColor(QPalette.Disabled, QPalette.Highlight, QColor(190, 190, 190))
|
||||
lightPalette.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(115, 115, 115))
|
||||
app.setPalette(lightPalette)
|
||||
_apply_base_theme(app)
|
||||
159
psmark/myskin_windows.py
Normal file
159
psmark/myskin_windows.py
Normal file
@@ -0,0 +1,159 @@
|
||||
from os.path import join, dirname, abspath
|
||||
from qtpy.QtCore import Qt, QMetaObject, Signal, Slot, QEvent
|
||||
from qtpy.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QToolButton, QLabel, QSizePolicy
|
||||
from PyQt5.QtGui import QIcon, QPixmap
|
||||
import qtpy, platform
|
||||
|
||||
QT_VERSION = tuple((int(v) for v in qtpy.QT_VERSION.split('.')))
|
||||
PLATFORM = platform.system()
|
||||
_FL_STYLESHEET = 'frameless.qss'
|
||||
|
||||
class WindowDragger(QWidget):
|
||||
'''Window dragger.
|
||||
Args:
|
||||
window (QWidget): Associated window.
|
||||
parent (QWidget, optional): Parent widget.
|
||||
'''
|
||||
doubleClicked = Signal()
|
||||
|
||||
def __init__(self, window, parent=None):
|
||||
QWidget.__init__(self, parent)
|
||||
self._window = window
|
||||
self._mousePressed = False
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
self._mousePressed = True
|
||||
self._mousePos = event.globalPos()
|
||||
self._windowPos = self._window.pos()
|
||||
|
||||
def mouseMoveEvent(self, event):
|
||||
if self._mousePressed:
|
||||
self._window.move(self._windowPos + (event.globalPos() - self._mousePos))
|
||||
|
||||
def mouseReleaseEvent(self, event):
|
||||
self._mousePressed = False
|
||||
|
||||
def mouseDoubleClickEvent(self, event):
|
||||
self.doubleClicked.emit()
|
||||
|
||||
|
||||
class ModernWindow(QWidget):
|
||||
'''
|
||||
Modern window.
|
||||
Args:
|
||||
w (QWidget): Main widget.
|
||||
parent (QWidget, optional): Parent widget.
|
||||
'''
|
||||
|
||||
def __init__(self, w, parent=None):
|
||||
QWidget.__init__(self, parent)
|
||||
self._w = w
|
||||
self.setupUi()
|
||||
contentLayout = QHBoxLayout()
|
||||
contentLayout.setContentsMargins(0, 0, 0, 0)
|
||||
contentLayout.addWidget(w)
|
||||
self.windowContent.setLayout(contentLayout)
|
||||
self.setWindowTitle(w.windowTitle())
|
||||
self.setGeometry(w.geometry())
|
||||
self._w.setAttribute(Qt.WA_DeleteOnClose, True)
|
||||
self._w.destroyed.connect(self._ModernWindow__child_was_closed)
|
||||
|
||||
def setupUi(self):
|
||||
self.vboxWindow = QVBoxLayout(self)
|
||||
self.vboxWindow.setContentsMargins(0, 0, 0, 0)
|
||||
self.windowFrame = QWidget(self)
|
||||
self.windowFrame.setObjectName('windowFrame')
|
||||
self.vboxFrame = QVBoxLayout(self.windowFrame)
|
||||
self.vboxFrame.setContentsMargins(0, 0, 0, 0)
|
||||
self.titleBar = WindowDragger(self, self.windowFrame)
|
||||
self.titleBar.setObjectName('titleBar')
|
||||
self.titleBar.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed))
|
||||
self.hboxTitle = QHBoxLayout(self.titleBar)
|
||||
self.hboxTitle.setContentsMargins(0, 0, 0, 0)
|
||||
self.hboxTitle.setSpacing(0)
|
||||
titleIcon = QPixmap('./ui/icon.png')
|
||||
Icon = QLabel()
|
||||
Icon.setPixmap(titleIcon.scaled(30, 30))
|
||||
self.icon = Icon
|
||||
self.icon.setAlignment(Qt.AlignLeft)
|
||||
self.lblTitle = QLabel('Title')
|
||||
self.lblTitle.setObjectName('lblTitle')
|
||||
self.lblTitle.setAlignment(Qt.AlignVCenter)
|
||||
spButtons = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
||||
self.btnMinimize = QToolButton(self.titleBar)
|
||||
self.btnMinimize.setObjectName('btnMinimize')
|
||||
self.btnMinimize.setSizePolicy(spButtons)
|
||||
self.btnRestore = QToolButton(self.titleBar)
|
||||
self.btnRestore.setObjectName('btnRestore')
|
||||
self.btnRestore.setSizePolicy(spButtons)
|
||||
self.btnRestore.setVisible(False)
|
||||
self.btnMaximize = QToolButton(self.titleBar)
|
||||
self.btnMaximize.setObjectName('btnMaximize')
|
||||
self.btnMaximize.setSizePolicy(spButtons)
|
||||
self.btnClose = QToolButton(self.titleBar)
|
||||
self.btnClose.setObjectName('btnClose')
|
||||
self.btnClose.setSizePolicy(spButtons)
|
||||
self.vboxFrame.addWidget(self.titleBar)
|
||||
self.windowContent = QWidget(self.windowFrame)
|
||||
self.vboxFrame.addWidget(self.windowContent)
|
||||
self.vboxWindow.addWidget(self.windowFrame)
|
||||
PLATFORM = '1Darwin'
|
||||
if PLATFORM == 'Darwin':
|
||||
self.hboxTitle.addWidget(self.btnClose)
|
||||
self.hboxTitle.addWidget(self.btnMinimize)
|
||||
self.hboxTitle.addWidget(self.btnRestore)
|
||||
self.hboxTitle.addWidget(self.btnMaximize)
|
||||
self.hboxTitle.addWidget(self.lblTitle)
|
||||
else:
|
||||
self.hboxTitle.addWidget(self.icon)
|
||||
self.hboxTitle.addWidget(self.lblTitle)
|
||||
self.hboxTitle.addWidget(self.btnMinimize)
|
||||
self.hboxTitle.addWidget(self.btnRestore)
|
||||
self.hboxTitle.addWidget(self.btnMaximize)
|
||||
self.hboxTitle.addWidget(self.btnClose)
|
||||
self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint | Qt.WindowSystemMenuHint)
|
||||
with open(_FL_STYLESHEET) as (stylesheet):
|
||||
self.setStyleSheet(stylesheet.read())
|
||||
QMetaObject.connectSlotsByName(self)
|
||||
|
||||
def __child_was_closed(self):
|
||||
self._w = None
|
||||
self.close()
|
||||
|
||||
def closeEvent(self, event):
|
||||
if not self._w:
|
||||
event.accept()
|
||||
else:
|
||||
self._w.close()
|
||||
event.setAccepted(self._w.isHidden())
|
||||
|
||||
def setWindowTitle(self, title):
|
||||
super(ModernWindow, self).setWindowTitle(title)
|
||||
self.lblTitle.setText(title)
|
||||
|
||||
@Slot()
|
||||
def on_btnMinimize_clicked(self):
|
||||
self.setWindowState(Qt.WindowMinimized)
|
||||
|
||||
@Slot()
|
||||
def on_btnRestore_clicked(self):
|
||||
self.btnRestore.setVisible(False)
|
||||
self.btnMaximize.setVisible(True)
|
||||
self.setWindowState(Qt.WindowNoState)
|
||||
|
||||
@Slot()
|
||||
def on_btnMaximize_clicked(self):
|
||||
self.btnRestore.setVisible(True)
|
||||
self.btnMaximize.setVisible(False)
|
||||
self.setWindowState(Qt.WindowMaximized)
|
||||
|
||||
@Slot()
|
||||
def on_btnClose_clicked(self):
|
||||
self.close()
|
||||
|
||||
@Slot()
|
||||
def on_titleBar_doubleClicked(self):
|
||||
if self.btnMaximize.isVisible():
|
||||
self.on_btnMaximize_clicked()
|
||||
else:
|
||||
self.on_btnRestore_clicked()
|
||||
319
psmark/newMark.py
Normal file
319
psmark/newMark.py
Normal file
@@ -0,0 +1,319 @@
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QTabWidget, QPushButton, QLabel, QVBoxLayout, QWidget, QHBoxLayout, QFrame, QMessageBox
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtCore import Qt
|
||||
from Tab1 import ImportPDFDialog
|
||||
from Tab2 import YourMainWindow
|
||||
from Tab3 import ImportPDFDialog2
|
||||
from Tab4 import ImportPDFDialog4
|
||||
import qdarktheme
|
||||
import sys
|
||||
import subprocess
|
||||
import re
|
||||
import hashlib
|
||||
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QPushButton, QGroupBox, \
|
||||
QSpacerItem, QSizePolicy, QMessageBox
|
||||
import pymysql
|
||||
import piece_decorative
|
||||
import configparser
|
||||
|
||||
def exception_hook(exctype, value, traceback):
|
||||
# Handle the uncaught exception
|
||||
# 处理未捕获的异常
|
||||
QMessageBox.warning(None, "错误", f"发生了未知的异常:{value}")
|
||||
|
||||
# class LoginDialog(QWidget):
|
||||
# def __init__(self):
|
||||
# super().__init__()
|
||||
# self.setWindowTitle("PSMARK登录界面")
|
||||
# self.setWindowIcon(QIcon("icons/newapp.ico")) # 设置窗口小图标,替换为您的图标文件路径
|
||||
#
|
||||
# self.resize(300, 200)
|
||||
#
|
||||
# 主布局 = QVBoxLayout()
|
||||
#
|
||||
# group1 = QGroupBox("登录验证")
|
||||
# group1_layout = QVBoxLayout()
|
||||
#
|
||||
# group2 = QHBoxLayout()
|
||||
# label1 = QLabel("用户名")
|
||||
# self.edit1 = QLineEdit()
|
||||
# self.edit1.setFixedWidth(200)
|
||||
# spacer1 = QSpacerItem(40, 10, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
# group2.addWidget(label1)
|
||||
# group2.addItem(spacer1)
|
||||
# group2.addWidget(self.edit1)
|
||||
#
|
||||
# group3 = QHBoxLayout()
|
||||
# label2 = QLabel("密码")
|
||||
# self.edit2 = QLineEdit()
|
||||
# self.edit2.setFixedWidth(200)
|
||||
# self.edit2.setEchoMode(QLineEdit.Password) # 设置密码输入框为密文
|
||||
# spacer2 = QSpacerItem(40, 10, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
# group3.addWidget(label2)
|
||||
# group3.addItem(spacer2)
|
||||
# group3.addWidget(self.edit2)
|
||||
#
|
||||
#
|
||||
#
|
||||
# group4 = QHBoxLayout()
|
||||
# button1 = QPushButton("登录")
|
||||
# button2 = QPushButton("注册")
|
||||
# group4.addWidget(button1)
|
||||
# group4.addWidget(button2)
|
||||
#
|
||||
# group1_layout.addLayout(group2)
|
||||
# group1_layout.addLayout(group3)
|
||||
# group1_layout.addLayout(group4)
|
||||
# group1.setLayout(group1_layout)
|
||||
#
|
||||
# 主布局.addWidget(group1)
|
||||
#
|
||||
# group5 = QHBoxLayout()
|
||||
# label3 = QLabel("机器码")
|
||||
# self.edit3 = QLineEdit()
|
||||
# self.edit3.setFixedWidth(200)
|
||||
#
|
||||
# # 获取主板序列号并提取数字部分
|
||||
# try:
|
||||
# result = subprocess.run(['wmic', 'baseboard', 'get', 'serialnumber'], stdout=subprocess.PIPE,
|
||||
# stderr=subprocess.PIPE, text=True)
|
||||
# motherboard_serial = result.stdout.strip()
|
||||
#
|
||||
# # 使用正则表达式提取数字
|
||||
# motherboard_serial = re.sub(r'\D', '', motherboard_serial)
|
||||
#
|
||||
# # 使用SHA-256加密特征码
|
||||
# feature_code = hashlib.sha256(motherboard_serial.encode()).hexdigest()
|
||||
#
|
||||
# # 去掉特征码中的英文字符
|
||||
# feature_code = re.sub(r'[a-zA-Z]', '', feature_code)
|
||||
# except Exception as e:
|
||||
# feature_code = "Error: " + str(e)
|
||||
#
|
||||
# self.edit3.setText(feature_code) # 将加密后的特征码设置为 "特征码" 输入框的文本
|
||||
# self.rem_user()
|
||||
#
|
||||
# spacer3 = QSpacerItem(10, 10, QSizePolicy.Fixed, QSizePolicy.Minimum)
|
||||
# group5.addWidget(label3)
|
||||
# group5.addItem(spacer3)
|
||||
# group5.addWidget(self.edit3)
|
||||
#
|
||||
# 主布局.addLayout(group5)
|
||||
#
|
||||
# self.setLayout(主布局)
|
||||
#
|
||||
# # 链接登录的点击事件
|
||||
# button1.clicked.connect(self.slot_login)
|
||||
# # 连接注册按钮的点击事件
|
||||
# button2.clicked.connect(self.show_warning_message)
|
||||
#
|
||||
# #记住密码
|
||||
# def rem_user(self):
|
||||
#
|
||||
# piece_decorative.config = configparser.ConfigParser()
|
||||
# piece_decorative.config.read('程序配置.ini', encoding='utf-8')
|
||||
# piece_decorative.PS应用名 = piece_decorative.config.get('程序配置', 'PS应用名')
|
||||
# self.window = MainWindow()
|
||||
# self.window.show()
|
||||
# self.close()
|
||||
# return
|
||||
#
|
||||
# code = self.edit3.text()
|
||||
# # 执行SQL语句,从user数据表中查询字段值
|
||||
# cur.execute(f"SELECT username,password,code FROM {User}")
|
||||
# # 将数据库查询的结果保存在result中
|
||||
# result = cur.fetchall()
|
||||
# code_list = [it[2] for it in result] # 从数据库查询的result中遍历查询元组中第3个元素code
|
||||
# if code in code_list:
|
||||
# user_name = result[code_list.index(code)][0]
|
||||
# user_password = result[code_list.index(code)][1]
|
||||
# self.edit1.setText(user_name)
|
||||
# self.edit2.setText(user_password)
|
||||
# else:
|
||||
# pass
|
||||
#
|
||||
# def slot_login(self):
|
||||
# user_name = self.edit1.text()
|
||||
# user_password = self.edit2.text()
|
||||
# code = self.edit3.text()
|
||||
# # print(user_name,user_password)
|
||||
# # 执行SQL语句,从user数据表中查询code和time字段值
|
||||
# cur.execute(f"SELECT username,password,code FROM {User}")
|
||||
# # 将数据库查询的结果保存在result中
|
||||
# result = cur.fetchall()
|
||||
# name_list = [it[0] for it in result] # 从数据库查询的result中遍历查询元组中第一个元素name
|
||||
# # 判断用户名或密码不能为空
|
||||
# if not (user_name and user_password):
|
||||
# QMessageBox.critical(self, "错误", "用户名或密码不能为空!")
|
||||
# # 判断用户名和密码是否匹配
|
||||
# elif user_name in name_list:
|
||||
# if user_password == result[name_list.index(user_name)][1]:
|
||||
# if code == result[name_list.index(user_name)][2]:
|
||||
# piece_decorative.config = configparser.ConfigParser()
|
||||
# piece_decorative.config.read('程序配置.ini', encoding='utf-8')
|
||||
# piece_decorative.PS应用名 = piece_decorative.config.get('程序配置', 'PS应用名')
|
||||
# self.window = MainWindow()
|
||||
# self.window.show()
|
||||
# self.close()
|
||||
# else:
|
||||
# QMessageBox.critical(self, "错误", "机器码不匹配!")
|
||||
# # QMessageBox.information(self, "欢迎您", "登录成功!\n在此添加新界面!")
|
||||
# else:
|
||||
# QMessageBox.critical(self, "错误", "密码输入错误!")
|
||||
# # 账号不在数据库中,则弹出是否注册的框
|
||||
# else:
|
||||
# QMessageBox.critical(self, "错误", "该账号不存在,请注册!")
|
||||
#
|
||||
# def show_warning_message(self):
|
||||
# # 弹出警告消息框
|
||||
# QMessageBox.critical(self, "错误", "请联系管理员 17520145271!")
|
||||
# # warning_message = QMessageBox()
|
||||
# # warning_message.setIcon(QMessageBox.Warning)
|
||||
# # warning_message.setWindowTitle("警告")
|
||||
# # warning_message.setText("请联系管理员 17520145271")
|
||||
# # warning_message.exec_()
|
||||
|
||||
#################################自定义tab标签#################################
|
||||
from PyQt5 import QtGui, QtCore, QtWidgets
|
||||
|
||||
class MyTabBar(QtWidgets.QTabBar):
|
||||
def paintEvent(self, event):
|
||||
painter = QtWidgets.QStylePainter(self)
|
||||
option = QtWidgets.QStyleOptionTab()
|
||||
for index in range(self.count()):
|
||||
self.initStyleOption(option, index)
|
||||
painter.drawControl(QtWidgets.QStyle.CE_TabBarTabShape, option)
|
||||
painter.drawText(
|
||||
self.tabRect(index),
|
||||
QtCore.Qt.AlignCenter | QtCore.Qt.TextDontClip,
|
||||
"\n".join(self.tabText(index)))
|
||||
|
||||
def tabSizeHint(self, index):
|
||||
#size = QtWidgets.QTabBar.tabSizeHint(self, index)
|
||||
width = max([QtWidgets.QTabBar.fontMetrics(self).width(text) for text in self.tabText(index)])
|
||||
height = len(self.tabText(index)) * QtWidgets.QTabBar.fontMetrics(self).lineSpacing()
|
||||
return QtCore.QSize(width + 12, height + 12)
|
||||
|
||||
class TabWidget(QtWidgets.QTabWidget):
|
||||
def __init__(self, parent=None):
|
||||
QtWidgets.QTabWidget.__init__(self, parent)
|
||||
self.setTabBar(MyTabBar())
|
||||
#################################自定义tab标签#################################
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.setWindowTitle("PS Mark")
|
||||
self.setWindowIcon(QIcon("icons/newapp.ico")) # 设置窗口小图标,替换为您的图标文件路径
|
||||
|
||||
main_widget = QWidget()
|
||||
self.setCentralWidget(main_widget)
|
||||
|
||||
main_layout = QVBoxLayout()
|
||||
main_widget.setLayout(main_layout)
|
||||
|
||||
tab_widget = TabWidget()
|
||||
tab_widget.setTabPosition(TabWidget.West)
|
||||
#tab_widget.tabBar().setStyle(TabBarStyle(Qt.Vertical))
|
||||
main_layout.addWidget(tab_widget)
|
||||
|
||||
tab2 = YourMainWindow()
|
||||
tab_widget.addTab(tab2, "纸样分割")
|
||||
|
||||
tab1 = ImportPDFDialog()
|
||||
tab_widget.addTab(tab1, "裁片套版")
|
||||
|
||||
# tab3 = ImportPDFDialog2()
|
||||
# tab_widget.addTab(tab3, "快速换图")
|
||||
|
||||
# tab4 = ImportPDFDialog4()
|
||||
# tab_widget.addTab(tab4, "版本介绍")
|
||||
|
||||
separator = QFrame()
|
||||
separator.setFrameShape(QFrame.HLine)
|
||||
separator.setFrameShadow(QFrame.Sunken)
|
||||
main_layout.addWidget(separator)
|
||||
|
||||
custom_label = QLabel("欢迎使用,尊敬的内测用户!!!PS Mark(1.8)")
|
||||
#############8-12号修复了宽高缩放跟比例缩放超过10个裁片就会定位不准的bug
|
||||
#############8-12号将缩水值跟前缀添加改为了前置条件
|
||||
#############8-24号新增Tab2界面 将DXF解析与CDR结合在一起 可以实现分段排版
|
||||
|
||||
|
||||
main_layout.addWidget(custom_label)
|
||||
|
||||
# self.setLayout(main_layout)
|
||||
# self.setWindowTitle("分割线和自定义文字示例")
|
||||
# settings_button = QPushButton(QIcon("icons/转换.png"), "")
|
||||
|
||||
# settings_button.setObjectName("settingsButton") # 设置对象名称以供样式表选择
|
||||
# settings_button.setStyleSheet("border: none;") # 设置按钮无边框
|
||||
# main_layout.addWidget(settings_button, alignment=Qt.AlignLeft)
|
||||
|
||||
# 设置窗口始终置顶
|
||||
self.setWindowFlags(Qt.WindowStaysOnTopHint)
|
||||
|
||||
self.width_ratio = 0.3
|
||||
self.height_ratio = 1
|
||||
|
||||
self.initial_width = self.width()
|
||||
self.initial_height = self.height()
|
||||
|
||||
def resizeEvent(self, event):
|
||||
super().resizeEvent(event)
|
||||
|
||||
# 获取当前窗口的宽度和高度
|
||||
current_width = self.width()
|
||||
current_height = self.height()
|
||||
|
||||
# 判断当前窗口是否超过了初始大小
|
||||
if current_width > self.initial_width or current_height > self.initial_height:
|
||||
# 允许窗口继续拉伸,不设置最小宽度和最小高度
|
||||
pass
|
||||
else:
|
||||
# 重新设置最小宽度和最小高度为初始大小
|
||||
self.setMinimumWidth(self.initial_width)
|
||||
self.setMinimumHeight(self.initial_height)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
host = "rm-bp1s36ps814qp23b7uo.mysql.rds.aliyuncs.com"
|
||||
user = "zw1847930177"
|
||||
password = "Zuowei1216"
|
||||
database = "program"
|
||||
charset = "utf8"
|
||||
port = 3306
|
||||
db = pymysql.connect(host=host, user=user, password=password, database=database, charset=charset, port=port)
|
||||
cur = db.cursor()
|
||||
user_creat ="""
|
||||
CREATE TABLE IF NOT EXISTS User(
|
||||
`id` INT auto_increment PRIMARY KEY,
|
||||
`username` varchar(255) DEFAULT '',
|
||||
`password` varchar(255) DEFAULT '',
|
||||
`code` varchar(255) DEFAULT ''
|
||||
) ENGINE=innodb DEFAULT CHARSET=utf8;
|
||||
"""
|
||||
cur.execute(user_creat)
|
||||
cur = db.cursor()
|
||||
User = 'User'
|
||||
|
||||
app3 = QApplication(sys.argv)
|
||||
sys.excepthook = exception_hook # 设置全局异常处理
|
||||
|
||||
qdarktheme.setup_theme(
|
||||
custom_colors={
|
||||
"[dark]": {
|
||||
"background": "#4d4d4d",
|
||||
"foreground": "#ffffff",
|
||||
"primary": "#ffffff",
|
||||
"border": "#717070",
|
||||
}
|
||||
}
|
||||
)
|
||||
# login_dialog = LoginDialog()
|
||||
# login_dialog.show()
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
sys.exit(app3.exec_())
|
||||
51
psmark/newMark.spec
Normal file
51
psmark/newMark.spec
Normal file
@@ -0,0 +1,51 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
|
||||
block_cipher = None
|
||||
|
||||
|
||||
a = Analysis(
|
||||
['newMark.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False,
|
||||
)
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name='newMark',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
console=False,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
icon=['newapp.ico'],
|
||||
)
|
||||
coll = COLLECT(
|
||||
exe,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
name='newMark',
|
||||
)
|
||||
BIN
psmark/newapp.ico
Normal file
BIN
psmark/newapp.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.1 KiB |
142
psmark/newmarkLogin.py
Normal file
142
psmark/newmarkLogin.py
Normal file
@@ -0,0 +1,142 @@
|
||||
import sys
|
||||
import subprocess
|
||||
import re
|
||||
import hashlib
|
||||
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QPushButton, QGroupBox, \
|
||||
QSpacerItem, QSizePolicy, QMessageBox
|
||||
import pymysql
|
||||
host = "rm-bp1s36ps814qp23b7uo.mysql.rds.aliyuncs.com"
|
||||
user = "zw1847930177"
|
||||
password = "Zuowei1216"
|
||||
database = "program"
|
||||
charset = "utf8"
|
||||
port = 3306
|
||||
db = pymysql.connect(host=host, user=user, password=password, database=database, charset=charset, port=port)
|
||||
cur = db.cursor()
|
||||
user_creat ="""
|
||||
CREATE TABLE IF NOT EXISTS User(
|
||||
`id` INT auto_increment PRIMARY KEY,
|
||||
`username` varchar(255) DEFAULT '',
|
||||
`password` varchar(255) DEFAULT ''
|
||||
) ENGINE=innodb DEFAULT CHARSET=utf8;
|
||||
"""
|
||||
cur.execute(user_creat)
|
||||
cur = db.cursor()
|
||||
User = 'User'
|
||||
|
||||
class LoginDialog(QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle("PSMARK登录界面")
|
||||
self.resize(300, 200)
|
||||
|
||||
主布局 = QVBoxLayout()
|
||||
|
||||
group1 = QGroupBox("登录验证")
|
||||
group1_layout = QVBoxLayout()
|
||||
|
||||
group2 = QHBoxLayout()
|
||||
label1 = QLabel("用户名")
|
||||
self.edit1 = QLineEdit()
|
||||
self.edit1.setFixedWidth(120)
|
||||
spacer1 = QSpacerItem(40, 10, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
group2.addWidget(label1)
|
||||
group2.addItem(spacer1)
|
||||
group2.addWidget(self.edit1)
|
||||
|
||||
group3 = QHBoxLayout()
|
||||
label2 = QLabel("密码")
|
||||
self.edit2 = QLineEdit()
|
||||
self.edit2.setFixedWidth(120)
|
||||
spacer2 = QSpacerItem(40, 10, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
group3.addWidget(label2)
|
||||
group3.addItem(spacer2)
|
||||
group3.addWidget(self.edit2)
|
||||
|
||||
group4 = QHBoxLayout()
|
||||
button1 = QPushButton("登录")
|
||||
button2 = QPushButton("注册")
|
||||
group4.addWidget(button1)
|
||||
group4.addWidget(button2)
|
||||
|
||||
group1_layout.addLayout(group2)
|
||||
group1_layout.addLayout(group3)
|
||||
group1_layout.addLayout(group4)
|
||||
group1.setLayout(group1_layout)
|
||||
|
||||
主布局.addWidget(group1)
|
||||
|
||||
group5 = QHBoxLayout()
|
||||
label3 = QLabel("机器码")
|
||||
edit3 = QLineEdit()
|
||||
edit3.setFixedWidth(200)
|
||||
|
||||
# 获取主板序列号并提取数字部分
|
||||
try:
|
||||
result = subprocess.run(['wmic', 'baseboard', 'get', 'serialnumber'], stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, text=True)
|
||||
motherboard_serial = result.stdout.strip()
|
||||
|
||||
# 使用正则表达式提取数字
|
||||
motherboard_serial = re.sub(r'\D', '', motherboard_serial)
|
||||
|
||||
# 使用SHA-256加密特征码
|
||||
feature_code = hashlib.sha256(motherboard_serial.encode()).hexdigest()
|
||||
|
||||
# 去掉特征码中的英文字符
|
||||
feature_code = re.sub(r'[a-zA-Z]', '', feature_code)
|
||||
except Exception as e:
|
||||
feature_code = "Error: " + str(e)
|
||||
|
||||
edit3.setText(feature_code) # 将加密后的特征码设置为 "特征码" 输入框的文本
|
||||
|
||||
spacer3 = QSpacerItem(10, 10, QSizePolicy.Fixed, QSizePolicy.Minimum)
|
||||
group5.addWidget(label3)
|
||||
group5.addItem(spacer3)
|
||||
group5.addWidget(edit3)
|
||||
|
||||
主布局.addLayout(group5)
|
||||
|
||||
self.setLayout(主布局)
|
||||
|
||||
# 链接登录的点击事件
|
||||
button1.clicked.connect(self.slot_login)
|
||||
# 连接注册按钮的点击事件
|
||||
button2.clicked.connect(self.show_warning_message)
|
||||
|
||||
def slot_login(self):
|
||||
user_name = self.edit1.text()
|
||||
user_password = self.edit2.text()
|
||||
# print(user_name,user_password)
|
||||
# 执行SQL语句,从user数据表中查询code和time字段值
|
||||
cur.execute(f"SELECT username,password FROM {User}")
|
||||
# 将数据库查询的结果保存在result中
|
||||
result = cur.fetchall()
|
||||
name_list = [it[0] for it in result] # 从数据库查询的result中遍历查询元组中第一个元素name
|
||||
# 判断用户名或密码不能为空
|
||||
if not (user_name and user_password):
|
||||
QMessageBox.critical(self, "错误", "用户名或密码不能为空!")
|
||||
# 判断用户名和密码是否匹配
|
||||
elif user_name in name_list:
|
||||
if user_password == result[name_list.index(user_name)][1]:
|
||||
QMessageBox.information(self, "欢迎您", "登录成功!\n在此添加新界面!")
|
||||
else:
|
||||
QMessageBox.critical(self, "错误", "密码输入错误!")
|
||||
# 账号不在数据库中,则弹出是否注册的框
|
||||
else:
|
||||
QMessageBox.critical(self, "错误", "该账号不存在,请注册!")
|
||||
|
||||
def show_warning_message(self):
|
||||
# 弹出警告消息框
|
||||
warning_message = QMessageBox()
|
||||
warning_message.setIcon(QMessageBox.Warning)
|
||||
warning_message.setWindowTitle("警告")
|
||||
warning_message.setText("请联系管理员 17520145271")
|
||||
warning_message.exec_()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
login_dialog = LoginDialog()
|
||||
login_dialog.show()
|
||||
sys.exit(app.exec_())
|
||||
240
psmark/piece_decorative.py
Normal file
240
psmark/piece_decorative.py
Normal file
@@ -0,0 +1,240 @@
|
||||
import configparser
|
||||
from win32com.client import Dispatch
|
||||
from JSX2 import dxf3_jscode
|
||||
from JSX3 import dxf2_jscode
|
||||
from JSX1 import dxf_jscode
|
||||
from JSX4 import dxf4_jscode
|
||||
from JSX5 import dxf5_jscode
|
||||
from JSX6 import dxf6_jscode
|
||||
from JSX7 import dxf7_jscode
|
||||
from JSX8 import dxf8_jscode
|
||||
from JSX9 import dxf9_jscode
|
||||
from JSX10 import dxf10_jscode
|
||||
from JSX11 import dxf11_jscode
|
||||
from JSX12 import dxf12_jscode
|
||||
from JSX13 import dxf13_jscode
|
||||
from JSX14 import dxf14_jscode
|
||||
from JSX15 import dxf15_jscode
|
||||
from JSX16 import dxf16_jscode
|
||||
from JSX17 import dxf17_jscode
|
||||
from JSX18 import dxf18_jscode
|
||||
from JSX19 import dxf19_jscode
|
||||
from JSX20 import dxf20_jscode
|
||||
from JSX21 import dxf21_jscode
|
||||
psapp = None
|
||||
aiapp = None
|
||||
config = configparser.ConfigParser()
|
||||
config.read('程序配置.ini', encoding='utf-8')
|
||||
PS应用名 = config.get('程序配置', 'PS应用名')
|
||||
|
||||
# from datetime import datetime # 引入datetime,获取当前日期
|
||||
# import sys # 引用退出程序方法
|
||||
#
|
||||
# ## 逻辑实现
|
||||
# d1 = datetime.now().date()
|
||||
# d2 = pd.to_datetime('2023-9-15').date()
|
||||
#
|
||||
# print("当前日期:", d1)
|
||||
# print("限制日期:", d2)
|
||||
#
|
||||
# if d1 > d2:
|
||||
# print('软件已过期,请联系作者!')
|
||||
# sys.exit()
|
||||
def PS_DXF_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
|
||||
def PS_DXF2_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf2_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
def PS_DXF3_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf3_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
def PS_DXF4_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf4_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
def PS_DXF5_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf5_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
def PS_DXF6_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf6_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
def PS_DXF7_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf7_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
def PS_DXF8_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf8_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
def PS_DXF9_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf9_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def PS_DXF10_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf10_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
def PS_DXF11_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf11_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
def PS_DXF12_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf12_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
def PS_DXF13_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf13_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
def PS_DXF14_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf14_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def PS_DXF15_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf15_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
def PS_DXF16_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf16_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
def PS_DXF17_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf17_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def PS_DXF18_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf18_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
def PS_DXF19_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf19_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
def PS_DXF20_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf20_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def PS_DXF21_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf21_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
|
||||
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
107
psmark/piece_decorativeV2.py
Normal file
107
psmark/piece_decorativeV2.py
Normal file
@@ -0,0 +1,107 @@
|
||||
import configparser
|
||||
from win32com.client import Dispatch
|
||||
from JSX2 import dxf3_jscode
|
||||
from JSX3 import dxf2_jscode
|
||||
from JSX1 import dxf_jscode
|
||||
from JSX4 import dxf4_jscode
|
||||
from JSX5 import dxf5_jscode
|
||||
from JSX6 import dxf6_jscode
|
||||
from JSX7 import dxf7_jscode
|
||||
from JSX8 import dxf8_jscode
|
||||
psapp = None
|
||||
aiapp = None
|
||||
#config = configparser.ConfigParser()
|
||||
#config.read('程序配置.ini', encoding='utf-8')
|
||||
#PS应用名 = config.get('程序配置', 'PS应用名')
|
||||
|
||||
# from datetime import datetime # 引入datetime,获取当前日期
|
||||
# import sys # 引用退出程序方法
|
||||
#
|
||||
# ## 逻辑实现
|
||||
# d1 = datetime.now().date()
|
||||
# d2 = pd.to_datetime('2023-9-15').date()
|
||||
#
|
||||
# print("当前日期:", d1)
|
||||
# print("限制日期:", d2)
|
||||
#
|
||||
# if d1 > d2:
|
||||
# print('软件已过期,请联系作者!')
|
||||
# sys.exit()
|
||||
def 运行PS_DXF_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
|
||||
def 运行PS_DXF2_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf2_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
def 运行PS_DXF3_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf3_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
def 运行PS_DXF4_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf4_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
def 运行PS_DXF5_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf5_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
def 运行PS_DXF6_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf6_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
def 运行PS_DXF7_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf7_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
def 运行PS_DXF8_jscode_fun(funcode):
|
||||
print(funcode)
|
||||
global psapp
|
||||
if psapp is None:
|
||||
psapp = Dispatch(PS应用名)
|
||||
res = psapp.DoJavaScript(dxf8_jscode + '\n' + funcode)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
55
psmark/test.py
Normal file
55
psmark/test.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout
|
||||
import piece_decorative
|
||||
class SimpleApp(QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# 初始化界面
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
# 创建一个按钮
|
||||
btn = QPushButton('接口测试', self)
|
||||
|
||||
# 连接按钮的点击事件到槽函数
|
||||
btn.clicked.connect(self.button_click)
|
||||
|
||||
# 创建一个垂直布局
|
||||
layout = QVBoxLayout()
|
||||
|
||||
# 在布局中添加按钮
|
||||
layout.addWidget(btn)
|
||||
|
||||
# 设置主窗口的布局
|
||||
self.setLayout(layout)
|
||||
|
||||
# 设置主窗口的标题和大小
|
||||
self.setWindowTitle('测试')
|
||||
self.setGeometry(300, 300, 300, 200)
|
||||
|
||||
# 显示界面
|
||||
self.show()
|
||||
|
||||
def button_click(self):
|
||||
# 按钮点击时调用的槽函数
|
||||
|
||||
# piece_decorative.PS_DXF2_jscode_fun('设置花样组删除图层设置名称();')
|
||||
# piece_decorative.PS_DXF12_jscode_fun('批量套数写入();')
|
||||
piece_decorative.PS_DXF2_jscode_fun('设置花样组2();')
|
||||
piece_decorative.PS_DXF19_jscode_fun('裁片抓取新的();')
|
||||
piece_decorative.PS_DXF2_jscode_fun('设置花样组顺序居中();')
|
||||
piece_decorative.PS_DXF_jscode_fun('信息写入();')
|
||||
piece_decorative.PS_DXF3_jscode_fun('裁片视图检查2();')
|
||||
print('按钮被点击了!')
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 创建应用程序对象
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
# 创建主窗口
|
||||
window = SimpleApp()
|
||||
|
||||
# 运行应用程序的主循环
|
||||
sys.exit(app.exec_())
|
||||
|
||||
324
psmark/test2.py
Normal file
324
psmark/test2.py
Normal file
@@ -0,0 +1,324 @@
|
||||
import myskin_styles, myskin_windows
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtGui import *
|
||||
import sys, os
|
||||
import piece_decorative
|
||||
import ezdxf
|
||||
import ezdxf.tools
|
||||
import ezdxf.bbox
|
||||
import ezdxf.units
|
||||
import ezdxf.math
|
||||
import qdarktheme
|
||||
|
||||
import re
|
||||
def extract_number_from_block_name(block_name):
|
||||
# 使用正则表达式提取块名称中的数字部分
|
||||
match = re.search(r'P(\d+)', block_name)
|
||||
if match:
|
||||
return int(match.group(1))
|
||||
return 0 # 如果没有找到数字,默认返回0
|
||||
|
||||
|
||||
|
||||
|
||||
def 获取dxf中心坐标和角度列表(doc):
|
||||
msp = doc.modelspace()
|
||||
mspBox = ezdxf.bbox.extents(msp)
|
||||
result = []
|
||||
for entity in msp.query():
|
||||
if entity.dxftype() == "INSERT":
|
||||
result.append({"块名称": entity.dxf.name, "center": None, "rotation": None})
|
||||
|
||||
temp = []
|
||||
rotation = None
|
||||
block = doc.blocks[entity.dxf.name]
|
||||
for e in block:
|
||||
if e.dxftype() != "TEXT":
|
||||
temp.append(e)
|
||||
else:
|
||||
rotation = e.dxf.all_existing_dxf_attribs()["rotation"]
|
||||
# 只有 0 90 -90 -180 出现其他的就以近似值代替
|
||||
if rotation < 0:
|
||||
rotation += 360
|
||||
if rotation < 45 or rotation > 315:
|
||||
rotation = 0
|
||||
elif rotation < 135:
|
||||
rotation = 90
|
||||
elif rotation < 225:
|
||||
rotation = -180
|
||||
else:
|
||||
rotation = -90
|
||||
|
||||
result[-1]["rotation"] = rotation
|
||||
|
||||
center = ezdxf.bbox.extents(temp).center
|
||||
# center y 改成从上往下计算
|
||||
center = (center.x, mspBox.size[1] + mspBox.extmin[1] - center.y)
|
||||
# 旋转
|
||||
center = (mspBox.size[1] - center[1], center[0])
|
||||
|
||||
result[-1]["center"] = center
|
||||
|
||||
# 打印处理前的数据
|
||||
print("处理前的数据:", result)
|
||||
|
||||
# 按块名称进行排序
|
||||
result.sort(key=lambda x: extract_number_from_block_name(x["块名称"]))
|
||||
|
||||
# 打印处理后的数据
|
||||
print("处理后的数据:", result)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
||||
class DXFWinUi(object):
|
||||
|
||||
def setupUi(self, MainWindow):
|
||||
# MainWindow.resize(800, 600)
|
||||
|
||||
self.centralwidget = QWidget(MainWindow)
|
||||
|
||||
mainLayout = QHBoxLayout(self.centralwidget)
|
||||
|
||||
groupBox = QGroupBox('多码混排')
|
||||
|
||||
leftLayout = QVBoxLayout(groupBox)
|
||||
|
||||
label1 = QLabel('大货裁片路径')
|
||||
# self.label2 = QLabel('暂未选择文件夹。')
|
||||
self.pushButton1 = QPushButton("选择文件夹")
|
||||
self.pushButton1.setFixedSize(100,30)
|
||||
leftLayout.addWidget(label1)
|
||||
# leftLayout.addWidget(self.label2)
|
||||
leftLayout.addWidget(self.pushButton1)
|
||||
leftLayout.addStretch()
|
||||
|
||||
label6 = QLabel('DXF文件路径')
|
||||
# self.label7 = QLabel('暂未选择文件。')
|
||||
self.pushButton2 = QPushButton("选择文件")
|
||||
self.pushButton2.setFixedSize(100, 30)
|
||||
leftLayout.addWidget(label6)
|
||||
# leftLayout.addWidget(self.label7)
|
||||
leftLayout.addWidget(self.pushButton2)
|
||||
leftLayout.addStretch()
|
||||
|
||||
|
||||
label3 = QLabel('分辨率大小')
|
||||
self.lineEdit1 = QLineEdit()
|
||||
self.lineEdit1.setValidator(QIntValidator())
|
||||
self.lineEdit1.setFixedSize(150,30)
|
||||
leftLayout.addWidget(label3)
|
||||
leftLayout.addWidget(self.lineEdit1)
|
||||
leftLayout.addStretch()
|
||||
|
||||
label4 = QLabel('文档名称')
|
||||
self.lineEdit2 = QLineEdit()
|
||||
self.lineEdit2.setFixedSize(150,30)
|
||||
leftLayout.addWidget(label4)
|
||||
leftLayout.addWidget(self.lineEdit2)
|
||||
leftLayout.addStretch()
|
||||
|
||||
label5 = QLabel('单码片数')
|
||||
self.lineEdit3 = QLineEdit()
|
||||
self.lineEdit3.setFixedSize(150,30)
|
||||
self.lineEdit3.setValidator(QIntValidator())
|
||||
leftLayout.addWidget(label5)
|
||||
leftLayout.addWidget(self.lineEdit3)
|
||||
leftLayout.addStretch()
|
||||
|
||||
|
||||
|
||||
# 滚动区域
|
||||
scrollArea = QScrollArea()
|
||||
scrollArea.setFixedSize(200,210)
|
||||
scrollWidget = QWidget(scrollArea)
|
||||
self.scrollWidgetLayout = QVBoxLayout(scrollWidget)
|
||||
self.scrollWidgetLayout.setContentsMargins(5,5,5,5)
|
||||
self.scrollWidgetLayout.setSpacing(5)
|
||||
scrollArea.setWidget(scrollWidget)
|
||||
scrollArea.setWidgetResizable(True)
|
||||
leftLayout.addWidget(scrollArea)
|
||||
leftLayout.addStretch()
|
||||
|
||||
rightWidget = QWidget()
|
||||
|
||||
# rightLayout = QVBoxLayout(rightWidget)
|
||||
# self.okPushButton = QPushButton("OK")
|
||||
# self.cancelPushButton = QPushButton("Cancel")
|
||||
# rightLayout.addWidget(self.okPushButton)
|
||||
# rightLayout.addWidget(self.cancelPushButton)
|
||||
# rightLayout.addStretch()
|
||||
|
||||
# rightWidget.setLayout(rightLayout)
|
||||
self.runButton = QPushButton("运行")
|
||||
leftLayout.addWidget(self.runButton)
|
||||
|
||||
rightWidget = QWidget()
|
||||
|
||||
mainLayout.addWidget(groupBox, 1)
|
||||
# mainLayout.addWidget(rightWidget, 1)
|
||||
|
||||
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
|
||||
|
||||
class DXFWin(QMainWindow, DXFWinUi):
|
||||
|
||||
def __init__(self):
|
||||
QMainWindow.__init__(self)
|
||||
self.ui = DXFWinUi()
|
||||
self.ui.setupUi(self)
|
||||
self.setWindowTitle("水平布局管理例子")
|
||||
|
||||
desktop = QApplication.desktop()
|
||||
self.move((desktop.width() - self.width()) / 2, (desktop.height() - self.height()) /2)
|
||||
|
||||
self.ui.pushButton1.clicked.connect(self.chooseDir)
|
||||
# self.ui.cancelPushButton.clicked.connect(self.close)
|
||||
self.ui.pushButton2.clicked.connect(self.chooseDxf)
|
||||
# self.ui.okPushButton.clicked.connect(self.ok)
|
||||
self.ui.runButton.clicked.connect(self.run)
|
||||
|
||||
self.dir = None
|
||||
self.dxfPath = None
|
||||
self.dxfLineEdits = {}
|
||||
|
||||
def run(self):
|
||||
print("按钮被点击")
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def chooseDir(self):
|
||||
rst = QFileDialog.getExistingDirectory()
|
||||
|
||||
if rst != '':
|
||||
self.ui.label2.setText(rst)
|
||||
self.dir = rst
|
||||
|
||||
def chooseDxf(self):
|
||||
rst = QFileDialog.getOpenFileName(filter='dxf file(*.dxf)')
|
||||
rst = rst[0]
|
||||
|
||||
if rst == '':
|
||||
return
|
||||
|
||||
|
||||
|
||||
# 解析文件路径
|
||||
# self.ui.label7.setText(rst)
|
||||
self.dxfPath = rst
|
||||
|
||||
sizes = []
|
||||
temp = ''
|
||||
for c in os.path.basename(rst).split('.')[0]:
|
||||
import string
|
||||
if c in string.punctuation:
|
||||
if temp != '':
|
||||
sizes.append(temp)
|
||||
temp = ''
|
||||
continue
|
||||
temp += c
|
||||
if temp != '':
|
||||
sizes.append(temp)
|
||||
|
||||
#清空self.ui.scrollWidgetLayout
|
||||
for i in range(self.ui.scrollWidgetLayout.count()):
|
||||
item = self.ui.scrollWidgetLayout.itemAt(0)
|
||||
self.ui.scrollWidgetLayout.removeItem(item)
|
||||
if item.widget():
|
||||
item.widget().deleteLater()
|
||||
self.dxfLineEdits = {}
|
||||
|
||||
# 添加label和button
|
||||
for size in sizes:
|
||||
layout = QHBoxLayout()
|
||||
layout.addWidget(QLabel(size))
|
||||
layout.setContentsMargins(0,0,00,0)
|
||||
lineEdit = QLineEdit()
|
||||
lineEdit.setValidator(QIntValidator())
|
||||
lineEdit.setFixedSize(100, 30)
|
||||
self.dxfLineEdits[size] = lineEdit
|
||||
layout.addWidget(lineEdit)
|
||||
self.ui.scrollWidgetLayout.addLayout(layout)
|
||||
|
||||
def ok(self):
|
||||
# 检查参数
|
||||
if self.dxfPath == None:
|
||||
QMessageBox.critical(self, "错误", "未选择dxf文件!")
|
||||
return
|
||||
if self.dir == None:
|
||||
QMessageBox.critical(self, "错误", "未选择大货裁片文件夹!")
|
||||
return
|
||||
|
||||
# 禁用窗口
|
||||
self.setDisabled(True)
|
||||
|
||||
# 解析dxf数据
|
||||
doc = ezdxf.readfile(self.dxfPath)
|
||||
msp = doc.modelspace()
|
||||
mspBox = ezdxf.bbox.extents(msp)
|
||||
|
||||
画布高 = mspBox.size[0]
|
||||
画布宽 = mspBox.size[1]
|
||||
|
||||
分辨率 = self.ui.lineEdit1.text()
|
||||
文档名称 = self.ui.lineEdit2.text()
|
||||
|
||||
piece_decorative.PS_DXF21_jscode_fun(f'创建裁片排版文档({画布宽},{画布高},{分辨率},"{文档名称}");')
|
||||
单码片数 = int(self.ui.lineEdit3.text())
|
||||
DXFnames = []
|
||||
for size, lineEdit in self.dxfLineEdits.items():
|
||||
for i in range(单码片数):
|
||||
for j in range(int(lineEdit.text())):
|
||||
DXFname = f"P{i + 1}-{size}"
|
||||
DXFnames.append(DXFname)
|
||||
print(DXFnames)
|
||||
|
||||
中心坐标和角度列表 = 获取dxf中心坐标和角度列表(doc)
|
||||
|
||||
|
||||
|
||||
# 保存新的文件
|
||||
# doc.saveas(self.dxfPath + ".out.dxf")
|
||||
|
||||
for i in range(len(DXFnames)):
|
||||
DXFname = DXFnames[i]
|
||||
中心x_mm = 中心坐标和角度列表[i]["center"][0]
|
||||
中心y_mm = 中心坐标和角度列表[i]["center"][1]
|
||||
角度 = 中心坐标和角度列表[i]["rotation"]
|
||||
|
||||
piece_decorative.PS_DXF21_jscode_fun(f'置入链接的智能对象("{self.dir}","{DXFname}");')
|
||||
piece_decorative.PS_DXF21_jscode_fun(f'裁片排版_lay({中心x_mm},{中心y_mm});')
|
||||
piece_decorative.PS_DXF21_jscode_fun(f'裁片角度({角度});')
|
||||
|
||||
|
||||
self.setDisabled(False)
|
||||
|
||||
def main():
|
||||
try:
|
||||
app = QApplication(sys.argv)
|
||||
# myskin_styles.dark(app)
|
||||
win = DXFWin()
|
||||
qdarktheme.setup_theme(
|
||||
custom_colors={
|
||||
"[dark]": {
|
||||
"background": "#4d4d4d",
|
||||
"foreground": "#ffffff",
|
||||
"primary": "#ffffff",
|
||||
"border": "#717070",
|
||||
}
|
||||
}
|
||||
)
|
||||
# mw = myskin_windows.ModernWindow(win)
|
||||
# win.setWindowIcon(QIcon('./ui/app.ico'))
|
||||
win.show()
|
||||
# win.show()
|
||||
sys.exit(app.exec_())
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
11
psmark/test3.py
Normal file
11
psmark/test3.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import json
|
||||
|
||||
# 读取 JSON 文件
|
||||
file_path = 'C:\\Users\\Administrator\\Desktop\\example.json'
|
||||
with open(file_path, 'r') as file:
|
||||
data = json.load(file)
|
||||
|
||||
# 处理数据
|
||||
print("name:", data["name"])
|
||||
print("resolution:", data["resolution"])
|
||||
print("matchCount:", data["matchCount"])
|
||||
264
psmark/test5.py
Normal file
264
psmark/test5.py
Normal file
@@ -0,0 +1,264 @@
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QLabel, QPushButton, QFileDialog, \
|
||||
QLineEdit, QScrollArea, QGroupBox, QHBoxLayout, QMessageBox, QProgressDialog
|
||||
from PyQt5.QtGui import QIntValidator
|
||||
from PyQt5.QtCore import QTimer
|
||||
import re
|
||||
import os
|
||||
import ezdxf
|
||||
import ezdxf.tools
|
||||
import ezdxf.bbox
|
||||
import ezdxf.units
|
||||
import ezdxf.math
|
||||
from coreldraw_checker import is_coreldraw_running
|
||||
from functools import partial
|
||||
import win32com.client
|
||||
import os
|
||||
import shutil
|
||||
import threading
|
||||
from clear_folder import another_function
|
||||
|
||||
|
||||
class YourMainWindow9(QMainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.setWindowTitle("RUNDXF")
|
||||
|
||||
layout = QVBoxLayout()
|
||||
|
||||
self.button2 = QPushButton("裁片文件路径")
|
||||
self.button2.setFixedWidth(200)
|
||||
self.button2.clicked.connect(self.showPltFileDialog)
|
||||
|
||||
self.button1 = QPushButton("DXF文件路径")
|
||||
self.button1.setFixedWidth(200)
|
||||
self.button1.clicked.connect(self.showDxfFileDialog)
|
||||
|
||||
self.initial_button2_text = self.button2.text()
|
||||
|
||||
self.initial_button1_text = self.button1.text()
|
||||
|
||||
panel1 = QGroupBox("文件路径")
|
||||
panel1_layout = QVBoxLayout(panel1)
|
||||
panel1_layout.setSpacing(10)
|
||||
panel1_layout.setContentsMargins(10, 10, 10, 10)
|
||||
panel1_layout.addWidget(self.button2)
|
||||
panel1_layout.addWidget(self.button1)
|
||||
|
||||
layout.addWidget(panel1)
|
||||
|
||||
self.label7 = QLabel('文档名称')
|
||||
self.lineEdit7 = QLineEdit()
|
||||
self.lineEdit7.setValidator(QIntValidator())
|
||||
self.lineEdit7.setFixedSize(120, 30)
|
||||
layout.addWidget(self.label7)
|
||||
layout.addWidget(self.lineEdit7)
|
||||
|
||||
self.label6 = QLabel('分辨率大小')
|
||||
self.lineEdit6 = QLineEdit()
|
||||
self.lineEdit6.setValidator(QIntValidator())
|
||||
self.lineEdit6.setFixedSize(120, 30)
|
||||
layout.addWidget(self.label6)
|
||||
layout.addWidget(self.lineEdit6)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
self.label5 = QLabel('单码片数')
|
||||
self.lineEdit3 = QLineEdit()
|
||||
self.lineEdit3.setValidator(QIntValidator())
|
||||
self.lineEdit3.setFixedSize(120, 30)
|
||||
layout.addWidget(self.label5)
|
||||
layout.addWidget(self.lineEdit3)
|
||||
|
||||
|
||||
self.scrollWidget = QWidget()
|
||||
self.scrollWidgetLayout = QVBoxLayout(self.scrollWidget)
|
||||
self.scrollArea = QScrollArea()
|
||||
self.scrollArea.setWidget(self.scrollWidget)
|
||||
self.scrollArea.setWidgetResizable(True)
|
||||
layout.addWidget(self.scrollArea)
|
||||
#
|
||||
# self.clearButton = QPushButton("清空信息")
|
||||
# self.clearButton.clicked.connect(self.clearScrollArea)
|
||||
# layout.addWidget(self.clearButton)
|
||||
|
||||
# self.bigconfirm_button = QPushButton("混码分割")
|
||||
# self.bigconfirm_button.clicked.connect(self.bigupdateScrollArea)
|
||||
# layout.addWidget(self.bigconfirm_button)
|
||||
|
||||
confirm_button = QPushButton("运行")
|
||||
confirm_button.clicked.connect(self.updateScrollArea)
|
||||
layout.addWidget(confirm_button)
|
||||
|
||||
|
||||
central_widget = QWidget()
|
||||
central_widget.setLayout(layout)
|
||||
self.setCentralWidget(central_widget)
|
||||
|
||||
self.dxfLineEdits = {}
|
||||
|
||||
self.allowButtonActions = True # 标志变量,控制是否允许按钮行为
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def showPltFileDialog(self):
|
||||
# options = QFileDialog.Options()
|
||||
# file_path, _ = QFileDialog.getOpenFileName(self, "选择PLT文件", "", "PLT Files (*.plt);;All Files (*)",
|
||||
# options=options)
|
||||
# if file_path:
|
||||
# print("Selected PLT file:", file_path)
|
||||
# extracted_content = self.extract_content_from_plt_path(file_path)
|
||||
# print(extracted_content)
|
||||
# self.sizes = self.fill_sizes_from_extracted_content(extracted_content)
|
||||
#
|
||||
# # 更新尺寸字典后,清空并填充滚动区域
|
||||
# self.clearScrollArea()
|
||||
# self.populateScrollArea()
|
||||
#
|
||||
# self.initial_plt_path = file_path # 更新初始路径而不更新按钮文本
|
||||
#
|
||||
# else:
|
||||
# print("No PLT file selected")
|
||||
# QMessageBox.warning(self, "警告", "没有选择文件夹。请重新选择文件夹。", QMessageBox.Ok)
|
||||
|
||||
pass
|
||||
|
||||
def showDxfFileDialog(self):
|
||||
options = QFileDialog.Options()
|
||||
file_path, _ = QFileDialog.getOpenFileName(self, "选择DXF文件", "", "DXF Files (*.dxf);;All Files (*)",
|
||||
options=options)
|
||||
if file_path:
|
||||
print("Selected DXF file:", file_path)
|
||||
extracted_content = self.extract_content_from_plt_path(file_path) # 更新初始路径而不更新按钮文本
|
||||
print(extracted_content)
|
||||
self.sizes = self.fill_sizes_from_extracted_content(extracted_content)
|
||||
|
||||
# 更新尺寸字典后,清空并填充滚动区域
|
||||
self.clearScrollArea()
|
||||
self.populateScrollArea()
|
||||
|
||||
self.initial_plt_path = file_path # 更新初始路径而不更新按钮文本
|
||||
else:
|
||||
print("No DXF file selected")
|
||||
QMessageBox.warning(self, "警告", "没有选择文件夹。请重新选择文件夹。", QMessageBox.Ok)
|
||||
# 在此处添加提醒逻辑,例如使用 QMessageBox 提示用户没有选择文件
|
||||
|
||||
def extract_content_from_plt_path(self, plt_path):
|
||||
match = re.search(r'\((.*?)\)', plt_path)
|
||||
if match:
|
||||
extracted_content = match.group(1)
|
||||
return extracted_content
|
||||
else:
|
||||
return "No content in parentheses found"
|
||||
|
||||
def fill_sizes_from_extracted_content(self, extracted_content):
|
||||
sizes = extracted_content.split("+")
|
||||
size_dict = {}
|
||||
for size in sizes:
|
||||
size_dict[size] = ""
|
||||
return size_dict
|
||||
|
||||
|
||||
|
||||
|
||||
def updateScrollArea(self):
|
||||
|
||||
another_function()
|
||||
|
||||
if not is_coreldraw_running():
|
||||
QMessageBox.warning(self, "警告", "CorelDRAW未运行,无法执行操作。")
|
||||
return
|
||||
|
||||
plt_file_path = self.initial_plt_path
|
||||
|
||||
# 获取DXF文件路径
|
||||
dxf_file_path = self.initial_dxf_path
|
||||
extracted_content = self.extract_content_from_plt_path(plt_file_path)
|
||||
|
||||
if dxf_file_path:
|
||||
# 去掉括号内内容后的PLT文件名作为DXF文件名
|
||||
plt_filename = os.path.basename(plt_file_path)
|
||||
# dxf_filename = re.sub(r'\(.*?\)', '', plt_filename)
|
||||
self.process_dxf_file(dxf_file_path, extracted_content) # 调用解析函数并传入单码片数和新的DXF文件名
|
||||
print("DXF文件解析完成!")
|
||||
else:
|
||||
QMessageBox.warning(self, "警告", "没有选择DXF文件。请先选择一个DXF文件。", QMessageBox.Ok)
|
||||
print()
|
||||
|
||||
|
||||
|
||||
self.run_coreldraw_macros()
|
||||
single_code_pieces = int(self.getSinglePieceCount()) # 获取单码片数
|
||||
print(single_code_pieces)
|
||||
# 打印滚动区域中的输入框内容
|
||||
code_quantities = {} # 创建一个新的字典用于存储数据
|
||||
|
||||
for label, line_edit in self.dxfLineEdits.items():
|
||||
text = line_edit.text()
|
||||
if text.isdigit():
|
||||
value = int(text) # 尝试将文本转换为整数
|
||||
else:
|
||||
try:
|
||||
value = float(text) # 尝试将文本转换为浮点数
|
||||
except ValueError:
|
||||
print(f"Invalid value for {label}: {text}")
|
||||
continue # 转换失败,跳过当前循环迭代
|
||||
|
||||
code_quantities[label] = value # 存储转换后的数字到字典
|
||||
|
||||
print(code_quantities)
|
||||
length = len(code_quantities)
|
||||
print(length) # 输出 3,因为字典中有三对键值对
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def updateLineEditsFromSizes(self):
|
||||
for size_label, line_edit in self.dxfLineEdits.items():
|
||||
self.sizes[size_label] = line_edit.text()
|
||||
|
||||
def populateScrollArea(self):
|
||||
self.clearScrollArea()
|
||||
for size_label, size_text in self.sizes.items():
|
||||
size_layout = QHBoxLayout()
|
||||
size_layout.addWidget(QLabel(size_label))
|
||||
|
||||
line_edit = QLineEdit()
|
||||
line_edit.setValidator(QIntValidator())
|
||||
line_edit.setFixedSize(100, 30)
|
||||
line_edit.setText(size_text)
|
||||
|
||||
self.dxfLineEdits[size_label] = line_edit
|
||||
size_layout.addWidget(line_edit)
|
||||
|
||||
self.scrollWidgetLayout.addLayout(size_layout)
|
||||
|
||||
def clearScrollArea(self):
|
||||
for i in reversed(range(self.scrollWidgetLayout.count())):
|
||||
item = self.scrollWidgetLayout.itemAt(i)
|
||||
if isinstance(item, QHBoxLayout) or isinstance(item, QVBoxLayout):
|
||||
while item.count():
|
||||
widget = item.takeAt(0).widget()
|
||||
if widget:
|
||||
widget.deleteLater()
|
||||
self.dxfLineEdits.clear() # 清空部件引用
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
mainWindow = YourMainWindow9()
|
||||
mainWindow.show()
|
||||
sys.exit(app.exec_())
|
||||
4
psmark/程序配置.ini
Normal file
4
psmark/程序配置.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
[程序配置]
|
||||
psname = Photoshop.Application.130
|
||||
Reference in New Issue
Block a user