作者VinceDunk (飞人卡特)
看板Visual_Basic
标题[VBS ] Wscript物件使用
时间Tue Jul 15 16:50:24 2008
各位大大你好
我们有个系统 是用来显示连续的图片
而这些图片呢 是要经过一个叫 ESRI ArcMap这个软体所绘制的
然後绘制图片需要很多步骤
所以ArcMap它里面有一个功能 叫 Model Builder
可以把这些动作都包起来
此外它还可以输出成 VB Script的码
不过它只有片段而已 并不是可以执行的
所以我想到是写一段 VB Script 把它加在系统的网页里
<html>
<head>
<script language="VBScript">
Sub RunProgram
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "ArcMap.exe D:\test.mxd"
' Create the Geoprocessor object
set gp = WScript.CreateObject("esriGeoprocessing.GPDispatch.1")
' Check out any necessary licenses
gp.CheckOutExtension "GeoStats"
' Load required toolboxes...
gp.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Geostatistical
Analyst Tools.tbx"
gp.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management
Tools.tbx"
' Set the Geoprocessing environment...
gp.scratchWorkspace = "C:\test"
' Script arguments...
请在”=”後键入周数,例如2007年第1周,就输入200701 =
wscript.arguments.item(0)
if 请在”=”後键入周数,例如2007年第1周,就输入200701 = "#" then
请在”=”後键入周数,例如2007年第1周,就输入200701 = """周别"" = 200701" '
provide a default value if unspecified
end if
请选择图层 = wscript.arguments.item(1)
if 请选择图层 = "#" then
请选择图层 = "testpoint" ' provide a default value if unspecified
end if
GA_lyr = wscript.arguments.item(2)
if GA_lyr = "#" then
GA_lyr = "C:\test\GA.lyr" ' provide a default value if unspecified
end if
汇出的图层 = wscript.arguments.item(3)
if 汇出的图层 = "#" then
汇出的图层 = "C:\test\point_test.shp" ' provide a default value if
unspecified
end if
' Local variables...
点图层暂存 = "testpoint"
GA_Layer暂存 = "GALayer"
Ordinary_Kriging = "Ordinary Kriging"
' Process: 利用属性选取...
gp.SelectLayerByAttribute_management 请选择图层, "NEW_SELECTION", 请在”=”後
键入周数,例如2007年第1周,就输入200701
' Process: 汇出所选取的图层...
gp.CopyFeatures_management 点图层暂存, 汇出的图层, "", "0", "0", "0"
' Process: Create Geostatistical Layer...
gp.GACreateGeostatisticalLayer_ga Ordinary_Kriging, "C:\test\point_test.shp 病
例比率千", GA_Layer暂存
' Process: Save To Layer File...
gp.SaveToLayerFile_management GA_Layer暂存, GA_lyr
End Sub
</script>
</head>
<body>
<button onclick="RunProgram">Run Program</button> <p>
</body>
</html>
执行结果 它是说 型态不符合 RunProgram
不知道哪边的程式有问题呢
谢谢大家
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 211.76.175.169