如何查找属性快文字?
MxDraw网页开发|黄洪辉|2018-05-07 09:55
-
回答:
var winWidth = 440; var winHeight = 140; var winLeft = (screen.width - winWidth) / 2; var winTop = (screen.height - winHeight) / 2 - 20; var str = 'dialogHeight:' + winHeight + 'px;dialogWidth:' + winWidth + 'px;dialogTop:' + winTop + 'px;dialogLeft:' + winLeft + 'px;resizable:yes;center:yes;status:no;' var rt = window.showModalDialog("Gettext.htm?tmp=" + Math.random(), "输入属性文字", str); var txt; if (typeof (rt) == "undefined") { return; } else { var arr = rt.split(","); txt = arr[0]; } var ss = mxOcx.NewSelectionSet(); var spFilte = mxOcx.NewResbuf(); // 把块对象,当着过滤条件. spFilte.AddStringEx("INSERT", 5020); // 得到图上,所有块对象. ss.Select2(5, null, null, null, spFilte); // 遍历每个块. for (var i = 0; i < ss.Count; i++) { var ent = ss.Item(i); if (ent == null) continue; if (ent.ObjectName == "McDbBlockReference") { var blkref = ent; var j = 0; for (; j < blkref.AttributeCount; j++) { var attrib = blkref.AttributeItem(j); if (attrib.TextString == txt) { // 找到块属性。 mxOcx.PutEntityInView(ent.ObjectID, 300); var dLen = mxOcx.ViewLongToDocCoord(80); // 绘制一个标记圆. mxOcx.DrawVectorCircle(ent.Position.x, ent.Position.y, dLen, 65280); return; } } } ent = null; } alert("没有找到块属性文字"); // 在这里必须显示释放控件的COM对象指针. ss = null; spFilte = null; CollectGarbage();