深入了解Python在HDA中的應用
Event Handler
在HDA中,要創(chuàng)建Python腳本,需要先選擇一個事件處理器(EventHandle),他表示你要在什么時候執(zhí)行你現在所創(chuàng)建的腳本命令
On Created (在節(jié)點創(chuàng)建時,執(zhí)行腳本)
如選擇此項編輯Python腳本,Python將會在節(jié)點創(chuàng)建時執(zhí)行Python中的命令
Python Model (Python模式)
這一項會使創(chuàng)建的腳本在使用過程中根據用戶設置執(zhí)行
可以使用這一項給節(jié)點設置參數提示等功能
On Delete(在節(jié)點創(chuàng)建時執(zhí)行腳本)
Python在Houdini節(jié)點上的常用方法
Set Color 設置顏色
node = kwargs['node'] #獲取當前節(jié)點 context = hou.pwd() #當前節(jié)點的父對象 node.setColor(hou.Color((0.584,0.776,1))) #設置當前節(jié)點顏色
Node 創(chuàng)建節(jié)點
try: out = context.createNode('null','OUT_render') #從當前節(jié)點的父對象創(chuàng)建節(jié)點 out.setInput(0,node) #設置out節(jié)點輸入端為當前節(jié)點node out.setColor(hou.Color(0,0,0)) #設置out節(jié)點的顏色 except: pass
Print and Button feedback 打印字符和按鈕反饋
def CacheGeo(): #在OnCreate創(chuàng)建一些自定的方法,然后可以在節(jié)點參數中調用 this = hou.pwd() #獲取當前節(jié)點 print "\nCaching......!" filecache = hou.node(this.path() + '/cache_geo') #獲取設置當前節(jié)點內cache_geo的路徑為filecache filecache.parm('execute').pressButton() #獲取filecache節(jié)點上execute的狀態(tài) this.setColor(hou.Color((0.584,0.776,1))) #設置節(jié)點顏色 def ReloadGeo(): this = hou.pwd() print "\nLoaded successfully" filecache = hou.node(this.path() + '/report_geo') filecache.parm('reload').pressButton() this.setColor(hou.Color((0.475,0.812,0.204))) output = hou.node(this.path() + '/output0') #設置當前節(jié)點內output0節(jié)點的路徑為output geo = output.geometry() #獲取output的geometry并賦予到geo(要求出geometry才可以求這個節(jié)點上的geometry屬性) print len(geo.points()) #打印geo的點數
設置這兩個按鈕(cache_geo、report_geo)執(zhí)行時調用不同的方法,執(zhí)行不同的操作
參數調用PythonScripts
hou.pwd().hdaModule().CacheGeo()
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
詳解pyppeteer(python版puppeteer)基本使用
這篇文章主要介紹了詳解pyppeteer(python版puppeteer)基本使用 ,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-06-06Python面試之os.system()和os.popen()的區(qū)別詳析
Python調用Shell,有兩種方法:os.system(cmd)或os.popen(cmd)腳本執(zhí)行過程中的輸出內容,下面這篇文章主要給大家介紹了關于Python面試之os.system()和os.popen()區(qū)別的相關資料,需要的朋友可以參考下2022-06-06Python常用模塊之threading和Thread模塊及線程通信
這篇文章主要介紹了Python常用模塊之threading和Thread模塊及線程通信,文章為圍繞主題的相關內容展開詳細的內容介紹,具有一定的參考價值,需要的朋友看可以參考一下方法2022-06-06