8,452
edits
Paradox-01 (talk | contribs) mNo edit summary |
Paradox-01 (talk | contribs) mNo edit summary |
||
Line 111: | Line 111: | ||
* run the current code in the Script Editor window: [F5] | * run the current code in the Script Editor window: [F5] | ||
* clear the log: Edit > Clear History Log | * clear the log: Edit > Clear History Log | ||
* | * Actions from button embedded code will be logged. | ||
* | * Actions from code files that are linked in a button won't be logged. (This results in a performance boost.) | ||
* you can save your code to a file via "File" > "Save As..." or "Save Selection" | * Logged stuff will be rewritten if you change the script language. (File > Preferences...) | ||
* You can also change the language by right-click the white script box and click on "Set to JScript" or "Set to VBScript". | |||
* Same way you can load a few code piece, e.g. "Syntax Help" > "If..Else" or "Catch Error". | |||
* Mark code you want to disable ("Comment Out") or enable ("Comment Remove"). | |||
* You can save your code to a file via "File" > "Save As..." or "Save Selection" | |||
Line 136: | Line 140: | ||
'''some basics of VBScript''' | '''some basics of VBScript''' | ||
* In VBS you declare variables only as a variant e.g. "dim PolygonCount". Mod Tool decides what type it becomes when it uses the variable the first time. | * In VBS you declare variables only as a variant e.g. "dim PolygonCount". Mod Tool decides what type it becomes when it uses the variable the first time. | ||
* The commands are not case-sensitive, e.g. you can write ''LogMessage'' or logmessage. | * The commands are not case-sensitive, e.g. you can write ''LogMessage'' or logmessage. | ||
Line 245: | Line 245: | ||
====code pieces (VB Script)==== | ====code pieces (VB Script)==== | ||
Remember that you can use the search function of your web browser. | |||
{| class="wikitable" width="100%" | |||
|width=33%| [1] making an array | |||
|width=33%| [2] check selection mode | |||
| [3] getting the IDs of selected polygons plus sorting them | |||
|- | |||
| [4] converting euler rotations (in degrees) to quaternions | |||
| [5] converting quaternions to euler rotations (in degrees) | |||
| [6] move to frame on the timeline (play control) | |||
|- | |||
| [7] get keyframes | |||
| [8] message box | |||
| [9] input box | |||
|- | |||
| [10] getting the desktop path | |||
| [11] selecting a folder | |||
| [12] selecting a file of a specific type | |||
|- | |||
| [13] reading out environment variables | |||
| [14] check if file exist | |||
| [15] check if folder exist + create folder | |||
|- | |||
| [16] write xml file | |||
| [17] create txt file + write lines | |||
| [18] read txt file | |||
|- | |||
| [19] call CMD, e.g. to use onisplit | |||
| [20] building forms in Softimage | |||
| | |||
|} | |||
' '''making an array''' | |||
' '''[1] making an array''' | |||
' make some object, select them and run the code | ' make some object, select them and run the code | ||
Line 264: | Line 296: | ||
' '''check selection mode ''' | ' '''[2] check selection mode ''' | ||
checkfilter | checkfilter | ||
Line 289: | Line 321: | ||
' '''getting the IDs of selected polygons plus sorting them''' | ' '''[3] getting the IDs of selected polygons plus sorting them''' | ||
poly_count = Selection(0).SubComponent.ComponentCollection.count | poly_count = Selection(0).SubComponent.ComponentCollection.count | ||
Line 318: | Line 350: | ||
' '''converting euler rotations (in degrees) to quaternions | ' '''[4] converting euler rotations (in degrees) to quaternions''' | ||
dim x, y, z, dRotation, qRotation | dim x, y, z, dRotation, qRotation | ||
Line 339: | Line 371: | ||
' '''converting quaternions to euler rotations (in degrees)''' | ' '''[5] converting quaternions to euler rotations (in degrees)''' | ||
dim qW, qX, qY, qZ, qRotation, x, y, z | dim qW, qX, qY, qZ, qRotation, x, y, z | ||
Line 357: | Line 389: | ||
' INFO : 0 | ' INFO : 0 | ||
' INFO : 0 | ' INFO : 0 | ||
' '''[6] move to frame (playcontrol)''' | |||
' '''[7] get keyframes''' | |||
' '''[8] message box''' | |||
[http://download.autodesk.com/global/docs/softimage2013/en_us/sdkguide/index.html?url=si_om/XSIUIToolkit.MsgBox.html,topicNumber=si_om_XSIUIToolkit_MsgBox_html msgbox] "message", , "title" | |||
' '''[9] input box''' | |||
logmessage inputbox ("message", "title" , "pre-entered content") | |||
' '''[10] getting the desktop path''' | |||
' this can be useful for ''default locations'' like when selecting a folder | |||
DesktopPath = CreateObject("WScript.Shell").SpecialFolders("Desktop") | |||
logmessage DesktopPath | |||
' '''[11] selecting a folder''' | |||
' the default path is in this case my desktop | |||
' to make it work on other systems, you would need the code of "getting the desktop path" section and replace my path with the ''DesktopPath'' | |||
logmessage XSIUIToolkit.PickFolder("C:\Users\RMM\Desktop\", "title" ) | |||
' '''[12] selecting a file of a specific type''' | |||
set oFileBrowser = XSIUIToolkit.FileBrowser | |||
oFileBrowser.DialogTitle = "Select an image file (png/tga/jpg)" | |||
' (default folder) | |||
oFileBrowser.InitialDirectory = "c:\" | |||
oFileBrowser.Filter = "JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png| Targa (*.tga)|*.tga||" | |||
oFileBrowser.ShowOpen | |||
If oFileBrowser.FilePathName <> "" Then | |||
logmessage "User selected " & oFileBrowser.FilePathName | |||
Else | |||
logmessage "User pressed cancel" | |||
End If | |||
' '''[13] reading out environment variables''' | |||
' some infos about env vars: [http://softimage.wiki.softimage.com/xsidocs/config_envirovars.htm (1)], [http://softimage.wiki.softimage.com/xsidocs/EnvVars_SettingandUsingEnvironmentVariables.htm (2)], [http://softimage.wiki.softimage.com/xsidocs/EnvVars_EnvironmentVariableReference.htm (3)] | |||
' those variables are stored inside the setenv.bat, two disadvantages: | |||
' adding or editing those vars appears to not work in vbs or I just did it wrong | |||
' anyway, new vars can only be read out after app restart | |||
' therefore let's concentrate on reading out existing ones and how to set up out own vars via txt files in the next section | |||
' code for reading out: | |||
logmessage = XSIUtils.ResolvePath("$SI_HOME/") | |||
' '''[14] check if file exist''' | |||
Set objFSO = CreateObject("Scripting.FileSystemObject") | |||
If objFSO.FileExists ("C:\folder\file.txt") then | |||
logmessage "File exists." | |||
else | |||
logmessage "File doesn't exist." | |||
end if | |||
' '''[15] check if folder exist + create folder''' | |||
' '''[16] write xml file''' | |||
FolderName = CreateObject("WScript.Shell").SpecialFolders("Desktop") | |||
FileName = "test" | |||
FilePath = FolderName & "\OBAN" & FileName & ".xml" | |||
Set oFS = CreateObject("Scripting.FileSystemObject") | |||
Set objXMLFile = oFS.OpenTextFile(FilePath, 2, True, 0) | |||
' quote sign in a string needs two quote signs | |||
objXMLFile.WriteLine "<?xml version=""1.0"" encoding=""utf-8""?>" | |||
objXMLFile.WriteLine "<Oni>" | |||
objXMLFile.WriteLine "..." | |||
' '''[17] create txt file + write lines''' | |||
' '''[18] read txt file''' | |||
' '''[19] call CMD, e.g. to use onisplit''' | |||
' '''[20] building a form''' | |||
edits