阅读:1754回复:3
[原创]空间元素的编辑
如何将一自己画的线元素polygonline添加到地图的某一线图层中,征求代码!
|
|
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> |
|
|
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> |
|
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编辑过]
|
|
|