阅读:1570回复:1
[求助]给选中的要素A加节点,却替代了A的下一个要素,问题何在?<P> 大家好,请教给选中的要素加节点的问题?只加一个节点没问题,出现的问题是加第二节点后, curRec中,选中的要素的下一个要素被新生成的要素(选中的要素新加节点形成的)替代了。问题出在哪里呢,如何改正?我的主要代码如下!</P> <P >1, 选中要素,赋给curRec记录集,判断要素类型面或线再赋值给editPoly或editLine</P> <P ><p> </p></P> <P >Private Sub Identify(x As Single, y As Single)</P> <P > 。。。。 和 MOVIEW 的代码一样 </P> <P > Dim aIndex As Long, i As Long</P> <P > aIndex = layerNum(1, 0)</P> <P > aRec = layerNum(2, 0)</P> <P > aName = layerName(aIndex)</P> <P > lyname = aName '选中要素所在的层</P> <P > lyname = ""</P> <P >' Set curRec variable to the correct record.</P> <P > </P> <P > Set curRec = Nothing</P> <P > Set curRec = Recs2(aIndex)</P> <P > </P> <P > curRec.MoveFirst</P> <P > If aRec > 0 Then</P> <P > For i = 1 To aRec</P> <P > curRec.MoveNext</P> <P > Next i</P> <P > End If</P> <P ><p> </p></P> <P > Set editPoly = Nothing</P> <P > Set editLine = Nothing</P> <P > Set undoPoly = Nothing</P> <P > Set undoLine = Nothing</P> <P > </P> <P > If Not curRec Is Nothing Then</P> <P > selected = True</P> <P > If curRec("shape").Type = moPolygon Then</P> <P > Set editPoly = curRec("shape").value</P> <P > Set pts = editPoly.Parts(0) 给点集pts赋值</P> <P > End If</P> <P > </P> <P > If curRec("shape").Type = <st1:City><st1:place>moLine</st1:place></st1:City> Then</P> <P > Set editLine = curRec("shape").value</P> <P > Set pts = editLine.Parts(0) </P> <P > End If</P> <P > </P> <P > Else</P> <P > selected = False</P> <P > End If</P> <P > </P> <P > End If</P> <P > Screen.MousePointer = 0</P> <P > </P> <P >End Sub</P> <P> </P> <P>2.工具条上安下"add"按钮后给state= "add",</P> <P>Private Sub mapDisp_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)</P> <P>select case state</P> <P> Case "select"</P> <P> Call Identify(x, y)</P> <P><p> </p></P> <P> Case "add"</P> <P> If selected Then 如果选中了要素</P> <P> If Not editPoly Is Nothing Then 选中要素是多边形</P> <P> Set pt = mapDisp.ToMapPoint(x, y)</P> <P> Call insertVert(pt, pts) ‘把点pt插入到点集pts</P> <P> curRec.Edit</P> <P> curRec("shape").value = editPoly</P> <P> curRec.Update</P> <P> curRec.StopEditing</P> <P> End If</P> <P> </P> <P> If Not editLine Is Nothing Then 选中要素是线段</P> <P> Set pt = mapDisp.ToMapPoint(x, y)</P> <P> Call insertVert(pt, pts)</P> <P> curRec.Edit</P> <P> curRec("shape").value = editLine</P> <P> curRec.Update</P> <P> curRec.StopEditing</P> <P> End If</P> <P> End If</P> <P> End Select</P> <P >mapDisp.Refresh</P> <P> mapDisp.TrackingLayer.Refresh True</P> <P>End sub<p></p></P> <P> <p></p></P> |
|
1楼#
发布于:2004-04-19 17:09
你可以看看mo自带的例子里的edit的例子,看对你有没有帮助,现在电脑上没mo,一时帮不了你调试
|
|
2楼#
发布于:2004-04-19 20:29
好的,我自己先再看看EDIT的例子吧,我看了自己的程序几天了,就是理不出头绪来!斑主要答辩了,祝他顺利通过吧!
|
|