天气与日历 切换到窄版

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

转换为3DSolid SetasBody功能 arx

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
[code]//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
Acad::ErrorStatus postToDatabase (/*[in]*/AcDbDatabase *pDb /*=NULL*/, AcDbEntity *pEnt, AcDbObjectId &idObj);

//-----------------------------------------------------------------------------
#define szRDS _RXST("")

//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CTest3dsolidApp : public AcRxArxApp {

public:
  CTest3dsolidApp () : AcRxArxApp () {}
  AcString AsdkHlrApi;

  virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
    AcRx::AppRetCode retCode = AcRxArxApp::On_kInitAppMsg (pkt) ;
    // Загружаем нужную версию HlrApi
    int ver = acdbHostApplicationServices()->releaseMajorVersion();  
    AsdkHlrApi.format(_T("AsdkHlrApi%d.dbx"),ver);
    acedArxLoad(AsdkHlrApi);
    return (retCode) ;
  }

  virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
    AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;
    acedArxUnload(AsdkHlrApi);
    return (retCode) ;
  }

  virtual void RegisterServerComponents () { }

  static void RivilisTestConv () {

    int nPoints = 8 ;
    int nTriangles = 12 ;
    int nIndices = 3 * nTriangles ;

    double p [] = {
      0, 0, 0,
      1, 0, 0,
      1, 1, 0,
      0, 1, 0,
      0, 0, 1,
      1, 0, 1,
      1, 1, 1,
      0, 1, 1
    } ;

    int i [] = {
      0, 1, 5,    0, 5, 4,
      1, 6, 5,    1, 2, 6,
      4, 5, 6,    4, 6, 7,
      7, 0, 4,    7, 3, 0,
      2, 0, 3,    2, 1, 0,
      7, 6, 3,    6, 2, 3
    } ;

    AcGeIntArray indices (nIndices) ;
    indices.setLogicalLength (nIndices) ;
    indices.setPhysicalLength (nIndices) ;
    memcpy (indices.asArrayPtr (), i, nIndices * sizeof (int)) ;

    AcGePoint3dArray gePts (nPoints) ;
    gePts.setLogicalLength (nPoints) ;
    gePts.setPhysicalLength (nPoints) ;
    memcpy (gePts.asArrayPtr(), p, nPoints * sizeof (AcGePoint3d)) ;

    void *acisBody = createBodyFromTriangles (gePts, indices) ;

    AcDbObjectId id ;
    // Получаем из треугольников AcDbBody, так как напрямую
    // AcDb3dSolid получить не удаётся.
    AcDbBody *pBody = new AcDbBody();
    Acad::ErrorStatus es = pBody->setASMBody(acisBody);
    // Преобразуем AcDbBody в поверхность AcDbSurface
    AcBrBrep *pBrep = new AcBrBrep();
    AcBr::ErrorStatus ebs = pBrep->set(*pBody);
    AcDbSurface *pSurf = new AcDbSurface() ;
    ebs = pBrep->get(pSurf);
    // Получаем из AcDbSurface AcDb3dSolid
    AcDb3dSolid *pSolid = new AcDb3dSolid();
    es = pSolid->createFrom(pSurf);
    // Добавляем в чертеж.
    es = postToDatabase (NULL, pSolid, id) ;
    delete pBrep;  delete pSurf;  delete pBody;
  }
} ;

//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CTest3dsolidApp)
ACED_ARXCOMMAND_ENTRY_AUTO(CTest3dsolidApp, Rivilis, TestConv, TestConv, ACRX_CMD_MODAL, NULL)

Acad::ErrorStatus postToDatabase (/*[in]*/AcDbDatabase *pDb /*=NULL*/, AcDbEntity *pEnt, AcDbObjectId &idObj) {
    assert ( pEnt != NULL ) ;
    if ( pDb == NULL )
      pDb =acdbHostApplicationServices ()->workingDatabase () ;
    Acad::ErrorStatus es ;
    AcDbBlockTable *pBlockTable ;
    if ( (es =pDb->getBlockTable (pBlockTable, AcDb::kForRead)) == Acad::eOk ) {
      AcDbBlockTableRecord *pSpaceRecord ;
      if ( (es =pBlockTable->getAt (ACDB_MODEL_SPACE, pSpaceRecord, AcDb::kForWrite)) == Acad::eOk ) {
        if ( (es =pSpaceRecord->appendAcDbEntity (idObj, pEnt)) == Acad::eOk )
          pEnt->close () ;
        pSpaceRecord->close () ;
      }
      pBlockTable->close () ;
    }
    return (es) ;
}


https://adn-cis.org/forum/index.php?topic=5192.msg17124#msg17124
[/code]

 

 

 

 

转换为3DSolid SetasBody功能 arx
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-11-1 15:21 , Processed in 0.160919 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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