尺寸标注值
<p>TCHAR s;<br/> AcGePoint3d 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, &e))<br/>{<br/>acutPrintf(_T("\n创建导出文件失败!"));<br/>return;<br/>}</p><p>AcDbLayerTable *pLayerTbl;<br/>acdbHostApplicationServices()->workingDatabase()<br/>->getSymbolTable(pLayerTbl, AcDb::kForRead);<br/>acedGetString(NULL,_T("请输入要查找的图层名称:"),s);<br/>if (!pLayerTbl->has(s))<br/>{<br/>acutPrintf(_T("\n当前图形中未包含你要查找的图层!"));<br/>pLayerTbl->close();<br/>return;<br/>}</p><p>AcDbObjectId layerId; // 图层的ID<br/>pLayerTbl->getAt(s, layerId);<br/>pLayerTbl->close();<br/>// 获得当前数据库的块表<br/>AcDbBlockTable *pBlkTbl;<br/>acdbHostApplicationServices()->workingDatabase()<br/>->getBlockTable(pBlkTbl, AcDb::kForRead);<br/>// 获得模型空间的块表记录<br/>AcDbBlockTableRecord *pBlkTblRcd;<br/>pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd,<br/>AcDb::kForRead);<br/>pBlkTbl->close();<br/>// 创建块表记录遍历器<br/>AcDbBlockTableRecordIterator *pItr; // 块表记录遍历器<br/>pBlkTblRcd->newIterator(pItr);<br/>AcDbEntity *pEnt; // 遍历的临时实体指针<br/>for (pItr->start(); !pItr->done(); pItr->step())<br/>{<br/>// 利用遍历器获得每一个实体<br/>pItr->getEntity(pEnt, AcDb::kForWrite);<br/>// 是否在图层上<br/>if (pEnt->layerId() == layerId)<br/>{</p><p>AcDbAlignedDimension *adimension = AcDbAlignedDimension::cast(pEnt);//对齐标注<br/>AcDbRotatedDimension *rodimension =AcDbRotatedDimension::cast(pEnt);//转角标注<br/>AcDbRadialDimension *rdimension =AcDbRadialDimension::cast(pEnt);//半径标注<br/>AcDbDiametricDimension *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->measurement( val )); <br/>CString duiqi; <br/>CString str1;<br/> str1.Format(_T("%d"), adimension->measurement( val));<br/> 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->measurement(val));<br/>CString zhuanjiao; <br/>CString str2;<br/> str2.Format(_T("%.0f"), rodimension->measurement(val));<br/> 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->measurement(val));<br/>CString banjing; <br/>CString str3;<br/> str3.Format(_T("%.0f"),rdimension->measurement(val));<br/> 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->measurement(val));<br/>CString zhijing; <br/>CString str4;<br/> str4.Format(_T("%.0f"),ddimension->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->measurement(val));<br/>CString zuobiao; <br/>CString str5;<br/> str5.Format(_T("%.0f"),odimension->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->measurement(val));<br/>CString jiaodu; <br/>CString str6;<br/> str6.Format(_T("%.0f"),ldimension->measurement(val));<br/>jiaodu="角度标注文字是:";<br/>jiaodu+= str6;<br/>f.WriteString(jiaodu);<br/>f.WriteString(_T("\n"));<br/>}<br/>}<br/>// 关闭实体<br/>pEnt->close();<br/>}<br/>delete pItr; // 删除遍历器!<br/>pBlkTblRcd->close();</p><p>高手帮忙看看这个程序啊,我调了好长时间了,就是达不到我要的结果,我想输出尺寸标注值!</p> <p>代码是从哪里copy来的吧?这么简单的错误都没有发现?</p><p>measurement(val),看下这个函数的返回值是什么?</p> pDimStyleTblRcd->setDimdec(2);pDimStyleTblRcd->g
//设置尺寸变量
setDimVar(pDimStyleTblRcd);
pDimStyleTblRcd->setDimdec(2);
pDimStyleTblRcd->g
//设置尺寸变量
setDimVar(pDimStyleTblRcd);
页:
[1]