明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2341|回复: 0

autocadmap短线检查源码

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

//-------------------------------------短线检查----------------------------------------------------------
void CleanupShortLine()
{
 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_cleanfree(cleanupModelId);
  return;
 }
 tpm_cleanactionlistins(cleanupVarId,1,1,cleanupactionVarId);//必须在tpm_cleaninit前调用
 tpm_cleanactionlistins(cleanupVarId,2,256,cleanupactionVarId);//必须在tpm_cleaninit前调用

 if(acedSSGet(_T("X"),NULL,NULL,NULL,ss)!= RTNORM)//第一个参数为NULL为自由选,“X”为全选
 {
  acutPrintf(_T("\n获取选择集失败!"));
  tpm_varfree(cleanupVarId);
  tpm_cleanfree(cleanupModelId);
  tpm_varfree(cleanupactionVarId);
  return;
 }
 // 初始化一个目标选择集命名为 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)
    {
     acutPrintf(_T("\n组类型:%d,子类型:%d,错误数目:%

d"),type,subtype,qty);
     totalqty+=qty;
    }
   } // else
  } // if
  else
  {
   acutPrintf(_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);
}

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 14:34 , Processed in 0.151232 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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