8,323
edits
Paradox-01 (talk | contribs) m (→Arrays) |
Paradox-01 (talk | contribs) (simplified two descriptions and added "check selection mode") |
||
Line 1: | Line 1: | ||
==General== | |||
logmessage license | logmessage license | ||
logmessage version | logmessage version | ||
Line 11: | Line 11: | ||
===Variables=== | |||
====Declaration==== | |||
In VBS, any new variable is of type "variant". | In VBS, any new variable is of type "variant". | ||
Line 41: | Line 41: | ||
====Global variables==== | |||
Any variable that gets defined outside a function or subroutine is a global variable. | Any variable that gets defined outside a function or subroutine is a global variable. | ||
Line 84: | Line 84: | ||
' set value | ' set value | ||
XSIUtils.Environment.Setitem "MyVar", "true" | XSIUtils.Environment.Setitem "MyVar", "true" | ||
' get value | ' get value | ||
Line 92: | Line 91: | ||
====Arrays==== | |||
An array is a variable that can contain multiple values, also named elements. VBS arrays are 0-based. For example MyArr(1) has 2 elements (one at index 0 and one at index 1). | An array is a variable that can contain multiple values, also named elements. VBS arrays are 0-based. For example MyArr(1) has 2 elements (one at index 0 and one at index 1). | ||
Line 118: | Line 117: | ||
[...] | [...] | ||
===Directories=== | |||
logmessage XSIUtils.ResolvePath("$XSI_USERHOME/") | logmessage XSIUtils.ResolvePath("$XSI_USERHOME/") | ||
' directory to addons and exported resources | ' directory to addons and exported resources | ||
Line 136: | Line 135: | ||
===Message box=== | |||
' okay-only | ' okay-only | ||
msgbox "message", 0, "title" | msgbox "message", 0, "title" | ||
Line 152: | Line 151: | ||
===Input box=== | |||
MyVar = inputbox ("message", "title" , "pre-entered content") | MyVar = inputbox ("message", "title" , "pre-entered content") | ||
Line 163: | Line 162: | ||
===Check executable version=== | |||
' taking OniSplit as example | ' taking OniSplit as example | ||
Set objFSO = CreateObject("Scripting.FileSystemObject") | Set objFSO = CreateObject("Scripting.FileSystemObject") | ||
Line 172: | Line 171: | ||
==Build an vbs executable== | |||
[[Image:VbsEdit_for_scripting_and_compiling.png|thumb]] | [[Image:VbsEdit_for_scripting_and_compiling.png|thumb]] | ||
Executable, app(lication), program. Whatever you call it, sometimes it might be necessary to compile the script into an actual program. | Executable, app(lication), program. Whatever you call it, sometimes it might be necessary to compile the script into an actual program. | ||
Line 183: | Line 182: | ||
==OS bit version== | |||
if GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth = 64 then | if GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth = 64 then | ||
logmessage "64" | logmessage "64" | ||
Line 199: | Line 198: | ||
==XSI/Softimage bit version== | |||
logmessage XSIUtils.ResolvePath("$XSI_CPU/") | logmessage XSIUtils.ResolvePath("$XSI_CPU/") | ||
' shows programm bit version | ' shows programm bit version | ||
Line 211: | Line 210: | ||
==Read registry== | |||
Mod Tool (because 32-bit) fails to execute following code properly on 64-bit operation systems. | Mod Tool (because 32-bit) fails to execute following code properly on 64-bit operation systems. | ||
Line 228: | Line 227: | ||
==Read file== | |||
===Binary=== | |||
scan_AKEV_file_table | scan_AKEV_file_table | ||
Line 326: | Line 325: | ||
==Modify file== | |||
===Binary=== | |||
[[Image:Before_and_after_binary_patching_with_vbs.png|thumb|400px|Before and after patching.]] | [[Image:Before_and_after_binary_patching_with_vbs.png|thumb|400px|Before and after patching.]] | ||
Change FilePath and in case of binary patching use function "StringToByteArray". | Change FilePath and in case of binary patching use function "StringToByteArray". | ||
Line 371: | Line 370: | ||
==Conversions== | |||
===String -> byte array=== | |||
function StringToByteArray(ThisString) | function StringToByteArray(ThisString) | ||
for i = 1 To Len(ThisString) Step 2 | for i = 1 To Len(ThisString) Step 2 | ||
Line 397: | Line 396: | ||
===Byte array -> string=== | |||
Function ByteArrayToString(Binary) | Function ByteArrayToString(Binary) | ||
'Antonin Foller, http://www.motobit.com | 'Antonin Foller, http://www.motobit.com | ||
Line 432: | Line 431: | ||
==Math== | |||
===Euler rotation -> matrix=== | |||
function cosn (n) | function cosn (n) | ||
cosn = cos(XSIMath.DegreesToRadians(n)) | cosn = cos(XSIMath.DegreesToRadians(n)) | ||
Line 480: | Line 479: | ||
===Matrix -> Euler rotation=== | |||
Function Atan2(y, x) | Function Atan2(y, x) | ||
If x > 0 Then | If x > 0 Then | ||
Line 556: | Line 555: | ||
===Euler rotation -> quaternion=== | |||
dim x, y, z, dRotation, qRotation | dim x, y, z, dRotation, qRotation | ||
x = 90 | x = 90 | ||
Line 582: | Line 581: | ||
===Quaternion -> Euler rotation=== | |||
dim qW, qX, qY, qZ, qRotation, x, y, z | dim qW, qX, qY, qZ, qRotation, x, y, z | ||
Line 607: | Line 606: | ||
'set qRotation = XSIMath.CreateQuaternion (qW, qX, qY, qZ) | 'set qRotation = XSIMath.CreateQuaternion (qW, qX, qY, qZ) | ||
==Softimage-specific stuff== | |||
===Check selection mode=== | |||
checkfilter | |||
'use sub to make use of the exit command | |||
sub checkfilter | |||
Select Case Selection.Filter.Name | |||
'caution: case-sensitive | |||
Case "object" | |||
logmessage "object mode" | |||
Case "Edge" | |||
logmessage "edge mode" | |||
Case "Vertex" | |||
logmessage "point mode" | |||
Case "Polygon" | |||
logmessage "polygon mode" | |||
Case Else | |||
logmessage "unknown mode" | |||
exit sub | |||
End Select | |||
end sub | |||
===Property Page=== | ===Property Page=== | ||
Line 683: | Line 704: | ||
=====Checkbox===== | =====Checkbox===== | ||
' create checkbox and remove key symboles by setting parameter "Animatable" to false ( | ' create checkbox and remove key symboles by setting parameter "Animatable" to false or 0 | ||
oPSet.AddParameter3 "Check1", siBool, | ' CustomProperty.AddParameter3( ScriptName, ValueType, [DefaultValue], [Min], [Max], [Animatable], [ReadOnly] ) | ||
oPSet.AddParameter3 "Check1", siBool, , , , 0, 0 | |||
oPPGLayout.AddItem "Check1", "Checkbox_caption" | oPPGLayout.AddItem "Check1", "Checkbox_caption" | ||
edits