找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 138|回复: 0

ARX读取数据展Cass一般高程点

[复制链接]

1

主题

0

回帖

37

积分

管理员

积分
37
发表于 2024-5-2 22:35:21 | 显示全部楼层 |阅读模式
  1. struct resbuf oSysRb, iSysRb;
  2. ads采用real blc, blc1;
  3. acedGetVar("USERR1", &oSysRb);
  4. iSysRb.restype = RTREAL;
  5. iSysRb.resval.rreal = 500;
  6. blc = oSysRb.resval.rreal;
  7. if (blc == 0)
  8. {
  9.     if (acedGetReal("\n请输入比例尺<1:500>", &blc1) != RTNORM)
  10.     {
  11.         iSysRb.resval.rreal = 500;
  12.         acedSetVar("USERR1", &iSysRb);
  13.     }
  14.     acedSetVar("USERR1", &iSysRb);
  15.     blc = iSysRb.resval.rreal;
  16. }
  17. AcDbBlockTable *pBlkTbl;
  18. acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl, AcDb::kForWrite);
  19. CString blkName;
  20. blkName.Format("%s", "GC200");
  21. if (!pBlkTbl->has(blkName))
  22. {
  23.     acutPrintf("\n当前图形中未包含GC200的块定义!");
  24.     pBlkTbl->close();
  25.     return;
  26. }
  27. double xyzScale = blc * 0.001;
  28. double textH = blc * 0.002;  // 设置文字高度
  29. CString strH;
  30. strH.Format("%.3lf", textH);
  31. char strTag[100];
  32. CString str("height");
  33. strncpy(strTag,(LPCTSTR)str,sizeof(strTag));
  34. int rc, i;
  35. ads采用point pt1;
  36. FILE *FP;
  37. char height[80];
  38. double r;
  39. TCHAR *fName;
  40. struct resbuf *rb;
  41. rb = acutNewRb(RTSTR);
  42. int  stat = acedGetFileD("选择txt文件", NULL, "txt;dat",  0, rb);
  43. if ((stat != RTNORM) || (rb == NULL))
  44. {
  45.     acutRelRb(rb);
  46.     return;
  47. }
  48. const size采用t nSize = 采用tcslen(rb->resval.rstring) + 1;
  49. fName =  (TCHAR*)acad采用malloc(nSize *  sizeof(TCHAR));
  50. strcpy(fName, rb->resval.rstring);
  51. acutRelRb(rb);
  52. CString filename;
  53. filename.Format("%s", fName);
  54. FP = fopen(filename, "r");    //以只读形式打开文件
  55. do
  56. {
  57.     fscanf(FP, "%d, %lf, %lf, %lf", &i, &pt1[X], &pt1[Y], &pt1[Z]);
  58.     AcGePoint3d blkbasePt (pt1[X], pt1[Y], pt1[Z]);
  59.     AcGePoint3d textPt (pt1[X] + 0.0012 * blc, pt1[Y] - 0.001 * blc, 0.0);
  60.     AcGePoint3d AlimPt (pt1[X] + 0.0012 * blc, pt1[Y], 0.0);
  61.     r = pt1[Z];
  62.     acdbRToS(r, 2, 2, height);
  63.     AcDbObjectId blkDefId;
  64.     pBlkTbl->getAt(blkName, blkDefId);
  65.     AcDbBlockReference *pBlkRef = new AcDbBlockReference(blkbasePt, blkDefId);
  66.     AcDbBlockTableRecord *pBlkTblRcd;
  67.     pBlkTbl->getAt(ACDB采用MODEL采用SPACE, pBlkTblRcd, AcDb::kForWrite);
  68.     pBlkTbl->close();
  69.     // 块比例系数
  70.     pBlkRef->setScaleFactors(xyzScale);
  71.     // 扩展数据
  72.     struct resbuf *pRb;
  73.     CString appName = "SOUTH";
  74.     CString typeName = "202101";
  75.     pRb = acutBuildList(AcDb::kDxfRegAppName, appName, AcDb::kDxfXdAsciiString, typeName, RTNONE);
  76.     pBlkRef->setXData(pRb);
  77.     acutRelRb(pRb);
  78.     AcDbObjectId entId;
  79.     pBlkTblRcd->appendAcDbEntity(entId, pBlkRef);
  80.     // 插入属性
  81.     AcDbEntity *pEnt;
  82.     acdbOpenObject(pEnt, entId, AcDb::kForWrite);
  83.     AcDbBlockTableRecord *pBlkDefRcd;
  84.     acdbOpenObject(pBlkDefRcd, blkDefId, AcDb::kForRead);        
  85.     AcDbBlockTableRecordIterator *pItr;
  86.     pBlkDefRcd->newIterator(pItr);
  87.     for (pItr->start(); !pItr->done(); pItr->step())
  88.     {
  89.         pItr->getEntity(pEnt, AcDb::kForRead);
  90.         AcDbAttributeDefinition *pAttDef = new AcDbAttributeDefinition;
  91.         pAttDef = AcDbAttributeDefinition::cast(pEnt);
  92.         AcDbAttribute *pAttr = new AcDbAttribute;
  93.         pAttr->setPropertiesFrom(pAttDef);           
  94.         pAttr->setHorizontalMode(AcDb::kTextLeft);   // 左对齐
  95.         pAttr->setVerticalMode(AcDb::kTextVertMid);  // 左中
  96.         pAttr->setPosition(textPt);       // 文本的位置点
  97.         pAttr->setAlignmentPoint(AlimPt); // 对齐点
  98.         pAttr->setWidthFactor(0.8);       // 宽度比例
  99.         pAttr->setHeight(textH);          // 高度
  100.         pAttr->setTag(strTag);            // 属性标签
  101.         pAttr->setTextString(height);     // 属性值
  102.         // 扩展数据
  103.         struct resbuf *pRb;
  104.         CString appName = "SOUTH";
  105.         CString typeName = "202111";
  106.         pRb = acutBuildList(AcDb::kDxfRegAppName, appName, AcDb::kDxfXdAsciiString, typeName, RTNONE);
  107.         pAttr->setXData(pRb);
  108.         acutRelRb(pRb);
  109.         // 追加属性
  110.         pBlkRef->appendAttribute(pAttr);
  111.         pAttr->close();
  112.     }
  113.     pBlkRef->setLayer("GCD");
  114.     delete pItr;
  115.     pBlkDefRcd->close();
  116.     pEnt->close();
  117.     pBlkRef->close();
  118.     pBlkTblRcd->close();
  119.     rc = feof(FP);
  120. }
  121. while (rc == 0);
  122. fclose(FP);  //关闭文件
  123. acedCommand(RTSTR, "ZOOM", RTSTR, "E", 0);
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|膜结构网

GMT+8, 2025-1-4 13:05 , Processed in 0.172570 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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