顯示具有 Python 標籤的文章。 顯示所有文章
顯示具有 Python 標籤的文章。 顯示所有文章

2013年11月25日 星期一

[Python] Photoshop 檔案輸出工具 : Export files with each layer set (Python + comtypes + PyQt)

  Photoshop檔案輸出工具試作,以Python 2.7 + comtypes + PyQt 4作成。其中使用comtypes是由於win32com無法處理2維陣列(參考:Python and photoshop- code snippets by Pete Hanshaw)。

  功能是自動的將所有的layers及每個layerSet(group)各別輸出成一個檔案(如下圖),另外還有layerSet的名稱過濾功能以及可自訂的輸出路徑,輸出的檔案名稱依據layerSet的name。


  寫到到目前為止遇到一個奇怪的問題無法解決,就是會無法獲得layerSets的length(app.activeDocument.layerSets.length),會出現NameError: Name length not found的錯誤訊息,另外看到有人使用len(layerSets)獲取length(參考:Photoshop scripting with Python @ Tech Art Tiki),但我用起來一樣會返回錯誤訊息(TypeError: object of type 'Dispatch' has no len()),也許是因為comtypes的關係吧?改天再來繼續完善。

目前完成的code
以下則是最單純的輸出功能的code供參考


參考資料:

2012年5月9日 星期三

Regular Expressions

Regular Expressions 可簡稱 re / regex / regexp
中文則為:正則表示式、正規表示式...
下面的連結對RE有詳細的解說
http://www.regular-expressions.info/reference.html
Regular-Expressions.info
石頭閒語 : RE in JavaScript

RE JavaScript Tester

MAXscript不支援RE(至少Max9是),但是可以藉由dotNet來實行,請見下面連結
For obj in $ do : RE with MAXscript
rx = dotNetClass "System.Text.RegularExpressions.RegEx"
pattern = "^([A-Za-z0-9]+_){2}\d{3}"
s = "robot_leftArm_001"
if (((rx.match s pattern).success) == true) then (print "success") else (print "fail!")

2012年2月3日 星期五

Python 資訊收集

fcamel's blog: 學 Python 的入門書: 常看到有人問這問題,想說來寫篇心得,省得重覆回一樣的問題。 我在學 Python 前已學過別的程式語言,所以想找針對已學過程式的人的書。一開始翻許多人推薦的《Learning Python》,發現它是針對沒學過程式的人,有太多篇幅在介紹基本觀念 (如 if 是什麼 ),翻沒幾...

fcamel's blog: Python 的特別之處 (1): 從新手的眼中來看 Python,比較能看出 Python 和其它語言不同之處。最近有機會幫別人快速上手 Python,就順便整理一下我從中發覺 Python 較為突出的優點。 list、dictionary and string 平時 coding 最常用到的 container...


blur-devBlur Studio API's, Libraries and Tools : Python and 3dsMax

Dive Into PythonPython from novice to pro: Dive Into Python is a free Python book for experienced programmers. It was originally hosted at DiveIntoPython.org, but the author has pulled down all copies. It is being mirrored here. You can read the book online, or download it in a variety of formats. It is also available in multiple languages.