如何选择范围比较?
MxDraw网页开发|黄洪辉|2018-05-07 10:05
-
回答:
首先通过id得到两个控件,返回控件的数据库对象,把两个控件里面不同的内容标记出来,具体实现js代码如下:
function DoImpCompare(points, filter) { var ocx1 = document.getElementById("MxDrawXCtrl1"); var ocx2 = document.getElementById("MxDrawXCtrl2"); var database1 = ocx1.GetDatabase(); var database2 = ocx2.GetDatabase(); var compare1 = ocx1.NewComObject("IMxDrawCompare"); compare1.Bound = points; compare1.Do(database1, database2, filter); var aryDifferent1 = compare1.GetCurveIdsOfTheDifferent(); compare1.DrawFlag(1.0, false); // 反过来比较一下,用来确定,那些对象是新增加的。 var compare2 = ocx1.NewComObject("IMxDrawCompare"); compare2.Bound = points; compare2.Do(database2, database1, filter); var aryDifferent2 = compare2.GetCurveIdsOfTheDifferent(); compare2.DrawFlag(1.0, true); var iErase = 0; var iModify = 0; var iAdd = 0; for (var i = 0; i < aryDifferent1.Count; i++) { var lId = aryDifferent1.AtObjectId(i); if (compare1.GetIsErase(lId)) { iErase = iErase + 1; } else { iModify = iModify + 1; } } for (var i = 0; i < aryDifferent2.Count; i++) { var lId = aryDifferent2.AtObjectId(i); if (compare2.GetIsErase(lId)) { iAdd = iAdd + 1; } } alert(iModify + "对象修改," + iErase + "对象删除," + iAdd + "对象被增加"); }
用户可以选取范围内的图纸作比较,具体实现js代码如下:
function BoundCompare() { var ocx1 = document.getElementById("MxDrawXCtrl1"); var getPt = ocx1.NewComObject("IMxDrawUiPrPoint"); getPt.message = "点取第一点"; if(getPt.go() != 1) return; var frstPt = getPt.value(); var getCorner = ocx1.NewUtility(); var secondPt = getCorner.GetCorner(frstPt,"点取第二点:"); if(secondPt == null) return; var points = ocx1.NewComObject("IMxDrawPoints"); points.Add2(frstPt); points.Add2(secondPt); var filter = ocx1.NewResbuf(); DoImpCompare( points, filter); }