{"id":473,"date":"2021-09-18T13:25:00","date_gmt":"2021-09-18T13:25:00","guid":{"rendered":"https:\/\/262235.xyz\/?p=473"},"modified":"2021-09-18T13:25:00","modified_gmt":"2021-09-18T13:25:00","slug":"473","status":"publish","type":"post","link":"https:\/\/lyvba.com\/index.php\/2021\/09\/18\/473\/","title":{"rendered":"Adobe Illustrator \u811a\u672c\u5b66\u4e60: JS\u811a\u672c\u6587\u6863\u4e2d\u63d2\u5165\u65e5\u671f\u548c\u6587\u4ef6\u540d"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/lyvba.com\/wp-content\/uploads\/2021\/09\/372287158.webp\" alt=\"ai.webp\" title=\"ai.webp\"><\/p>\n<ul>\n<li>javascript Date \u7c7b\u7adf\u7136\u6ca1\u6709\u5185\u7f6e\u683c\u5f0f\u5316\u51fd\u6570\uff0c\u67e5\u4e86\u6587\u6863\u627e\u4e0d\u5230\uff0c\u5230\u7f51\u4e0a\u627e\u4e86\u51e0\u4e2a <code>yyyy-MM-DD<\/code> \u683c\u5f0f\u5316\u65e5\u671f\uff0c\u8fd8\u662f\u8fd9\u4e2a\u7b97\u4e0d\u9519\u3002<\/li>\n<li>\n<p>Adobe Illustrator \u811a\u672c\uff0c\u4f7f\u7528 <code>activeDocument.name<\/code> \u5bf9\u8c61\u5c31\u80fd\u83b7\u5f97\u6587\u4ef6\u540d\uff1b <code>activeDocument.fullName.fsName<\/code>\u53ef\u4ee5\u83b7\u5f97\u6587\u4ef6\u7684\u5b8c\u6574\u8def\u5f84\u540d\u79f0\u3002<\/p>\n<pre><code>alert(activeDocument.name);\n\nalert(activeDocument.fullName.fsName);<\/code><\/pre>\n<h2>JS\u683c\u5f0f\u5316\u65f6\u95f4\uff0c\u83b7\u53d6\u6587\u6863\u540d\u79f0;\u5728\u6587\u6863\u4e2d\u5efa\u7acb\u4e00\u4e2a\u65b0\u6587\u672c<\/h2>\n<pre><code>\/\/ \u83b7\u53d6\u5f53\u524d\u65f6\u95f4\nfunction getdate() {\nvar d = new Date(), month = '' + (d.getMonth() + 1),\n  day = '' + d.getDate(), year = d.getFullYear();\nif (month.length &lt; 2) month = '0' + month;\nif (day.length &lt; 2) day = '0' + day;\nreturn [year, month, day].join('-');\n}\n\n\/\/ \u83b7\u53d6 AI\u6587\u6863\u540d\u79f0\nvar doc = activeDocument;\nvar str = doc.name;\nstr = str + \"   \" + getdate();\nalert(\"\u672c\u811a\u672c\u5efa\u7acb\u4e00\u4e2a\u6587\u672c:\n\" + str);\n\n\/\/ \u6587\u6863\u4e2d\u5efa\u7acb\u4e00\u4e2a\u65b0\u6587\u672c\nvar textRef = doc.textFrames.add();\ntextRef.top = 100;\ntextRef.left = 200;\ntextRef.contents = str;<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>\u4f7f\u7528 <code>Adobe ExtendScript Toolkit<\/code>\uff0c\u70b9\u5f00\u6570\u636e\u6d4f\u89c8\u5668\uff0c\u53ef\u4ee5\u65b9\u4fbf\u83b7\u53d6\u7269\u4ef6\u4fe1\u606f\u548c\u5b66\u4e60\u5bf9\u8c61\u5c42\u6b21<\/h3>\n<p><a href=\"https:\/\/lyvba.com\/wp-content\/uploads\/2021\/09\/4069912100.png\"><img decoding=\"async\" src=\"https:\/\/lyvba.com\/wp-content\/uploads\/2021\/09\/4069912100.png\" alt=\"DATA_BROWSER.png\" title=\"DATA_BROWSER.png\"><\/a><\/p>\n<ul>\n<li>\u6267\u884c\u4e0a\u9762\u811a\u672c\u540e\uff0c\u9009\u5230\u8fd9\u4e2a\u6587\u672c\uff0c\u770b\u5230 <code>.selection =[TextFrme]<\/code> \u9009\u62e9\u662f\u4e2a\u6587\u672c\u5bf9\u8c61\uff0c\u70b9\u5f00\u540e\u53ef\u4ee5\u770b\u5230\u8d4b\u503c\u7684\u4e09\u4e2a\u5c5e\u6027\u3002<\/li>\n<\/ul>\n<h3>\u521b\u5efa\u65b0\u7684\u5b57\u7b26\u6837\u5f0f\u5e76\u8bbe\u7f6e\u5b57\u8ddd\u8c03\u6574\u65b9\u6cd5\u548c\u586b\u5145\u989c\u8272<\/h3>\n<pre><code>var charStyle = doc.characterStyles.add(\"MarkText\");\ncharStyle.characterAttributes.kerningMethod = AutoKernType.METRICSROMANONLY;\n\nvar cmykColor = new CMYKColor();\ncmykColor.cyan = 10;\ncmykColor.magenta = 100;\ncmykColor.yellow = 100;\ncmykColor.black = 5;\ncharStyle.characterAttributes.fillColor = cmykColor;\n\ncharStyle.applyTo(text.textRange);<\/code><\/pre>\n<p>\u76f8\u5173\u6587\u7ae0: <a href=\"https:\/\/www.lyvba.com\/index.php\/tag\/Adobe\/\">https:\/\/www.lyvba.com\/index.php\/tag\/Adobe\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>javascript Date \u7c7b\u7adf\u7136\u6ca1\u6709\u5185\u7f6e\u683c\u5f0f\u5316\u51fd\u6570\uff0c\u67e5\u4e86\u6587\u6863\u627e\u4e0d\u5230\uff0c\u5230\u7f51\u4e0a\u627e\u4e86\u51e0\u4e2a yyyy- [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,12],"tags":[51],"class_list":["post-473","post","type-post","status-publish","format-standard","hentry","category-soft","category-learn","tag-adobe"],"_links":{"self":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/comments?post=473"}],"version-history":[{"count":0,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/473\/revisions"}],"wp:attachment":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/media?parent=473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/categories?post=473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/tags?post=473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}