v1.0
処理
OS のコマンド、プログラム、またはバッチ ファイルを実行できます。 移植性を最大限に高めるために、XSIApplication.Platformプロパティとともに使用することがよくあります。
また、ハードコーディングされたパスの使用率を最低限に抑えるために、XSIApplication.InstallationPathも使用できます。
ご使用のプログラムやバッチ ファイルでは、標準の exit コマンドを使って値を戻すことができます(例: C/C++の
exit(1)、UNIX シェル プログラミングの exit 1、Windows XP バッチ ファイルの exit /b
1)。
通常 OS コマンドは、正常終了時に 0 を、エラー時に他の値を戻します。 詳細についてはご使用の OS
のマニュアルを参照してください。
注: このコマンドは、出力引数を使用します。 C#
および一部のスクリプト言語(JScript、PerlScript、Python
など)は、リファレンスによって渡される引数をサポートしていません。 ただし、戻り値にも出力引数があります。
oDouble = System( Pathname, [Value] ); |
ダブルとして実行するコマンド、プログラム、またはバッチファイルのの戻り値。 この値は、情報をバッチ ファイルまたはカスタム ビルド アプリケーションから Softimage に送信するために使用されます。
' Creates a text file with the content of the project directory
Dim cmdResult ' result of the command line operation
Dim cmd ' command to execute
Dim destinationPath ' destination path for the created file
Dim sourcePath ' path of the directory used to create the file
' source = project path
sourcePath = Application.InstallationPath( siProjectPath )
' output in the user path
destinationPath = Application.InstallationPath( siUserPath )
' create the command line depending on the current platform
Select Case Application.Platform
' Windows
Case "Win32"
cmd = "dir " & sourcePath & " > " & destinationPath & "\content.log"
' Linux
Case Else
cmd = "ls " & sourcePath & " > " & destinationPath & "/content.log"
End Select
' run the constructed command
cmdResult = system( cmd )
' Check if everything went fine
If cmdResult = 0 Then
LogMessage "Success"
Else
LogMessage "Failure"
End If
|
' Running an application through Softimage
Dim customApplication ' the application or batch file to run
Dim customApplicationParam ' parameters to pass to your application
Dim appResult ' the return code of your application
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Set the custom application to run. Put your application
' path here. You could use the Application.InstallationPath
' property along with the Application.Platform property to make
' your code work on any possible user configurations.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
customApplication = "notepad.exe"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Set the parameters to pass to your custom application. This can
' be nothing if none are required.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ApplicationParam = "c:/content.log"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' execute the application
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
appResult = System( customApplication & " " & ApplicationParam )
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Perform actions according to the return value of the application
' The values below must be customised according to the application
' or the batch file that ran.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Select Case appResult
Case 0 LogMessage "Wonderful!"
Case 1 LogMessage "Error case when 1 is returned"
Case 2 LogMessage "Error case when 2 is returned"
Case Else LogMessage "Any other error case"
End Select
|