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

  • 相关阅读:
    通过哪吒动漫豆瓣影评,带你分析python爬虫与BeautifulSoup快速入门
    带着canvas去流浪系列之九 粒子动画
    带着canvas去流浪系列之八 碰撞
    Python小数据保存,有多少中分类?不妨看看他们的类比与推荐方案...
    免费试用 | 多模 NoSQL 服务GeminiDB for Cassandra 全球首发
    Vue+ElementUI项目使用webpack输出MPA
    nmon
    补习系列(12)-springboot 与邮件发送
    从React 编程到"好莱坞"
    百度网盘API的操作--PCS 百度个人云存储 上传 ,下载文件
  • 原文地址:https://www.cnblogs.com/edata/p/15631124.html
Copyright © 2011-2022 走看看