' create a simple script command file
dim fso, f, filename
filename=installationpath(siUserPath)&"\Data\Scripts\"&"helloworld.vbs"
set fso = CreateObject("Scripting.FileSystemObject")
set f = fso.CreateTextFile(filename, True)
f.writeline "logmessage "&chr(34)&"Hello World" & chr(34)
f.close
'create script command
strID = CreateScriptCommand( "Hello World" ,_
"HelloWorld" ,_
filename ,_
"",_
"Example of a simple command" )
' Use the strID with the CreateToolbarButton command
' print information about command
PrintCommand "Hello World"
' execute new command
HelloWorld
' remove the command
RemoveScriptCommand "Hello World"
' check that the command has been removed
PrintCommand "Hello World"
sub PrintCommand(name)
set cmd = Application.Commands(name)
if (typename(cmd) <> "Nothing") then
logmessage cmd.name & " command" & vbCR & vbLF & _
" category: "& cmd.category & vbCR & vbLF & _
" description: "& cmd.description & vbCR & vbLF & _
" tooltip: "& cmd.tooltip & vbCR & vbLF & _
" scriptingname: "& cmd.scriptingname & vbCR & vbLF & _
" handler: " & cmd.handler & vbCR & vbLF & _
" filename: " & cmd.filename & vbCR & vbLF & _
" language: " & cmd.language & vbCR & vbLF & _
" builtin: " & cmd.builtin & vbCR & vbLF & _
" returnvalue: " & cmd.returnvalue & vbCR & vbLF
strArgs = "Arguments:" & vbCR & vbLF
index=0
for each arg in cmd.arguments
strArgs = strArgs & vbTab & "Arg" & index & _
" name:" & arg.name &_
", flags:"& arg.flags & _
", value:"& arg.value& vbCR & vbLF
index=index+1
next
logmessage strArgs
else
logmessage name & " command is not installed"
end if
end sub
sub PrintArgument( arg )
logmessage " " & arg.name &":"& arg.flags
end sub
'INFO : "Hello World"
'INFO : "Hello World command
' category: Custom
' description: Example of a simple command
' tooltip:
' scriptingname: HelloWorld
' handler:
' filename: c:\users\username\softimage\xsi_3.0\data\scripts\helloworld.vbs
' language: VBScript
' builtin: False
' returnvalue: True
'"
'INFO : "Arguments:
' Arg0 name:_ScriptEngine, flags:0, value:VBScript
' Arg1 name:_ScriptName, flags:0, value:c:\users\username\softimage\xsi_3.0\data\scripts\helloworld.vbs
' Arg2 name:_ScriptProcedure, flags:0, value:
' Arg3 name:_ScriptPathType, flags:0, value:0
' Arg4 name:_ScriptResult, flags:-1, value:
'"
'INFO : "Hello World"
'INFO : "Hello World command is not installed"
|