调用控件的AddCurrentSelect函数,把实体设置成选中状,函数详见:
http://www.mxdraw.com/help/[email protected]@[email protected]_BOOL.htm
调用控件的ClearCurrentSelect函数清除当前选择
调用IMxDrawSelectionSet::CurrentSelect 得到当前选择的实体,详见:
http://www.mxdraw.com/help/[email protected][in,defaultvalueNULL]_IMxDrawResbuf_.htm
下面代码,得到当前选择的实体:
//实例化一个构造选择集进行过滤,该类封装了选择集及其处理函数。 var ss = mxOcx.NewSelectionSet(); //构造一个过滤链表 var filter = mxOcx.NewResbuf(); ss.CurrentSelect(filter); for (var i = 0; i < ss.Count; i++) { var ent = ss.Item(i); if (ent.ObjectName == "McDbLine") { // 是个直线。 var line = ent; var spt = line.StartPoint; alert(spt.x); alert(spt.y); var ept = line.EndPoint; alert(ept.x); alert(ept.y); } else if (ent.ObjectName == "McDbPolyline") { // 是个多义线. var pl = ent; var j = 0; // 循环,得到端点坐标 for (j = 0; j < pl.NumVerts; j++) { var pt = pl.GetPointAt(j); alert(pt.x); alert(pt.y); } } }
原文地址:https://www.cnblogs.com/yzy0224/p/12016493.html
时间: 2024-11-07 15:29:19