论坛帮助 |
社区圈子 |
日历事件 |
2020-01-28, 21:03 | #1 | ||
|
|||
正式会员
等级: 四袋长老
|
doc = app.activeDocument; theSelect = doc.selection; sizelayer=doc.layers.add(); sizelayer.name = 'Rulerlayer'; for (i=0;i<theSelect.length;i++){ x=theSelect[i].left; y=theSelect[i].top; w=theSelect[i].width; h=theSelect[i].height; s=8; asize=10; tsize=30; /*if(h>100){ s=8; asize=10; tsize=30; } */ redColor = new CMYKColor(); redColor.black = 00; redColor.cyan = 100; redColor.magenta = 00; redColor.yellow = 00; greenColor = new CMYKColor(); greenColor.black = 00; greenColor.cyan = 00; greenColor.magenta = 100; greenColor.yellow = 100; var g1 = doc.groupItems.add(); var line1=g1.pathItems.add(); line1.setEntirePath( new Array( new Array(x-s, y), new Array(x-s, y-h), ) ) ; line1.strokeColor= redColor; var line1=g1.pathItems.add(); line1.setEntirePath( new Array( new Array(x-s-s/2, y), new Array(x-s/2, y), ) ) ; line1.strokeColor= redColor; var line1=g1.pathItems.add(); line1.setEntirePath( new Array( new Array(x-s-s/2, y-h), new Array(x-s/2, y-h), ) ) ; line1.strokeColor= redColor; var ar1=g1.pathItems.add(); ar1.setEntirePath( new Array( new Array(x-s, y), new Array(x-s-asize/2,y-asize), new Array(x-s+asize/2,y-asize), ) ) ; ar1.strokeColor= NoColor; ar1.fillColor= redColor; ar1.closed=true; var ar1=g1.pathItems.add(); ar1.setEntirePath( new Array( new Array(x-s, y-h), new Array(x-s-asize/2,y-h+asize), new Array(x-s+asize/2,y-h+asize), ) ) ; ar1.strokeColor= NoColor; ar1.fillColor= redColor; ar1.closed=true; var t1 = g1.textFrames.add(); t1.contents = (h/2.834645).toFixed(2)+" mm"; t1.textRange.characterAttributes.size=tsize; t1.textRange.characterAttributes.fillColor= greenColor; t1.textRange.textFont=app.textFonts[textFonts.name="MicrosoftYaHei"]; t1.rotate(90); t1.left = (x-s-s-t1.width)+5; t1.top = y-h/2+t1.height/2; } |
||
2020-01-30, 09:04 | 只看该作者 #2 | |||
|
||||
VIP会员
等级: 七袋长老
|
引用:
doc = app.activeDocument; theSelect = doc.selection; sizelayer=doc.layers.add(); sizelayer.name = 'Rulerlayer'; for (i=0;i<theSelect.length;i++){ selInfo=theSelect[i].geometricBounds; selL=selInfo[0]; selT=selInfo[1] selW=Math.abs(selInfo[2]-selInfo[0]) selH=Math.abs(selInfo[3]-selInfo[1]) lineL=8; asize=10; var u=2.834645 var spa=5*u //这里数字可修改距离 tsize=30; redColor = new CMYKColor(); redColor.black = 00; redColor.cyan = 100; redColor.magenta = 00; redColor.yellow = 00; greenColor = new CMYKColor(); greenColor.black = 00; greenColor.cyan = 00; greenColor.magenta = 100; greenColor.yellow = 100; var g1 = doc.groupItems.add(); var line1=g1.pathItems.add(); line1.setEntirePath( new Array( new Array(selL-(lineL/2)-spa, selT), new Array(selL-(lineL/2)-spa, selT-selH), ) ) ; line1.strokeColor= redColor; var line1=g1.pathItems.add(); line1.setEntirePath( new Array( new Array(selL-lineL-spa, selT), new Array(selL-spa, selT), ) ) ; line1.strokeColor= redColor; var line1=g1.pathItems.add(); line1.setEntirePath( new Array( new Array(selL-lineL-spa, selT-selH), new Array(selL-spa, selT-selH), ) ) ; line1.strokeColor= redColor; var ar1=g1.pathItems.add(); ar1.setEntirePath( new Array( new Array(selL-spa-(lineL/2), selT), new Array(selL-spa-(lineL/2)-asize/2, selT-asize), new Array(selL-spa-(lineL/2)+asize/2, selT-asize), ) ) ; ar1.strokeColor= NoColor; ar1.fillColor= redColor; ar1.closed=true; var ar1=g1.pathItems.add(); ar1.setEntirePath( new Array( new Array(selL-spa-(lineL/2), selT-selH), new Array(selL-spa-(lineL/2)-asize/2, selT-selH+asize), new Array(selL-spa-(lineL/2)+asize/2, selT-selH+asize), ) ) ; ar1.strokeColor= NoColor; ar1.fillColor= redColor; ar1.closed=true; var t1 = g1.textFrames.add(); t1.contents = (selH/u).toFixed(2)+" mm"; t1.textRange.characterAttributes.size=tsize; t1.textRange.characterAttributes.fillColor= greenColor; t1.textRange.textFont=app.textFonts[textFonts.name="MicrosoftYaHei"]; t1.rotate(90); t1.left = (selL-lineL-spa-t1.width)+5; t1.top = selT-selH/2+t1.height/2; } doc.selection=null; //////////////////////////////////////////////////////////////////////////////////////////////// |
|||
右列会员因为此帖价值甚高向 calvin530126 表示感谢: |
yzx0120 (2020-01-30)
|