yellow
路人甲
路人甲
  • 注册日期2005-04-25
  • 发帖数7
  • QQ
  • 铜币139枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1254回复:2

在ARCSCENE环境里, 如何在VBA里面写合并两个层的代码??主要是用哪个接口?有人知道吗??谢谢了。。。

楼主#
更多 发布于:2006-07-30 09:57
<P>在ARCSCENE环境里, 如何在VBA里面写合并两个层的代码??主要是用哪个接口?有人知道吗??谢谢了。。。</P>
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2006-07-31 11:11
<P>使用IBasicGeoprocessor接口</P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
2楼#
发布于:2006-07-31 11:16
<TABLE cellSpacing=0 cellPadding=2 width="75%" align=center border=0>

<TR>
<TD class=tdWhite>
<DIV>Public Sub Merge() <BR><BR>' Get the first layer in the map <BR>Dim pMxDoc As IMxDocument <BR>Set pMxDoc = ThisDocument <BR>Dim pLayer As ILayer <BR>Set pLayer = pMxDoc.FocusMap.Layer(0) <BR>Dim pFeatLayer As IFeatureLayer <BR>Set pFeatLayer = pLayer <BR>Dim pFirstFeatClass As IFeatureClass <BR>Set pFirstFeatClass = pFeatLayer.FeatureClass <BR><BR>' Get the first layer’s table <BR>' Use the Itable interface from the Layer (not from the FeatureClass) <BR>' This table defines which fields are to be used in the output <BR>Dim pFirstTable As ITable <BR>Set pFirstTable = pLayer <BR><BR>' Get the second layer and its table <BR>' Use the Itable interface from the Layer (not from the FeatureClass) <BR>Set pLayer = pMxDoc.FocusMap.Layer(1) <BR>Dim pSecondTable As ITable <BR>Set pSecondTable = pLayer <BR><BR>' Error checking <BR>If pFirstTable Is Nothing Then <BR>MsgBox "Table QI failed" <BR>Exit Sub <BR>End If <BR><BR>If pSecondTable Is Nothing Then <BR>MsgBox "Table QI failed" <BR>Exit Sub <BR>End If <BR><BR>' Define the output feature class name and shape type <BR>Dim pFeatClassName As IFeatureClassName <BR>Set pFeatClassName = New FeatureClassName <BR><BR>With pFeatClassName <BR>.FeatureType = esriFTSimple <BR>.ShapeFieldName = "Shape" <BR>.ShapeType = pFirstFeatClass.ShapeType <BR>End With <BR><BR>' Set the output location and feature class name <BR>Dim pNewWSName As IWorkspaceName <BR>Set pNewWSName = New WorkspaceName <BR><BR>With pNewWSName <BR>.WorkspaceFactoryProgID = "esriCore.ShapefileWorkspaceFactory.1" <BR>.PathName = "C:\temp" <BR>End With <BR><BR>Dim pDatasetName As IDatasetName <BR>Set pDatasetName = pFeatClassName <BR>pDatasetName.Name = "Merge_result" <BR><BR>Set pDatasetName.WorkspaceName = pNewWSName <BR><BR>' Build the input set/array – these are the layers to be merged <BR>Dim inputArray As IArray <BR>Set inputArray = New esriCore.Array ' in ArcGIS 9.0 and newer versions replace with '= New esriSystem.Array' <BR>inputArray.Add pFirstTable <BR>inputArray.Add pSecondTable <BR><BR>' Perform the merge <BR>Dim pBGP As IBasicGeoprocessor <BR>Set pBGP = New BasicGeoprocessor <BR>Dim pOutputFeatClass As IFeatureClass <BR>Set pOutputFeatClass = pBGP.Merge(inputArray, pFirstTable, pFeatClassName) <BR><BR>' Add the output to the map <BR>Dim pOutputFeatLayer As IFeatureLayer <BR>Set pOutputFeatLayer = New FeatureLayer <BR>Set pOutputFeatLayer.FeatureClass = pOutputFeatClass <BR>pOutputFeatLayer.Name = pOutputFeatClass.AliasName <BR>pMxDoc.FocusMap.AddLayer pOutputFeatLayer <BR><BR>End Sub <BR></DIV></TD></TR></TABLE>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
游客

返回顶部