acedinitget

// 提示用户选择选择方式

        acedInitGet(0, _T("W CP"));

        int nRs = acedGetKword(_T("\n请输入关键字确定选择方式[窗选(W)/圈交(CP)]:<点选>"), szKword);

 

if (RTCAN == nRs)   // 取消

        {

            return;

        }

        elseif (RTNONE == nRs)  // 默认为点选

        {

            // 让用户选择一个点

            ads_point pt;

            nRs = acedGetPoint(NULL, _T("\n请选择点:"), pt);

            if (RTNORM != nRs)  // 取消

                return;

           

            nRs = acedSSGet(NULL, pt, NULL, NULL, ss);

        }

        elseif (RTNORM == nRs)

        {

            if (_tcscmp(szKword, _T("W")) == 0)

            {

                // W方式选择集,需要两个点

                ads_point pt1, pt2;

                nRs = acedGetPoint(NULL, _T("\n请输入第一个角点:"), pt1);

                if (RTNORM != nRs)

                    return;

 

                nRs = acedGetPoint(pt1, _T("\n请输入第二个角点:"), pt2);

                if (RTNORM != nRs)

                    return;

 

                nRs = acedSSGet(_T("W"), pt1, pt2, NULL, ss);

            }

            elseif (_tcscmp(szKword, _T("CP")) == 0)

            {

                // CP方式构造选择集,需要一组点,此处需要四个点

                ads_point pt[4];

                nRs = acedGetPoint(NULL, _T("\n输入第一个点:"), pt[0]);

                if (RTNORM != nRs)

                    return;

 

                nRs = acedGetPoint(pt[0], _T("\n第二个点:"), pt[1]);

                if (RTNORM != nRs)

                    return;

 

                nRs = acedGetPoint(pt[1], _T("\n第三个点:"), pt[2]);

                if (RTNORM != nRs)

                    return;

 

                nRs = acedGetPoint(pt[2], _T("\n第四个点:"), pt[3]);

                if (RTNORM != nRs)

                    return;

 

                resbuf* pRb = acutBuildList(RTPOINT, pt[0], RTPOINT, pt[1], RTPOINT, pt[2], RTPOINT, pt[3], 0);

                nRs = acedSSGet(_T("CP"), pRb, NULL, NULL, ss);

                acutRelRb(pRb);

            }

            else

            {

                acutPrintf(_T("\n无效输入"));

                return;

            }

        }

        else

        {

            acutPrintf(_T("\n无效输入"));

            return;

        }

 

        if (RTNONE == nRs)

        {

            acutPrintf(_T("\n选择集为空"));

            return;

        }

        elseif (RTNORM != nRs)

        {

            acutPrintf(_T("\n构建选择集失败"));

            return;

        }

 

        //////////////////////////////////////////////////////////////////////////

        // 遍历选择集,删除实体

        long lLen = 0;

        acedSSLength(ss, &lLen);

        for (long index = 0; index < lLen; index++)

        {

            ads_name ent;

            AcDbObjectId objId;

            acedSSName(ss, index, ent);

 

            acdbGetObjectId(objId, ent);

            if (!objId.isValid())

                continue;

 

            AcDbEntity* pEnt = NULL;

            if (Acad::eOk != acdbOpenAcDbEntity(pEnt, objId, AcDb::kForWrite))

                continue;

 

            pEnt->erase();

            pEnt->close();

        }

 

        acutPrintf(_T("\n删除成功"));

        return;

    }

} ;

 

posted @ 2015-07-30 10:13  xzh1993  阅读(1071)  评论(0编辑  收藏  举报