- 积分
- 26737
- 明经币
- 个
- 注册时间
- 2007-4-24
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2014-9-30 12:11:55
|
显示全部楼层
是ARX的要不要?[em0]
- static void xlCassGCDExplode_TEST(void)
- {
- ads_name ent, ss, ssName;
- AcDbObjectId entId;
- AcDbEntity *pEnt = NULL;
- struct resbuf *rb;
- rb = acutBuildList(RTDXF0, TEXT("INSERT"), 2, TEXT("GC200"), RTNONE);
- int rt = acedSSGet(TEXT("X"), NULL, NULL, rb, ss);
- // int rt = acedSSGet(NULL, NULL, NULL, rb, ss);
- if (rt != RTNORM)
- {
- acutRelRb(rb);
- return;
- }
- acutRelRb(rb);
- // 新建图层
- CString newLayerName = TEXT("newGCD");
- AcDbObjectId layerId = GetLayerId(newLayerName);
- if (!layerId.isValid())
- {
- Add(newLayerName, 4);
- }
- CString strHeight;
- long len;
- acedSSLength(ss, &len);
- for (int i = 0; i < len; i++)
- {
- acedSSName(ss, i, ssName);
- acdbGetObjectId(entId, ssName);
- acdbOpenObject(pEnt, entId, AcDb::kForWrite);
- if (pEnt->isKindOf(AcDbBlockReference::desc()))
- {
- AcDbBlockReference *pBlk = AcDbBlockReference::cast(pEnt);
- AcGePoint3d pt = pBlk->position();
- int color = pBlk->colorIndex();
- CString layerName = pBlk->layer();
- AcGeScale3d scale = pBlk->scaleFactors();
- AcDbObjectIterator *pAttrIter = pBlk->attributeIterator();
- AcDbAttribute *pAttr;
- AcDbObjectId attrObjId;
- for(int k = 0; !pAttrIter->done(); pAttrIter->step())
- {
- attrObjId = pAttrIter->objectId();
- acdbOpenObject(pAttr,attrObjId, AcDb::kForWrite);
- CString pTagStr = pAttr->tag();
- // acutDelString(pTagStr);
- CString testStr = pAttr->textString(); // 获取文字字符串
- AcGePoint3d alignmentPt = pAttr->alignmentPoint(); // 获取对象的对齐点
- AcGePoint3d insertionPt = pAttr->position(); // 获取对象的插入点
- AcDb::TextHorzMode pHorizontalStr = pAttr->horizontalMode(); // 获取对象水平模式
- AcDb::TextVertMode pVerticalStr = pAttr->verticalMode(); // 获取对象垂直对齐模式
- double height = pAttr->height(); // 获取对象的高度
- double width = pAttr->widthFactor(); // 取得对象的宽度比例
- double rotAng = pAttr->rotation(); // 获取对象的旋转角度
- AcDbObjectId style = pAttr->textStyle(); // 获取对象的样式名称
- AcDbVoidPtrArray pExps;
- if (pEnt->explode(pExps) == Acad::eOk)
- {
- AcDbEntity *pXEnt;
- for (int j = 0; j < pExps.length(); j++)
- {
- pXEnt = (AcDbEntity*)pExps.at(j);
- pXEnt->close();
- }
- }
- // 添加文字
- AcDbText *pText = new AcDbText(insertionPt, testStr, style, height, rotAng);
- pText->setLayer(layerName);
- pText->setHorizontalMode(pHorizontalStr);
- pText->setVerticalMode(pVerticalStr);
- pText->setPosition(insertionPt);
- pText->setAlignmentPoint(alignmentPt);
- pText->setWidthFactor(width);
- pText->setLayer(newLayerName);
- // pText->setColorIndex(4);
- CString appName = TEXT("SOUTH");
- struct resbuf *pRb;
- if (_tcscmp(pTagStr, TEXT("height")) == 0)
- {
- CString typeName = TEXT("202101");
- pRb = acutBuildList(AcDb::kDxfRegAppName, appName, AcDb::kDxfXdAsciiString, typeName, RTNONE);
- pText->setXData(pRb);
- acutRelRb(pRb);
- }
- else if (_tcscmp(pTagStr, TEXT("integer")) == 0)
- {
- CString typeName = TEXT("186411");
- pRb = acutBuildList(AcDb::kDxfRegAppName, appName, AcDb::kDxfXdAsciiString, typeName, RTNONE);
- pText->setXData(pRb);
- acutRelRb(pRb);
- }
- else if (_tcscmp(pTagStr, TEXT("decimal")) == 0)
- {
- CString typeName = TEXT("186412");
- pRb = acutBuildList(AcDb::kDxfRegAppName, appName, AcDb::kDxfXdAsciiString, typeName, RTNONE);
- pText->setXData(pRb);
- acutRelRb(pRb);
- }
- else
- {
- acutRelRb(pRb);
- acutPrintf(TEXT("\n无扩展数据"));
- }
- PostToModelSpace(pText);
- // 创建块参照对象
- CString blkName = TEXT("GC200");
- AcDbObjectId blkDefId = GetBlkDefId(blkName);
- AcDbBlockReference *pBlkRef = new AcDbBlockReference(pt, blkDefId);
- pBlkRef->setScaleFactors(scale);
- pBlkRef->setRotation(rotAng);
- pBlkRef->setLayer(newLayerName);
- // pBlkRef->setColorIndex(4);
- // 扩展数据
- if (_tcscmp(pTagStr, TEXT("height")) == 0)
- {
- struct resbuf *pRb;
- CString typeName = TEXT("202101");
- pRb = acutBuildList(AcDb::kDxfRegAppName, appName, AcDb::kDxfXdAsciiString, typeName, RTNONE);
- pBlkRef->setXData(pRb);
- acutRelRb(pRb);
- }
- else
- {
- struct resbuf *pRb;
- CString typeName = TEXT("186400");
- pRb = acutBuildList(AcDb::kDxfRegAppName, appName, AcDb::kDxfXdAsciiString, typeName, RTNONE);
- pBlkRef->setXData(pRb);
- acutRelRb(pRb);
- }
- PostToModelSpace(pBlkRef);
- // pEnt->erase();
- pAttr->close();
- k++;
- }
- delete pAttrIter;
- pBlk->close();
- }
- pEnt->close();
- }
- acedSSFree(ss);
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|