zoukankan      html  css  js  c++  java
  • 遍历动态块块定义的可见性名称方法

    测试代码

    由于autocad没有公布动态块块定义的相关接口,无法遍历到可见性的名称列表,现有的api只能得到名称,不能确定是可见性还是其他属性,不能够精确的判断。
    此例子可以通过遍历数据库所有对象,通过dxf名称获取可见性句柄,通过entget方式获取相关信息。代码如下。

    		AcDbDatabase *pDb=curDoc()->database();
    		AcDbHandle endHandle= pDb->handseed();
    		for (AcDbHandle h=pDb->blockTableId().handle();h<endHandle;h++)
    		{			
    			AcDbObjectId objId;
    			pDb->getAcDbObjectId(objId,false,h);
    			if (!objId.isNull())
    			{
    				CString strDxfName=objId.objectClass()->dxfName();
    				if (_T("BLOCKVISIBILITYPARAMETER") == strDxfName)
    				{
    					acutPrintf(_T("\nDxfName=%s,Handle="),objId.objectClass()->dxfName());
    					h.print();
    					ads_name ent;
    					Acad::ErrorStatus es= acdbGetAdsName(ent,objId);
    					resbuf *elist= acdbEntGet(ent);
    					if (elist!=NULL)
    					{
    						for (resbuf *eb = elist; eb != NULL; eb = eb->rbnext) 
    						{
    							if (eb->restype == 303)
    							{
    								printdxf(eb);
    							}
    						}												
    						acutRelRb(elist);
    					}
    				}		
    			}
    		}
    

    调用的函数

    	static int printdxf(struct resbuf *eb)
    	{ 
    		int rt; 
    		if (eb == NULL) 
    			return RTNONE; 
    		if ((eb->restype >= 0) && (eb->restype <= 9)) 
    			rt = RTSTR ; 
    		else if ((eb->restype >= 10) && (eb->restype <= 19)) 
    			rt = RT3DPOINT; 
    		else if ((eb->restype >= 38) && (eb->restype <= 59)) 
    			rt = RTREAL ; 
    		else if ((eb->restype >= 60) && (eb->restype <= 79)) 
    			rt = RTSHORT ; 
    		else if ((eb->restype >= 210) && (eb->restype <= 239)) 
    			rt = RT3DPOINT ; 
    		else if (eb->restype < 0) 
    			// Entity name (or other sentinel)
    			rt = eb->restype; 
    		else if (eb->restype == 303)
    			rt = RTSTR ; 		
    		else 
    			rt = RTNONE; 
    		switch (rt) { 
    		case RTSHORT: 
    			acutPrintf(_T("(%d . %d)\n"), eb->restype, 
    				eb->resval.rint); 
    			break; 
    		case RTREAL: 
    			acutPrintf(_T("(%d . %0.3f)\n"), eb->restype, 
    				eb->resval.rreal); 
    			break; 
    		case RTSTR: 
    			acutPrintf(_T("(%d . \"%s\")\n"), eb->restype, 
    				eb->resval.rstring); 
    			break; 
    		case RT3DPOINT: 
    			acutPrintf(_T("(%d . %0.3f %0.3f %0.3f)\n"), 
    				eb->restype, 
    				eb->resval.rpoint[X], eb->resval.rpoint[Y], 
    				eb->resval.rpoint[Z]); 
    			break; 
    		case RTNONE: 
    			acutPrintf(_T("(%d . Unknown type)\n"), eb->restype); 
    			break; 
    		case -1: 
    		case -2:  
    			// First block entity
    			acutPrintf(_T("(%d . <Entity name: %8lx>)\n"), 
    				eb->restype, eb->resval.rlname[0]); 
    		} 
    		return eb->restype; 
    	} 
    

    效果


    鸣谢

    鸣谢 疯狂的青蛙 惊惊

    参考C#代码

    https://www.cnblogs.com/JJBox/p/12489648.html

  • 相关阅读:
    SD卡测试
    测试人员可能会遇到的问题
    HDU 1024 Max Sum Plus Plus
    HDU 1176 免费馅饼
    HDU 1257 最少拦截系统
    HDU 1087 Super Jumping! Jumping! Jumping!
    poj 1328 Radar Installation
    poj 1753 Flip Game
    HDU 1003 Max Sum
    HDU 5592 ZYB's Premutation(BestCoder Round #65 C)
  • 原文地址:https://www.cnblogs.com/edata/p/15631124.html
Copyright © 2011-2022 走看看