明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2682|回复: 3

尺寸标注值

[复制链接]
发表于 2008-4-26 18:14:00 | 显示全部楼层 |阅读模式

TCHAR  s[100];
 AcGePoint3d  ptemp;
CStdioFile f;
CFileException e;
double val;
TCHAR *pFileName = _T("D:\\尺寸值.txt");
if (!f.Open(pFileName, CFile::modeCreate | CFile::modeWrite, &e))
{
acutPrintf(_T("\n创建导出文件失败!"));
return;
}

AcDbLayerTable *pLayerTbl;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pLayerTbl, AcDb::kForRead);
acedGetString(NULL,_T("请输入要查找的图层名称:"),s);
if (!pLayerTbl->has(s))
{
acutPrintf(_T("\n当前图形中未包含你要查找的图层!"));
pLayerTbl->close();
return;
}

AcDbObjectId layerId; // 图层的ID
pLayerTbl->getAt(s, layerId);
pLayerTbl->close();
// 获得当前数据库的块表
AcDbBlockTable *pBlkTbl;
acdbHostApplicationServices()->workingDatabase()
->getBlockTable(pBlkTbl, AcDb::kForRead);
// 获得模型空间的块表记录
AcDbBlockTableRecord *pBlkTblRcd;
pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd,
AcDb::kForRead);
pBlkTbl->close();
// 创建块表记录遍历器
AcDbBlockTableRecordIterator *pItr; // 块表记录遍历器
pBlkTblRcd->newIterator(pItr);
AcDbEntity *pEnt; // 遍历的临时实体指针
for (pItr->start(); !pItr->done(); pItr->step())
{
// 利用遍历器获得每一个实体
pItr->getEntity(pEnt, AcDb::kForWrite);
// 是否在图层上
if (pEnt->layerId() == layerId)
{

AcDbAlignedDimension *adimension = AcDbAlignedDimension::cast(pEnt);//对齐标注
AcDbRotatedDimension *rodimension =AcDbRotatedDimension::cast(pEnt);//转角标注
AcDbRadialDimension  *rdimension =AcDbRadialDimension::cast(pEnt);//半径标注
AcDbDiametricDimension  *ddimension =AcDbDiametricDimension::cast(pEnt);//直径标注
AcDbOrdinateDimension *odimension =AcDbOrdinateDimension::cast(pEnt);//坐标标注
AcDb2LineAngularDimension *ldimension=AcDb2LineAngularDimension::cast(pEnt);//角度标注
if (adimension != NULL)
{

acutPrintf(_T("\n对齐标注文字是: %.0f"),adimension->measurement( val ));
CString duiqi;
CString str1;
 str1.Format(_T("%d"), adimension->measurement( val));
 duiqi="对齐标注文字是:";
duiqi+= str1;

f.WriteString(duiqi);
f.WriteString(_T("\n"));

}
if (rodimension != NULL)
{
acutPrintf(_T("\n转角标注文字是: %.0f"),rodimension->measurement(val));
CString zhuanjiao;
CString str2;
 str2.Format(_T("%.0f"), rodimension->measurement(val));
 zhuanjiao="转角标注文字是:";
zhuanjiao+= str2;

f.WriteString(zhuanjiao);
f.WriteString(_T("\n"));
}
if (rdimension != NULL)
{
acutPrintf(_T("\n半径标注文字是: %.0f"),rdimension->measurement(val));
CString banjing;
CString str3;
 str3.Format(_T("%.0f"),rdimension->measurement(val));
 banjing="半径标注文字是:";
banjing+= str3;
f.WriteString(banjing);
f.WriteString(_T("\n"));
}
if (ddimension!= NULL)
{
acutPrintf(_T("\n直径标注文字是: %.0f"),ddimension->measurement(val));
CString zhijing;
CString str4;
 str4.Format(_T("%.0f"),ddimension->measurement(val));
zhijing="直径标注文字是:";
zhijing+= str4;
f.WriteString(zhijing);
f.WriteString(_T("\n"));
}
if (odimension!= NULL)
{
acutPrintf(_T("\n坐标标注文字是: %.0f"),odimension->measurement(val));
CString zuobiao;
CString str5;
 str5.Format(_T("%.0f"),odimension->measurement(val));
zuobiao="坐标标注文字是:";
zuobiao+= str5;
f.WriteString(zuobiao);
f.WriteString(_T("\n"));
}
if (ldimension != NULL)
{
acutPrintf(_T("\n角度标注文字是: %.0f"),ldimension->measurement(val));
CString jiaodu;
CString str6;
 str6.Format(_T("%.0f"),ldimension->measurement(val));
jiaodu="角度标注文字是:";
jiaodu+= str6;
f.WriteString(jiaodu);
f.WriteString(_T("\n"));
}
}
// 关闭实体
pEnt->close();
}
delete pItr; // 删除遍历器!
pBlkTblRcd->close();

高手帮忙看看这个程序啊,我调了好长时间了,就是达不到我要的结果,我想输出尺寸标注值!

发表于 2008-5-3 11:31:00 | 显示全部楼层

代码是从哪里copy来的吧?这么简单的错误都没有发现?

measurement(val),看下这个函数的返回值是什么?

发表于 2011-7-23 15:00:31 | 显示全部楼层
pDimStyleTblRcd->setDimdec(2);
pDimStyleTblRcd->g
//设置尺寸变量
setDimVar(pDimStyleTblRcd);  
发表于 2011-7-23 16:54:15 | 显示全部楼层
pDimStyleTblRcd->setDimdec(2);
pDimStyleTblRcd->g
//设置尺寸变量
setDimVar(pDimStyleTblRcd);  
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 12:58 , Processed in 0.174367 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表