autocadmap短线检查源码
<p>//-------------------------------------短线检查----------------------------------------------------------<br/>void CleanupShortLine()<br/>{<br/> SetCurLayer(_T("checklayer"),250);<br/> ade_id cleanupVarId = ADE_NULLID; // variable ID<br/> ade_id cleanupModelId = ADE_NULLID; // clean ID<br/> ade_id cleanupactionVarId = ADE_NULLID; //variable ID<br/> ads_name ss; // selection set<br/> long qty = 0; // quantity数量<br/> long totalqty=0; //所有错误的总和<br/> int type = 0; // clean error group type<br/> int subtype = 0; // clean error group subtype<br/> int done = 0; //是否完成清理工作<br/> int resultCode = 0;<br/> CString str;<br/> //给cleanup变量分配内存,变量初始化为它们的缺省值,使用tpm_varalloc.<br/> cleanupVarId = tpm_varalloc();<br/> cleanupactionVarId=tpm_varalloc();<br/> //为cleanup模型分配内存,使用 tpm_cleanalloc. <br/> cleanupModelId = tpm_cleanalloc();</p><p> if( ! cleanupVarId || ! cleanupModelId ||!cleanupactionVarId) <br/> {<br/> acutPrintf(_T("\n内存分配失败."));<br/> tpm_varfree(cleanupVarId);<br/> tpm_cleanfree(cleanupModelId);<br/> return;<br/> }<br/> tpm_cleanactionlistins(cleanupVarId,1,1,cleanupactionVarId);//必须在tpm_cleaninit前调用<br/> tpm_cleanactionlistins(cleanupVarId,2,256,cleanupactionVarId);//必须在tpm_cleaninit前调用</p><p> if(acedSSGet(_T("X"),NULL,NULL,NULL,ss)!= RTNORM)//第一个参数为NULL为自由选,“X”为全选<br/> {<br/> acutPrintf(_T("\n获取选择集失败!"));<br/> tpm_varfree(cleanupVarId); <br/> tpm_cleanfree(cleanupModelId); <br/> tpm_varfree(cleanupactionVarId); <br/> return;<br/> }<br/> // 初始化一个目标选择集命名为 ss进行清理工作<br/> tpm_cleaninit(cleanupModelId, cleanupVarId, ss);//初始化清理模型<br/> resultCode = tpm_cleanstart(cleanupModelId);//开始清理进程</p><p> if( resultCode != RTNORM )<br/> {<br/> acutPrintf(_T("\n清理工作启动失败.")); <br/> tpm_varfree(cleanupVarId); <br/> tpm_varfree(cleanupactionVarId); <br/> tpm_cleanfree(cleanupModelId); <br/> return; <br/> }<br/> // Count errors by group type and subtype<br/> while ( ! done)<br/> {<br/> resultCode = tpm_cleangroupnext(cleanupModelId);<br/> if ( resultCode == RTNORM ) <br/> { <br/> if (tpm_cleancomplete(cleanupModelId) == TRUE ) <br/> {<br/> done = 1; <br/> }<br/> else <br/> { <br/> type = tpm_cleangrouptype(cleanupModelId); <br/> subtype = tpm_cleangroupsubtype(cleanupModelId); <br/> tpm_cleangroupqty(cleanupModelId, &qty); <br/> tpm_cleangroupmark(cleanupModelId);<br/>// tpm_cleangroupfix(cleanupModelId);<br/> if(qty>0)<br/> {<br/> acutPrintf(_T("\n组类型:%d,子类型:%d,错误数目:%</p><p>d"),type,subtype,qty); <br/> totalqty+=qty;<br/> }<br/> } // else <br/> } // if <br/> else<br/> {<br/> acutPrintf(_T("\n没有要清理的对象"));<br/> }<br/> } // while<br/> resultCode = tpm_cleanend(cleanupModelId);//完成清理进程并更新图形,修复被tpm_cleanerrorfix指定的</p><p>要修复的错误<br/> resultCode = acedSSFree(ss);//最后释放选择集<br/> tpm_cleanfree(cleanupModelId);//释放清理模型<br/> tpm_varfree(cleanupVarId);//释放配置变量<br/> tpm_varfree(cleanupactionVarId);//释放配置变量<br/> if(totalqty==0)<br/> str.Format(_T("\n恭喜!未找到任何错误。"));<br/> else<br/> str.Format(_T("短线错误%d处"),totalqty);<br/> acedAlert(str);<br/>}<br/></p>
页:
[1]