Interface: LayerManager
.count
Get the number of layers in the scene
.current
Returns a LayerProperties MixinInterface to the current layer.
getLayerFromName #name
Returns a LayerProperties MixinInterface to the layer with the given name.
選取Layer中的物件
layer = layerManager.getLayerFromName #name
--Returns true on success, and an array of all nodes on the layer in the by-reference Out parameter.
layer.nodes &theNodes
select theNodes
2012年3月2日 星期五
2012年2月14日 星期二
MAXscript : 如何自動觸發Dialog中的按鈕
在Max中有許多不被MAXscript直接支援的東西,譬如說Load Envelopes等等的Dialog,此時可靠一個callback function來解決,CGS的Bobo分享了這個方法,另外在這邊也有相關討論。
這個callback是case sensitive
fn ANoon_EnvelopeCallbackFunction =
(
WindowHandle = DialogMonitorOPS.GetWindowHandle()
theDialogName = UIAccessor.GetWindowText WindowHandle
if theDialogName != undefined and matchpattern theDialogName pattern:"*Load Envelopes*" do
UIAccessor.PressButtonByName WindowHandle "OK" true
)
DialogMonitorOPS.RegisterNotification ANoon_EnvelopeCallbackFunction ID:#ANoon_Envelopes
DialogMonitorOPS.Enabled = true
這個callback是case sensitive
2012年2月9日 星期四
MAXscript : Skinops Methods
今天想寫個merge已綁定模型的同時也自動將skin加上去的script,但是當寫到給merge進來的模型add bone的時候就是一直** system exception **,搞了好久一直找不到原因,上網搜了一下找到答案了,原來是skinops的methods一定要在該skin modifier可以被選取的狀態下才可以使用!!真是太不人性化了...
Help裡面就有寫著,一直被我無視...
Help裡面就有寫著,一直被我無視...
The following methods require that the Skin modifier be the displayed modifier in the Modify panel, and that the Modify panel is active.addbone後要執行load envlope時,又遇到一個問題,load envlope雖然成功執行,但是卻沒有load到envlope,咕狗後發現解決辦法(還有如何執行load envlope dialog的按鈕的方法),一為執行load envlope兩次,二為在load envlope之前加入completeRedraw()。
2012年2月7日 星期二
MAXscript : 控制外部文件
MAXscript 控制外部文件的函數 (適用於max檔案及非max檔案)
getFiles "wild_card_filename_string"
Returns an array of file names that match the given wild-card path name. The following example gets an array of all the .max scene files in c:\foo and then loops over the array, opening each file and printing the objects in each:
files = getFiles "c:\\foo\\*.max"
for f in files do (loadMAXFile f; print objects)
getFiles() can also be used to determine if a file exists.
getDirectories "wild_card_directory_name_string"
Returns an array of directory paths that match the given wild-card directory path name.
makeDir "directorypath_string"all:
Return false on failure (either because the path could not be created or because the path already existed).
deleteFile "filename_string"
Fails if the file is open in MAXScript.
renameFile "old_filename_string" "new_filename_string"
Renames the old file to the new file. This can also be used to move a file between directories. Fails if new file already exists or if the old file is open in MAXScript. Returns true on success, false on failure.
copyFile "existing_ filename_string" "new_filename_string"
Copies the existing file to the new file. Fails if the new file already exists, the new file cannot be created, or the existing file is open in MAXScript. Returns true on success, false on failure.
getFileSize "filename_string"
Returns the size of the specified file in bytes. Returns 0 if the file could not be found.
getFileAttribute "filename_string" "attribute"
setFileAttribute "filename_string" "attribute"
The valid values are:
#readOnly #hidden #system #directory #archive #temporary #normal
getFileModDate "filename_string"
getFileCreateDate "filename_string"
getFileVersion "filename_string"
This data is typically specified only for executable and application extension (i.e., .dll) files.
FileStream Values
createFile
openFile [ mode: ]
close filepath
Standard Open and Save File Dialogs
getOpenFileName
getSaveFileName
Both functions return a fully-specified file path name or undefined if the user cancels out.
When the optional keyword filename: is supplied, the string is used to define the path and file name of the file to be loaded or saved. The dialog automatically navigates to the specified path (if available on the disk/network), displays its content in the browsing area and suggests the file name in the "File name" field. If the path does not exist, the current path is used and only the file name is displayed as requested.
getMAXFileObjectNames
傳回該檔案內物件的字串陣列
checkForSave()
儲存確認視窗
shellLaunch "notepad.exe" filepath
執行外部程式 eg. Notepad
File Name Parsing 檔名的解析
filenameFromPath "filename_string"
從完整的檔案路徑中擷取檔名(包含副檔名)
getFilenamePath " filename_string "
getFilenameFile " filename_string "
getFilenameType " filename_string "
從完整的檔案路徑中獲得目錄路徑、檔案檔名(不含副檔名)、副檔名
doesFileExist " filename_string "
return True or False
getFiles "wild_card_filename_string"
Returns an array of file names that match the given wild-card path name. The following example gets an array of all the .max scene files in c:\foo and then loops over the array, opening each file and printing the objects in each:
files = getFiles "c:\\foo\\*.max"
for f in files do (loadMAXFile f; print objects)
getFiles() can also be used to determine if a file exists.
getDirectories "wild_card_directory_name_string"
Returns an array of directory paths that match the given wild-card directory path name.
makeDir "directorypath_string"
Return false on failure (either because the path could not be created or because the path already existed).
deleteFile "filename_string"
Fails if the file is open in MAXScript.
renameFile "old_filename_string" "new_filename_string"
Renames the old file to the new file. This can also be used to move a file between directories. Fails if new file already exists or if the old file is open in MAXScript. Returns true on success, false on failure.
copyFile "existing_
Copies the existing file to the new file. Fails if the new file already exists, the new file cannot be created, or the existing file is open in MAXScript. Returns true on success, false on failure.
getFileSize "filename_string"
Returns the size of the specified file in bytes. Returns 0 if the file could not be found.
getFileAttribute "filename_string" "attribute"
setFileAttribute "filename_string" "attribute"
The valid
#readOnly #hidden #system #directory #archive #temporary #normal
getFileModDate
getFileCreateDate
getFileVersion
This data is typically specified only for executable and application extension (i.e., .dll) files.
FileStream Values
createFile
openFile
getOpenFileName
getSaveFileName
Both functions return a fully-specified file path name or undefined if the user cancels out.
When the optional keyword filename: is supplied, the string is used to define the path and file name of the file to be loaded or saved. The dialog automatically navigates to the specified path (if available on the disk/network), displays its content in the browsing area and suggests the file name in the "File name" field. If the path does not exist, the current path is used and only the file name is displayed as requested.
傳回該檔案內物件的字串陣列
checkForSave()
儲存確認視窗
shellLaunch "notepad.exe" filepath
執行外部程式 eg. Notepad
File Name Parsing 檔名的解析
filenameFromPath "filename_string"
從完整的檔案路徑中擷取檔名(包含副檔名)
getFilenamePath " filename_string "
getFilenameFile " filename_string "
getFilenameType " filename_string "
從完整的檔案路徑中獲得目錄路徑、檔案檔名(不含副檔名)、副檔名
doesFileExist " filename_string "
return True or False
2012年2月5日 星期日
Maxscript / Python / OLE
PYTHON
Python
(Offical) http://python.org/
(Offical) Wiki http://wiki.python.org/
Google Code University - Python Tutorials
com
用Python控制Excel的範例 - www.dev.idv.tw
使用Python來控制MS Word (參考, 含說明)
利用Python操作Excel - SkiFF
Python and Com http://www.boddie.org.uk/python/COM.html
Tech Art Tiki: Calling Python from MaxScript
Tech Art Tiki: Photoshop scripting with Python
PhotoshopCS5 VBScript Scripting Reference
dev.idv.tw : 使用Python來控制MS Word
dev.idv.tw : 用Python控制Excel的範例
OpenSourceCode : Python 操作 Word, Excel, Access
pyQT
(Offical)River Bank http://www.riverbankcomputing.co.uk/
http://zetcode.com/tutorials/pyqt4/introduction/
xlrd xlwt
Working with Excel files in Python - http://www.python-excel.org/
MAXSCRIPT
OLE Automation
Maxscript to Excel : OLE Automation - Max Help
Setting Up MAXScript OLE Automation - project3d.narod.ru : 如何設定為OLE Server
--
PS5 OLE Automation Programming Guide
OLE with Excel
py3dsMax
blur-devBlur Studio API's, Libraries and Tools : Python and 3dsMax
Python
(Offical) http://python.org/
(Offical) Wiki http://wiki.python.org/
Google Code University - Python Tutorials
com
用Python控制Excel的範例 - www.dev.idv.tw
使用Python來控制MS Word (參考, 含說明)
利用Python操作Excel - SkiFF
Python and Com http://www.boddie.org.uk/python/COM.html
Tech Art Tiki: Calling Python from MaxScript
Tech Art Tiki: Photoshop scripting with Python
PhotoshopCS5 VBScript Scripting Reference
dev.idv.tw : 使用Python來控制MS Word
dev.idv.tw : 用Python控制Excel的範例
OpenSourceCode : Python 操作 Word, Excel, Access
pyQT
(Offical)River Bank http://www.riverbankcomputing.co.uk/
http://zetcode.com/tutorials/pyqt4/introduction/
xlrd xlwt
Working with Excel files in Python - http://www.python-excel.org/
MAXSCRIPT
OLE Automation
Maxscript to Excel : OLE Automation - Max Help
Setting Up MAXScript OLE Automation - project3d.narod.ru : 如何設定為OLE Server
--
PS5 OLE Automation Programming Guide
OLE with Excel
py3dsMax
blur-devBlur Studio API's, Libraries and Tools : Python and 3dsMax
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...
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.
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.
2012年1月29日 星期日
2012年1月11日 星期三
Bone-Gimbal & Gimbal Lock
在3dsMax創bone的時候,座標系的旋轉值會因為創bone時的軸向而異(viewport也有關聯),會造成錯誤的gimbal軸向(Euler Controller的問題,x跟z軸會重疊),導致調curves的時候會異常困難,動態也有問題。在網路上搜到了一個討論串提到了解決方法:
- 建立一個dummy對齊bone的pivot,將bone link給dummy,對dummy上key
- 創好bone之後,選取bone後alt+RMB執行Freeze transform
在搜尋解決方式時也發現了Gimbal Lock一詞,這個現象的相關資料:
Gimbal Lock到底該怎麼稱呼?
Wikipedia:Gimbal Lock
Gimbal Lock 萬向鎖 (內文有滿深入的講解跟有用的連結)
Gimbal Lock到底該怎麼稱呼?
Wikipedia:Gimbal Lock
Gimbal Lock 萬向鎖 (內文有滿深入的講解跟有用的連結)
2011年12月26日 星期一
MAXscript : 新創同樣BoneList的Skin
從現有已加完Bones的Skin中,抓取Bone List到新的Skin中
--從已有的Skin中抓取骨骼的Name
bonesAry = for i in 1 to skinOps.getNumberBones $.skin collect skinOps.getBoneName $.skin i 0
--加入到新的Skin中
for i in 1 to boneAry.count do skinOps.addBone $.skin (getNodeByName boneAry[i]) 0
--從已有的Skin中抓取骨骼的Name
bonesAry = for i in 1 to skinOps.getNumberBones $.skin collect skinOps.getBoneName $.skin i 0
--加入到新的Skin中
for i in 1 to boneAry.count do skinOps.addBone $.skin (getNodeByName boneAry[i]) 0
2011年12月4日 星期日
Maxscript : Writing Better and Faster Scripts
( Frequently Asked Questions in MAXscript help)
Disable Viewport Redraws when making changes to scene objects
You can use the with redraw off() context or a pair of disableSceneRedraw() and enableSceneRedraw() calls to speed up you code. The former method is the preferred one.
Disable Undo system when possible
ondo off( ... ) ; ondo on( ... ) ; with undo off
print (et-st) --print the resulting time
gc() --call Garbage Collection &endash; you will needed it!
Modify Panel can be slow - change to Create Panel when possible
In 3ds Max 7 and higher, you can also completely disable Modify Panel updates using the suspendEditing() and resumeEditing() methods
Only calculate once if possible
Try to avoid running the same calculation more than once, or interrogating the same value in the same node more than once.
Cache frequently used functions and objects
You can store frequently used functions and objects in user variables to faster access.
Pre-initialize arrays when final size is known
When adding elements to an array using the append method, a copy of the original array is being created in memory before the new array is created. When the size of an array is known before the array is actually used, it is a good practice to pre-initialize the array in memory by assigning the last element of the array to some temporary value. This will create an array of the desired size in memory and will let you simply assign values to any element of the array using indexed access without the memory overhead of the append method.
MyArray = #()
MyArray[100] = 0 --initialize a 100 elements array in memory
for i = 1 to 100 do MyArray[i] = random 1 100 --assign to predefined array
matchPattern is faster than findString
When searching for a substring inside a string, using the matchPattern() method is faster than using findString().
Executing the same method one million times on the same PC resulted in:
3.7 seconds execution time for matchPattern
5.9 seconds execution time for findString
5.0 seconds execution time for subString when comparing the first 3 characters.
Do not use return, break, exit or continue
Return, break, exit, continue and throw are implemented using C++ exception.
C++ exceptions are SLOW!
Use StringStream to build large strings
If building strings, use a StringStream value to accumulate the string and then convert to a string.
fn test5d =
(
local ss = stringstream"",fmt ="%"
for i = 1 to 100 do format fmt ito:ss
ss as string
)
Using Bsearch For Fast Table Lookup
The bsearch() method available in 3ds Max 2009 and higher allows for very fast table lookup operations in sorted arrays.
The bsearch() method available in 3ds Max 2009 and higher allows for very fast table lookup operations in sorted arrays.
2011年12月2日 星期五
Maxscript : Right-Handed to Left-Handed
正解!!Right to Left or Left to Right:by cmann
Let me try to explain it a little better. I need to export from Blender, in which the z axis is facing, to OpenGL where the y axis is facing up.
For every coordinate (x, y, z) it's simple, swap the y and z values: (x, z, y).
Because I have swapped the all of the y and z values any matrix that I use also needs to be flipped so that it has the same affect .
Because I have swapped the all of the y and z values any matrix that I use also needs to be flipped so that it has the same affect .
After a lot of searching I've eventually found a solution here:
http://www.gamedev.net/community/forums/topic.asp?topic_id=537664
If your matrix looks like this:
http://www.gamedev.net/community/forums/topic.asp?topic_id=537664
If your matrix looks like this:
{ rx, ry, rz, 0 }
{ ux, uy, uz, 0 }
{ lx, ly, lz, 0 }
{ px, py, pz, 1 }
To change it from left to right or right to left, flip it like this:
{ rx, rz, ry, 0 }
{ lx, lz, ly, 0 }
{ ux, uz, uy, 0 }
{ px, pz, py, 1 }
訂閱:
文章 (Atom)