tiansheng
路人甲
路人甲
  • 注册日期2007-01-25
  • 发帖数11
  • QQ
  • 铜币21枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1754回复:3

[原创]空间元素的编辑

楼主#
更多 发布于:2007-03-06 16:02
如何将一自己画的线元素polygonline添加到地图的某一线图层中,征求代码!
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2007-03-06 16:11
<P>在arcmap里可以用下面的VBA代码</P><PRE>Private Sub UIToolControl3_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)

   Dim pMXDoc As IMxDocument
  Dim pLine As IPolyline
  Dim pRubberLine As IRubberBand
  
  Dim pMap As IMap
  Set pMap = pMXDoc.FocusMap
  
  ' QI for the MXDocument interface
  Set pMXDoc = ThisDocument
  
'get the first layer in the map
  Dim pFeatLyr As IGeoFeatureLayer
  Set pFeatLyr = pMap.Layer(0)
  
  Dim pFClass As IFeatureClass
  Set pFClass = pFeatLyr.FeatureClass
  
  Set pLine = New Polyline
  Dim pFeat As IFeature
  Set pFeat = pFClass.CreateFeature
  
  ' QI for the IGraphicsContainerSelect interface on the document's activeview
  Set pGraCont = pMXDoc.ActiveView
  
  ' Create a new RubberLine
  Set pRubberLine = New RubberLine
 
  
   'Check which mouse button was pressed...
  If button = 1 Then ' If button 1 (left) then create a new Line (TrackNew)
  
    ' Return a new Line from the tracker object using TrackNew
    Set pLine = pRubberLine.TrackNew(pMXDoc.ActiveView.ScreenDisplay, Nothing)
    
     Set pFeat.Shape = pLine
     pFeat.Store
     'pMXDoc.ActivatedView.Refresh
    
    
  Else ' If button 2 (right) then display a message
    MsgBox " Use the Left Button for Digitizing! "
    
  End If
  
  ' Refresh the activeView
  pMXDoc.ActiveView.Refresh

End Sub</PRE>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
alearner
路人甲
路人甲
  • 注册日期2006-09-11
  • 发帖数74
  • QQ
  • 铜币433枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2007-03-07 09:17
<P>请教尊敬的帝国总统:</P>
<P> 如果是在一个含有Z属性的线图层中创建一条线段呢?</P>
<P>我把您的上述代码复制到我的含有Z属性的线图层中,运行时,错误在“Set pFeat.Shape = pLine”这一行,错误提示“The Geometry has no z values”</P>
<P>请教您怎么解决</P>
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
3楼#
发布于:2007-03-07 10:35
<P>Use ZAware = True when you want geometries to retain Z values during geometry operations. </P><P>The following example shows how to make a Point ZAware:<CODE></P><PRE>Dim pPoint1 As IPoint <br>Set pPoint1 = New Point <br>pPoint1.PutCoords 1, 1 <br>Dim pZAware As IZAware <br>Set pZAware = pPoint1 <br>pZAware.ZAware = True <br>pPoint1.z = 11.1 </PRE></CODE><OBJECT><PARAM><PARAM><PARAM></OBJECT>
[此贴子已经被作者于2007-3-7 10:35:43编辑过]
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
游客

返回顶部