TA的每日心情![](source/plugin/dsu_paulsign/img/emot/kx.gif) | 开心 昨天 15:23 |
---|
签到天数: 69 天 [LV.6]常住居民II
管理员
- 积分
- 2704
|
分享下自动读取excel成图技术要点,根据RTK测点的坐标裂成excel格式,然后读取excel坐标在CAD自动生成所要的地物。我写的代码这样:
// 获得Sheet9
_Worksheet excelSheet10;
GetWorkSheet(excelBook, 10, excelSheet10);
rowCount = GetRowCount(excelSheet10);
Range cells10;
cells10.AttachDispatch(excelSheet10.GetCells());
CString fileName9 = TEXT("C:\\环网柜.dwg");
for (long row = 2; row <= rowCount; row++)
{
AcGePoint3d startPoint;
long col = 2;
GetCellValue(cells10, row, col++, startPoint.x);
GetCellValue(cells10, row, col++, startPoint.y);
GetCellValue(cells10, row, col++, startPoint.z);
if (_taccess(fileName9, 0) != -1)
{
AcDbObjectId blkDefId = CBlockUtil::InsertDwgBlockDef(fileName9, TEXT("方井剖面"), true);
// CEntityUtil::SetLayer(blkDefId,TEXT("设备"));
if (blkDefId.isValid())
{
CBlockUtil::InsertBlockRef(blkDefId, AcGePoint3d(startPoint.x, startPoint.y, startPoint.z), 1, 0);
}
}
else
{
acutPrintf(TEXT("\n指定的图形文件不存在."));
}
} |
|