zoukankan      html  css  js  c++  java
  • XCLIP xrefs using ObjectARX ----- AcDbSpatialFilter 类设计用来做这个的,在AutoCAD重新生成图形(REGEN)的时候,通过 spatial filter 来决定要处理哪些对象

    ACED_ARXCOMMAND_ENTRY_AUTO(CMyTestApp,
                               MyTestApp,
                               _MyClip, MyClip,
                               ACRX_CMD_TRANSPARENT |
                               ACRX_CMD_NOINTERNALLOCK,
                               NULL)

    static void MyTestApp_MyClip()
    {
        ads_point pt1,pt2;
        ads_name ent;
        if (acedEntSel(_T("Select xref:"),ent,pt1)!=RTNORM)
            return;
        AcDbObjectId idXref;
        if (acdbGetObjectId(idXref,ent)!=Acad::eOk)
            return;
        AcDbObjectPointer<AcDbBlockReference> pRef(idXref,AcDb::kForRead);
        if (pRef.openStatus()!=Acad::eOk)
        {
            acutPrintf(_T("Not an xref! "));
            return;
        }
        AcGePoint2dArray pts;
        if (acedGetPoint(NULL,_T("First point:"),pt1)!=RTNORM)
            return;
        //the ECS of the vertices must be defined in the
        //coordinate system of the _block_ so let's calculate
        //transform all points to that coordinate system

        AcGeMatrix3d mat(pRef->blockTransform());
        mat.invert();

        AcGePoint3d pt3d(asPnt3d(pt1));
        pt3d.transformBy(mat);
        pts.append(AcGePoint2d(pt3d.x,pt3d.y));
        while (acedGetPoint(pt1,_T("Next point:"),pt2)==RTNORM)
        {
            acedGrDraw(pt1,pt2,1,1);
            pt3d = asPnt3d(pt2);
            pt3d.transformBy(mat);
            pts.append(AcGePoint2d(pt3d.x,pt3d.y));
            memcpy(pt1,pt2,sizeof(ads_point));
        }
        acedRedraw(NULL,0);
        AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
        AcGeVector3d normal;
        double elev;
        if (pDb->tilemode())
        {
            normal = pDb->ucsxdir().crossProduct(pDb->ucsydir());
            elev = pDb->elevation();
        }
        else
        {
            normal = pDb->pucsxdir().crossProduct(pDb->pucsydir());
            elev = pDb->pelevation();
        }
        normal.normalize();
        Acad::ErrorStatus es = pRef.object()->upgradeOpen();
        if (es !=Acad::eOk)
            return;
        //create the filter
        AcDbSpatialFilter* pFilter = new AcDbSpatialFilter;
        if (pFilter->setDefinition(pts,normal,elev,
            ACDB_INFINITE_XCLIP_DEPTH,-ACDB_INFINITE_XCLIP_DEPTH,true)!=Acad::eOk)
        {
            delete pFilter;
            return;
        }
        //add it to the extension dictionary of the block reference
        //the AcDbIndexFilterManger class provides convenient utility functions
        if (AcDbIndexFilterManager::addFilter(pRef.object(),pFilter)!=Acad::eOk)
            delete pFilter;
        else
        {
            acutPrintf(_T("Filter has been succesfully added! "));
            pFilter->close();
        }

    }

  • 相关阅读:
    MySQL-Front的安装简介
    【翻译】如何通过使用两台电脑变得更加有效率
    Vim学习资源汇总
    21天战拖记——Day1:不算好的开始(2014-05-04)
    课时97.背景定位上(掌握)
    课时96.背景平铺(掌握)
    课时95.背景图片(掌握)
    课时94.背景颜色(掌握)
    课时93.百度首页(理解)
    课时92.CSS元素显示模式转换(掌握)
  • 原文地址:https://www.cnblogs.com/mjgw/p/12459518.html
Copyright © 2011-2022 走看看