查找图上文字,找到文字内空为"AAA"的文字,并把文字放到视区中间,使用标记圆标出.
C++开发|大少爷|2017-07-27 11:43
-
回答:
IMxDrawSelectionSetPtr ss; ss.CreateInstance(__uuidof( MxDrawXLib::MxDrawSelectionSet )); IMxDrawResbufPtr spFilte; spFilte.CreateInstance(__uuidof( MxDrawXLib::MxDrawResbuf )); // 把文字对象,当着过滤条件. spFilte->AddStringEx("TEXT",5020); // 得到图上,所有文字对象. ss->Select(mcSelectionSetAll,NULL,NULL,spFilte); // 遍历每个文字. for(long i = 0; i < ss->Count;i++) { IMxDrawEntityPtr ent = ss->Item(i); if(ent == NULL) continue; IMxDrawTextPtr spTxt; ent->QueryInterface(&spTxt); if(spTxt == NULL) continue; CString sTxt = spTxt->TextString; if(sTxt == "AAA") { // 把文字放到视区中间. m_ocx.PutEntityInView(spTxt->ObjectID,300); double dLen = m_ocx.ViewLongToDocCoord(80); // 绘制一个标记圆. m_ocx.DrawVectorCircle(spTxt->Position->x, spTxt->Position->y, dLen, 65280); } }