- 积分
- 26737
- 明经币
- 个
- 注册时间
- 2007-4-24
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2024-7-15 15:14:51
|
显示全部楼层
本帖最后由 gzxl 于 2024-7-15 15:36 编辑
没点改进,全都是搬来搬去。那是 CASS几的高程点?CASS11 的高程点分散看看。
虽然是小问题。贴一个 arx,这与 CASS11 的子图元就对应了。
- /// @brief 创建Cass高程点
- /// @param[In] ptInsert : 输入插入点
- /// @param[In] strText : 输入高程值
- /// @param[In] layerName : 输入图层名(缺省为"GCD")
- /// @param[In] colorIndex : 图层颜色(缺省为红色)
- /// @param[In] dUSERR1 : 输入比例尺(缺省为500)
- /// @return 成功则返回高程点的ID
- AcDbObjectId CCassUtil::AddGeneralGcd(const AcGePoint3d& ptInsert,
- const TCHAR* strText,
- const TCHAR* layerName /*= _T("GCD") */,
- int colorIndex /*= 1 */,
- double dUSERR1 /*= 500 */)
- {
- // 获得指向块表的指针
- AcDbBlockTable* pBlockTable = NULL;
- acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForWrite);
- // 获得指向特定的块表记录(模型空间)的指针
- AcDbBlockTableRecord* pBlkTblRcd = NULL;
- AcDbObjectId entId = AcDbObjectId::kNull;
- AcDbObjectId blkDefId = AcDbObjectId::kNull;
- Acad::ErrorStatus es = pBlockTable->getAt(_T("gc200"), blkDefId);
- if (!CStringUtil::IsNumOrDecimal(strText))
- return AcDbObjectId::kNull;
- AcGePoint3d pt(ptInsert.x, ptInsert.y, CConvertUtil::ToDouble(strText));
- if (es != Acad::eOk) // GC200图块定义不存在
- {
- // 创建新的块表记录
- pBlkTblRcd = new AcDbBlockTableRecord();
- pBlkTblRcd->setName(_T("gc200"));
- // 将块表记录添加到块表中
- AcDbObjectId blkDefId;
- pBlockTable->add(blkDefId, pBlkTblRcd);
- pBlockTable->close();
- AcDbObjectIdArray ObjIds;
- AcGeVector3d vecNormal(0.0, 0.0, 1.0);
- AcDbHatch* pHatch = new AcDbHatch();
- pHatch->setNormal(vecNormal);
- pHatch->setElevation(0.0);
- // 将Hatch模式设置为SOLID预定义类型
- pHatch->setPattern(AcDbHatch::kPreDefined, _T("SOLID"));
- // 设定关联
- pHatch->setAssociative(Adesk::kTrue);
- AcDbObjectId circleId, hatchId;
- // 圆
- AcDbCircle* pCircle = new AcDbCircle(AcGePoint3d::kOrigin, vecNormal, dUSERR1 * 0.00025);
- pBlkTblRcd->appendAcDbEntity(circleId, pCircle);
- pCircle->close();
- ObjIds.append(circleId);
- // 填充
- pHatch->appendLoop(AcDbHatch::kDefault, ObjIds);
- pHatch->evaluateHatch();
- ObjIds.setLogicalLength(0);
- pHatch->getAssocObjIds(ObjIds);
- pBlkTblRcd->appendAcDbEntity(hatchId, pHatch);
- pHatch->close();
- pBlkTblRcd->close();
- }
- pBlockTable->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForWrite);
- es = pBlockTable->getAt(_T("gc200"), blkDefId);
- if (es != Acad::eOk)
- return AcDbObjectId::kNull;
- // 创建新图层并设置当前层
- CLayerUtil::Add(layerName, colorIndex);
- CLayerUtil::SetCurLayer(layerName);
- // 定义块参数参数
- AcDbBlockReference* pBlockRef = new AcDbBlockReference(pt, blkDefId);
- pBlockRef->setLayer(layerName);
- AcGeScale3d Scale3d(dUSERR1 * 0.001, dUSERR1 * 0.001, dUSERR1 * 0.001);
- pBlockRef->setScaleFactors(Scale3d);
- AcGePoint3d positionPt, alignmentPt;
- positionPt = CGePointUtil::PolarPoint(pt, 0.0, dUSERR1 * 0.0012);
- alignmentPt = CGePointUtil::PolarPoint(positionPt, CMathUtil::PI() * 1.5, dUSERR1 * 0.001);
- // 字体
- CString simhei = _T("等线体");
- AcDbObjectId simheiId = CTextStyleUtil::GetAt(simhei);
- if (simheiId.isNull())
- CTextStyleUtil::Add(simhei, _T("simhei.ttf"), _T("常规"));
- // 设置当前字体
- CTextStyleUtil::SetCurTextStyle(_T("等线体"));
- // 块属性定义参数
- AcDbAttribute* pAttribute = new AcDbAttribute(pt, strText, _T("height"), simheiId);
- pAttribute->setHeight(dUSERR1 * 0.002);
- pAttribute->setWidthFactor(0.8);
- pBlockRef->appendAttribute(pAttribute);
- pAttribute->setHorizontalMode(AcDb::kTextLeft); // 左对齐
- pAttribute->setVerticalMode(AcDb::kTextVertMid); // 左中
- pAttribute->setPosition(alignmentPt); // 文本的位置点
- pAttribute->setAlignmentPoint(positionPt); // 对齐点
- pAttribute->setLayer(layerName);
- pAttribute->setColorIndex(colorIndex);
- // 创建扩展数据
- struct resbuf* pRb;
- pRb = acutBuildList(AcDb::kDxfRegAppName, _T("SOUTH"), AcDb::kDxfXdAsciiString, _T("202101"), RTNONE);
- acdbRegApp(_T("SOUTH"));
- pBlockRef->setXData(pRb);
- acutRelRb(pRb);
- pBlkTblRcd->appendAcDbEntity(entId, pBlockRef);
- // 关闭对象
- pAttribute->close();
- pBlockRef->close();
- pBlockTable->close();
- pBlkTblRcd->close();
- // 返回
- return entId;
- }
复制代码
|
|