zhengfumin 发表于 2008-4-26 18:14:00

尺寸标注值

<p>TCHAR&nbsp; s;<br/>&nbsp;AcGePoint3d&nbsp; ptemp;<br/>CStdioFile f;<br/>CFileException e;<br/>double val;<br/>TCHAR *pFileName = _T("D:\\尺寸值.txt");<br/>if (!f.Open(pFileName, CFile::modeCreate | CFile::modeWrite, &amp;e))<br/>{<br/>acutPrintf(_T("\n创建导出文件失败!"));<br/>return;<br/>}</p><p>AcDbLayerTable *pLayerTbl;<br/>acdbHostApplicationServices()-&gt;workingDatabase()<br/>-&gt;getSymbolTable(pLayerTbl, AcDb::kForRead);<br/>acedGetString(NULL,_T("请输入要查找的图层名称:"),s);<br/>if (!pLayerTbl-&gt;has(s))<br/>{<br/>acutPrintf(_T("\n当前图形中未包含你要查找的图层!"));<br/>pLayerTbl-&gt;close();<br/>return;<br/>}</p><p>AcDbObjectId layerId; // 图层的ID<br/>pLayerTbl-&gt;getAt(s, layerId);<br/>pLayerTbl-&gt;close();<br/>// 获得当前数据库的块表<br/>AcDbBlockTable *pBlkTbl;<br/>acdbHostApplicationServices()-&gt;workingDatabase()<br/>-&gt;getBlockTable(pBlkTbl, AcDb::kForRead);<br/>// 获得模型空间的块表记录<br/>AcDbBlockTableRecord *pBlkTblRcd;<br/>pBlkTbl-&gt;getAt(ACDB_MODEL_SPACE, pBlkTblRcd,<br/>AcDb::kForRead);<br/>pBlkTbl-&gt;close();<br/>// 创建块表记录遍历器<br/>AcDbBlockTableRecordIterator *pItr; // 块表记录遍历器<br/>pBlkTblRcd-&gt;newIterator(pItr);<br/>AcDbEntity *pEnt; // 遍历的临时实体指针<br/>for (pItr-&gt;start(); !pItr-&gt;done(); pItr-&gt;step())<br/>{<br/>// 利用遍历器获得每一个实体<br/>pItr-&gt;getEntity(pEnt, AcDb::kForWrite);<br/>// 是否在图层上<br/>if (pEnt-&gt;layerId() == layerId)<br/>{</p><p>AcDbAlignedDimension *adimension = AcDbAlignedDimension::cast(pEnt);//对齐标注<br/>AcDbRotatedDimension *rodimension =AcDbRotatedDimension::cast(pEnt);//转角标注<br/>AcDbRadialDimension&nbsp; *rdimension =AcDbRadialDimension::cast(pEnt);//半径标注<br/>AcDbDiametricDimension&nbsp; *ddimension =AcDbDiametricDimension::cast(pEnt);//直径标注<br/>AcDbOrdinateDimension *odimension =AcDbOrdinateDimension::cast(pEnt);//坐标标注<br/>AcDb2LineAngularDimension *ldimension=AcDb2LineAngularDimension::cast(pEnt);//角度标注<br/>if (adimension != NULL)<br/>{</p><p>acutPrintf(_T("\n对齐标注文字是: %.0f"),adimension-&gt;measurement( val )); <br/>CString duiqi; <br/>CString str1;<br/>&nbsp;str1.Format(_T("%d"), adimension-&gt;measurement( val));<br/>&nbsp;duiqi="对齐标注文字是:";<br/>duiqi+= str1; </p><p>f.WriteString(duiqi);<br/>f.WriteString(_T("\n"));</p><p>}<br/>if (rodimension != NULL)<br/>{<br/>acutPrintf(_T("\n转角标注文字是: %.0f"),rodimension-&gt;measurement(val));<br/>CString zhuanjiao; <br/>CString str2;<br/>&nbsp;str2.Format(_T("%.0f"), rodimension-&gt;measurement(val));<br/>&nbsp;zhuanjiao="转角标注文字是:";<br/>zhuanjiao+= str2;</p><p>f.WriteString(zhuanjiao);<br/>f.WriteString(_T("\n"));<br/>}<br/>if (rdimension != NULL)<br/>{<br/>acutPrintf(_T("\n半径标注文字是: %.0f"),rdimension-&gt;measurement(val));<br/>CString banjing; <br/>CString str3;<br/>&nbsp;str3.Format(_T("%.0f"),rdimension-&gt;measurement(val));<br/>&nbsp;banjing="半径标注文字是:";<br/>banjing+= str3;<br/>f.WriteString(banjing);<br/>f.WriteString(_T("\n"));<br/>}<br/>if (ddimension!= NULL)<br/>{<br/>acutPrintf(_T("\n直径标注文字是: %.0f"),ddimension-&gt;measurement(val));<br/>CString zhijing; <br/>CString str4;<br/>&nbsp;str4.Format(_T("%.0f"),ddimension-&gt;measurement(val));<br/>zhijing="直径标注文字是:";<br/>zhijing+= str4;<br/>f.WriteString(zhijing);<br/>f.WriteString(_T("\n"));<br/>}<br/>if (odimension!= NULL)<br/>{<br/>acutPrintf(_T("\n坐标标注文字是: %.0f"),odimension-&gt;measurement(val));<br/>CString zuobiao; <br/>CString str5;<br/>&nbsp;str5.Format(_T("%.0f"),odimension-&gt;measurement(val));<br/>zuobiao="坐标标注文字是:";<br/>zuobiao+= str5;<br/>f.WriteString(zuobiao);<br/>f.WriteString(_T("\n"));<br/>}<br/>if (ldimension != NULL)<br/>{<br/>acutPrintf(_T("\n角度标注文字是: %.0f"),ldimension-&gt;measurement(val));<br/>CString jiaodu; <br/>CString str6;<br/>&nbsp;str6.Format(_T("%.0f"),ldimension-&gt;measurement(val));<br/>jiaodu="角度标注文字是:";<br/>jiaodu+= str6;<br/>f.WriteString(jiaodu);<br/>f.WriteString(_T("\n"));<br/>}<br/>}<br/>// 关闭实体<br/>pEnt-&gt;close();<br/>}<br/>delete pItr; // 删除遍历器!<br/>pBlkTblRcd-&gt;close();</p><p>高手帮忙看看这个程序啊,我调了好长时间了,就是达不到我要的结果,我想输出尺寸标注值!</p>

jackin 发表于 2008-5-3 11:31:00

<p>代码是从哪里copy来的吧?这么简单的错误都没有发现?</p><p>measurement(val),看下这个函数的返回值是什么?</p>

hourui800720 发表于 2011-7-23 15:00:31

pDimStyleTblRcd->setDimdec(2);
pDimStyleTblRcd->g
//设置尺寸变量
setDimVar(pDimStyleTblRcd);

hourui800720 发表于 2011-7-23 16:54:15

pDimStyleTblRcd->setDimdec(2);
pDimStyleTblRcd->g
//设置尺寸变量
setDimVar(pDimStyleTblRcd);
页: [1]
查看完整版本: 尺寸标注值