明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1173|回复: 0

请教各位大虾指教一个非常刺手de问题

[复制链接]
发表于 2003-6-5 23:19 | 显示全部楼层 |阅读模式
thisline.set(leftPnt3d,rightPnt3d);
   
        AcGePoint3dArray breakPts;
        AcDbBlockTable *pBlockTable1;
        //下面这段程序是遍历块表,找到与this AcDbmyEntity相交的others AcDbmyEntity实体
        acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable1, AcDb::kForRead);
        AcDbBlockTableRecord *pBlockTableRecord1;
        pBlockTable1->getAt(ACDB_MODEL_SPACE, pBlockTableRecord1, AcDb::kForRead);
        pBlockTable1->close();
        AcDbBlockTableRecordIterator *pBlockIterator;
        pBlockTableRecord1->newIterator(pBlockIterator);
        AcGePoint3d rightPt,leftPt;
        double qiangHeight,qiangwidth;
    AcDbEntity *pEntity;
    for (; !pBlockIterator->done();pBlockIterator->step())
    {
        pBlockIterator->getEntity(pEntity, AcDb::kForRead);
        if(pEntity->isKindOf(AcDbmyEntity::desc()))
        {
          AcDbmyEntity::cast(pEntity)->getRpoint(rightPt);
          AcDbmyEntity::cast(pEntity)->getLpoint(leftPt);
          AcDbmyEntity::cast(pEntity)->getHeight(qiangHeight);
          AcDbmyEntity::cast(pEntity)->getWidth(qiangwidth);
          otherline.set(rightPt,leftPt);
          Adesk::Boolean rc=thisline.intersectWith(otherline, ptmy);
          if(rc==Adesk::kTrue)
          {
           breakPts.append(ptmy);   
          //下面为删除others AcDbmyEntity实体
          AcDbmyEntity::cast(pEntity)->upgradeOpen();
          AcDbmyEntity::cast(pEntity)->erase(true);
          AcDbmyEntity::cast(pEntity)->close();

//问题在下面,如果不加下面1-15句,运行不会报错误,不知为什么出错,也不知道这样
//出实现下面的功能行不行,是否有其他的方法,请各位大虾指教
          //下面为用ptmy点重新生成两个AcDbmyEntity实体替换已删除others AcDbmyEntity实体
          //相当于把others AcDbmyEntity实体以ptmy点分为两段
   1      AcDbmyEntity* pTriangle0 = new AcDbmyEntity();
          pTriangle0->create(leftPt, ptmy,qiangwidth,qiangHeight);
          AcDbEquiTriangle* pTriangle1 = new AcDbmyEntity();
          Triangle1->create(ptmy,rightPt,qiangwidth,qiangHeight);         
          AcDbBlockTable *pBlockTable2;
          acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable2, AcDb::kForRead);
          AcDbBlockTableRecord *pBlockTableRecord2;
          pBlockTable2->getAt(ACDB_MODEL_SPACE, pBlockTableRecord2, AcDb::kForWrite);
          pBlockTable2->close();
          AcDbObjectId objectId1,objectId2;
          pBlockTableRecord2->appendAcDbEntity(objectId1, (AcDbmyEntity *)pTriangle0);
          pBlockTableRecord1->appendAcDbEntity(objectId2, (AcDbmyEntity *)pTriangle1);
          pBlockTableRecord2->close();
          pTriangle0->close();
   15          pTriangle1->close();
          }
          else
          {
          AcDbmyEntity::cast(pEntity)->close();
          }
        }
     }
    delete pBlockIterator;
    pBlockTableRecord1->close();
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-17 19:02 , Processed in 0.312649 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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