判断一个指令是否存在。脚本执行过程中需要调用第三方插件的指令时,这个函数非常有用。
rhinoscriptsyntax.IsCommand( command_name )
rhinoscript.application.IsCommand( command_name )
command_name |
必须参数。字符串。要判断的指令名称。 |
布尔值 |
存在返回 True,不存在返回 False。 |
import rhinoscriptsyntax as rs
cmdname = rs.GetString("Command name to test")
if cmdname is not None:
iscmd = rs.IsCommand(cmdname)
if iscmd:
print "The", cmdname, "command exists."
else:
print "The", cmdname, "command does not exist."