天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 5|回复: 0

图块] AcDbBlockReference::explode 失败

[复制链接]
  • TA的每日心情
    开心
    昨天 15:23
  • 签到天数: 69 天

    [LV.6]常住居民II

    410

    主题

    167

    回帖

    2704

    积分

    管理员

    积分
    2704
    发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
    cDbBlockReference::explode fails

    问题:

    Why does AcDbBlockReference::explode produce incorrect results if there are
    AcDbText or AcDbAttribute definition entities in the block that is exploded?

    解答:

    This isa known problem that is desribed in DevNote #TS36113.
    AcDbBlockReference::explode internally calls AcDbText::getTransformedCopy that
    produces incorrect results. The code below uses the code in DevNote #TS36113 to
    explode an AcDbBlockReference correctly.

    普通浏览复制代码
    Acad::ErrorStatus safeExplode(const AcDbBlockReference* pRef,AcDbVoidPtrArray&entitySet)
    {  
    AcDbBlockTableRecord* pBTR;
    Acad::ErrorStatus es;  
    if ((es = acdbOpenAcDbObject((AcDbObject*&)pBTR, pRef->blockTableRecord(), AcDb::kForRead)) == Acad::eOk)
    {   
      AcDbBlockTableRecordIterator* pIterator;
      if (pBTR->newIterator(pIterator) == Acad::eOk)
      {  
       AcGeMatrix3d xform = pRef->blockTransform();   
       AcGePoint3d pt3dBlkOrigin = pBTR->origin();  
       if (pt3dBlkOrigin != AcGePoint3d::kOrigin)
       {     
        AcGeVector3d xformOrigin = xform.translation();
        AcGeVector3d vectorOrigin(pt3dBlkOrigin.x,pt3dBlkOrigin.y,0.0);  
        vectorOrigin.transformBy(xform);
        xformOrigin -= vectorOrigin;   
        xform.setTranslation(xformOrigin);   
       }   
       pIterator->start();   
       while (!pIterator->done())
       {     
        AcDbEntity* pEntity;
        if (pIterator->getEntity(pEntity, AcDb::kForRead) == Acad::eOk)
        {
          // If pEntity does not implement getTransformedCopy()  
          // or explode() methods, we should simply ignore
          // that entity and continue to step into next entity
          // instead of exit prematurely. Most operations such
          // as BHATCH depends on complete iteration through  
          // the entire block entities.      
          AcDbEntity* pNewEntity;
          AcDbText* pText =NULL;   
          if (pText=AcDbText::cast(pEntity))  
           es = AdskUtil::safeGetTransformedCopy(pText,xform, pNewEntity);      
          else
          es = pEntity->getTransformedCopy(xform, pNewEntity);
          if (es==Acad::eOk)
          {
          entitySet.append(pNewEntity);
          }
          else if (Acad::eExplodeBeforeTransform == es)
          {
          AcDbVoidPtrArray explSet;  
          if (Acad::eOk == pEntity->explode(explSet))
          {
           for (int i = 0; i < explSet.length(); i++)
           {         
            AcDbEntity* pObj = (AcDbEntity*)explSet<i>;
            if (Acad::eOk == pObj->getTransformedCopy( xform, pNewEntity))
            {     
             entitySet.append(pNewEntity);   
            }        
            delete pObj;     
           }  
          }  
         }
         else if (Acad::eCopyFailed == es)
         {            
          AcDbVoidPtrArray explSet;   
          if (Acad::eOk == pEntity->explode(explSet))
          {            
           for (int i = 0; i < explSet.length(); i++)     
           {           
            AcDbEntity* pObj = (AcDbEntity*)explSet<i>;
            if (Acad::eOk == pObj->transformBy(xform))
            {         
             entitySet.append(pObj);
            }         
           }   
          }     
         }     
         pEntity->close();
        }  
        pIterator->step();
       }   
       delete pIterator;
      }  
      pBTR->close();
    }
    return es;
    }

     

     

     

     

    图块] AcDbBlockReference::explode 失败
    中国膜结构网打造全中国最好的膜结构综合平台 ,统一协调膜结构设计,膜结构施工,膜材采购,膜材定制,膜结构预算全方位服务。 中国空间膜结构协会合作单位。
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|

    GMT+8, 2024-7-1 05:58 , Processed in 0.056804 second(s), 22 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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