• 获取块中文字


    CString Dialog::GetTextForBlock(AcDbBlockReference *pRef, AcGePoint3d pickPoint)
    {
    AcDbEntity *pEnt;
    CString str=_T("");
    AcDbVoidPtrArray ptarr = NULL;
    Acad::ErrorStatus es=pRef->explode(ptarr);
    int iLen = ptarr.length();
    for (int i = 0; i < iLen;i++)
    {
    pEnt = static_cast<AcDbEntity*>(ptarr[i]);
    AcDbExtents ext;
    pEnt->getGeomExtents(ext);
    auto minPt = AcadUtils::ConvertTo2D(ext.minPoint());
    auto maxPt = AcadUtils::ConvertTo2D(ext.maxPoint());
    AcGePoint2dArray pts;
    pts.append(minPt);
    pts.append(AcGePoint2d(minPt.x, maxPt.y));
    pts.append(maxPt);
    pts.append(AcGePoint2d(maxPt.x, minPt.y));
    if (XFuntion().PtInRegionInXYPlate(pickPoint, pts) && XFuntion().PtInRegionInXYPlate(pickPoint, pts))//命中了包围框
    {
    if (pEnt->isKindOf(AcDbText::desc()))
    {
    AcDbText *pText = NULL;
    pText = AcDbText::cast(pEnt);
    str = pText->textString();
    pText->close();
    return str;
    }
    if (pEnt->isKindOf(AcDbMText::desc()))
    {
    AcDbMText *pmText = NULL;
    pmText = AcDbMText::cast(pEnt);
    str = pmText->contents();
    pmText->close();
    return str;
    }
    if (pEnt->isKindOf(AcDbBlockReference::desc()))
    {
    AcDbBlockReference *pRef = AcDbBlockReference::cast(pEnt);
    str=GetTextForBlock(pRef, pickPoint);
    pRef->close();
    }
    }
    pEnt->close();
    }
    return str;
    }

  • 相关阅读:
    014_Python3 循环语句
    013_Python3 条件控制
    012_Python3 斐波纳契数列 + end 关键字
    011_Python3 集合
    010_Python3 字典
    009_Python3 元组
    008_Python3 列表
    006_Python3 数字(Number)
    005_Python3 运算符
    bzoj3160
  • 原文地址:https://www.cnblogs.com/xzh1993/p/5650916.html
Copyright © 2020-2023  润新知