找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 899|回复: 0

[日积月累]:autocadmap2008重复线检查源码

[复制链接]
发表于 2009-6-19 14:48:57 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
//-------------------------------------重复线检查----------------------------------------------------------
void CleanupDuplicates()
{
        SetCurLayer(_T("checklayer"),250);
        ade_id cleanupVarId = ADE_NULLID;        // variable ID
        ade_id cleanupModelId = ADE_NULLID;      // clean ID
          ade_id cleanupactionVarId = ADE_NULLID;  //variable ID
        ads_name ss;                             // selection set
        long qty = 0;                            // quantity数量(组类型,子类型)
        long totalqty=0;                         //所有错误的总和
        int type = 0;                            // clean error group type
        int subtype = 0;                         // clean error group subtype
        int done = 0;                            //是否完成清理工作
        int resultCode = 0;
        CString str;
        //给cleanup变量分配内存,变量初始化为它们的缺省值,使用tpm_varalloc.
        cleanupVarId = tpm_varalloc();
    cleanupactionVarId=tpm_varalloc();
        //为cleanup模型分配内存,使用 tpm_cleanalloc.
        cleanupModelId = tpm_cleanalloc();

        if( ! cleanupVarId || ! cleanupModelId ||!cleanupactionVarId)
        {
                acutPrintf(_T("\n内存分配失败."));
                tpm_varfree(cleanupVarId);
                tpm_varfree(cleanupactionVarId);
                tpm_cleanfree(cleanupModelId);
                return;
        }
        tpm_cleanactionlistins(cleanupVarId,1,8,cleanupactionVarId);//必须在tpm_cleaninit前调用
        TCHAR* pszConfigVarName = _T("INCLUDEOBJS_AUTOSELECT");//如何指定要清理的图元,0手动,1全部
        struct resbuf* pIncludeObjsVarValRb = acutBuildList(RTSHORT,1,0);
        resultCode = tpm_varset(
                               cleanupVarId,
                            pszConfigVarName,
                            pIncludeObjsVarValRb);//设置配置变量的值
        acutRelRb(pIncludeObjsVarValRb);

        TCHAR* pLayerName =_T("LINK_LAYER");//已设为1,所以此项失效
        struct resbuf* pLayerRb = acutBuildList(RTSTR,_T(""),0);//""为包含所有图层
        resultCode = tpm_varset(
                               cleanupVarId,
                            pLayerName,
                            pLayerRb);//设置配置变量的值
        acutRelRb(pLayerRb);

        // 初始化一个目标选择集命名为 ss进行清理工作
        tpm_cleaninit(cleanupModelId, cleanupVarId, ss);//初始化清理模型
        resultCode = tpm_cleanstart(cleanupModelId);//开始清理进程

        if( resultCode != RTNORM )
        {
                acutPrintf(_T("\n清理工作启动失败."));
                tpm_varfree(cleanupVarId);
                tpm_varfree(cleanupactionVarId);
                tpm_cleanfree(cleanupModelId);
                return;
        }
        // Count errors by group type and subtype
        while ( ! done)
        {
                resultCode = tpm_cleangroupnext(cleanupModelId);
                if ( resultCode == RTNORM )
                {
                        if (tpm_cleancomplete(cleanupModelId) == TRUE )
                                done = 1;
                        else
                        {
                                type = tpm_cleangrouptype(cleanupModelId);
                                subtype = tpm_cleangroupsubtype(cleanupModelId);
                                tpm_cleangroupqty(cleanupModelId, &qty);
                        tpm_cleangroupmark(cleanupModelId);
//                        tpm_cleangroupfix(cleanupModelId);
                                if(qty>0)
                                {
                                        totalqty+=qty;
                                }
                        } // else
                } // if
                else
                {
                        acedAlert(_T("\n没有要检查的对象"));
                }
        } // while
    resultCode = tpm_cleanend(cleanupModelId);//完成清理进程并更新图形,修复被tpm_cleanerrorfix指定的要修复的错误
    resultCode = acedSSFree(ss);//最后释放选择集
        tpm_cleanfree(cleanupModelId);//释放清理模型
        tpm_varfree(cleanupVarId);//释放配置变量
        tpm_varfree(cleanupactionVarId);
        if(totalqty==0)
                str.Format(_T("\n恭喜!未找到任何错误。"));
        else
            str.Format(_T("重复线错误%d处"),totalqty);
        acedAlert(str);
}
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-24 08:32 , Processed in 0.377154 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表