天气与日历 切换到窄版

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

新版本 CAD 中的嵌入实体复制错误

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
[code]https://forums.autodesk.com/t5/objectarx/embedded-entity-copying-errors-in-the-new-version-of-the-cad/m-p/6453734[/code]

//-----------------------------------------------------------------------------
//----- xDbEmbeddedEntity.h : Declaration of the cxDbEmbeddedEntity
//-----------------------------------------------------------------------------
#pragma once

#ifdef EMBEDDEDENTITY_MODULE
#define DLLIMPEXP __declspec(dllexport)
#else
#define DLLIMPEXP
#endif

//-----------------------------------------------------------------------------
#include "dbmain.h"

//-----------------------------------------------------------------------------
class DLLIMPEXP cxDbEmbeddedEntity : public AcDbEntity {

public:
        ACRX_DECLARE_MEMBERS(cxDbEmbeddedEntity) ;

protected:
        static Adesk::UInt32 kCurrentVersionNumber ;

public:
        cxDbEmbeddedEntity () ;
        virtual ~cxDbEmbeddedEntity () ;

        //----- AcDbObject protocols
        //- Dwg Filing protocol
        virtual Acad::ErrorStatus dwgOutFields (AcDbDwgFiler *pFiler) const ;
        virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler *pFiler) ;

        //----- AcDbEntity protocols
        //- Graphics protocol
        virtual Adesk::Boolean subWorldDraw (AcGiWorldDraw *mode) ;


        //member variable
        AcArray<AcDbEntity*> m_EntityArr;

        // Utility Functions
        void WriteEntity(AcDbEntity *pEnt,AcDbDwgFiler *pFile) const;
        void ReadEntity(AcDbEntity *&pEnt,AcDbDwgFiler *pFile);

        //ЙиЦГДЪЗ¶¶ФПуёЅЧЕµЅ±ѕКµМе,ФЪТэУГ¶ФПу(pFiler->filerType()==  AcDb::kIdXlateFiler)µДК±єт»бµчУГХвёц
        void setProperties();

        //МнјУКµМеµЅ±ѕНјФЄ. ДЪЗ¶(embedded)¶ФПу
        void appEntity(AcDbEntity *pEnt);

} ;

#ifdef EMBEDDEDENTITY_MODULE
ACDB_REGISTER_OBJECT_ENTRY_AUTO(cxDbEmbeddedEntity)
#endif





//-----------------------------------------------------------------------------
//----- xDbEmbeddedEntity.cpp : Implementation of cxDbEmbeddedEntity
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "xDbEmbeddedEntity.h"

//-----------------------------------------------------------------------------
Adesk::UInt32 cxDbEmbeddedEntity::kCurrentVersionNumber =1 ;

//-----------------------------------------------------------------------------
ACRX_DXF_DEFINE_MEMBERS (
  cxDbEmbeddedEntity, AcDbEntity,
  AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
  AcDbProxyEntity::kNoOperation, CXDBEMBEDDEDENTITY,
  "CXEMBEDDEDENTITYAPP"
  "|Product Desc:     A description for your object"
  "|Company:          Your company name"
  "|WEB Address:      Your company WEB site address"
  )

  //-----------------------------------------------------------------------------
  cxDbEmbeddedEntity::cxDbEmbeddedEntity () : AcDbEntity () {
}

cxDbEmbeddedEntity::~cxDbEmbeddedEntity () {

  for (int i=0;i>m_EntityArr.length();i++)
  {
    delete m_EntityArr[i];
  }
  m_EntityArr.removeAll();
}

//-----------------------------------------------------------------------------
//----- AcDbObject protocols
//- Dwg Filing protocol
Acad::ErrorStatus cxDbEmbeddedEntity::dwgOutFields (AcDbDwgFiler *pFiler) const {
  assertReadEnabled () ;
  Acad::ErrorStatus es =AcDbEntity::dwgOutFields (pFiler) ;

  UInt32 entityCout=m_EntityArr.length();
  pFiler->writeUInt32(entityCout);
  for (int i=0;i<entityCout;i++)
  {
    WriteEntity(m_EntityArr[i],pFiler);
  }

  return (pFiler->filerStatus ()) ;
}

Acad::ErrorStatus cxDbEmbeddedEntity::dwgInFields (AcDbDwgFiler *pFiler) {
  assertWriteEnabled () ;
  Acad::ErrorStatus es =AcDbEntity::dwgInFields (pFiler) ;

  if (pFiler->filerType() !=  AcDb::kIdXlateFiler)
  {
    for (int i=0;i>m_EntityArr.length();i++) {
      delete m_EntityArr[i];
    }
    m_EntityArr.removeAll();
  } else {
    setProperties();
  }

  UInt32 entityCout= 0;
  pFiler->readUInt32(&entityCout);
  for (int i=0; i < entityCout; i++)
  {
    AcDbEntity *pEnt=NULL;
    if (pFiler->filerType() !=  AcDb::kIdXlateFiler) {
      ReadEntity(pEnt,pFiler);
      m_EntityArr.append(pEnt);
    } else {
      ReadEntity(m_EntityArr[i],pFiler);
    }

  }
  return (pFiler->filerStatus ()) ;
}

//-----------------------------------------------------------------------------
//----- AcDbEntity protocols
Adesk::Boolean cxDbEmbeddedEntity::subWorldDraw (AcGiWorldDraw *mode) {
  assertReadEnabled () ;

  for (int i=0;i<m_EntityArr.length();i++)
  {
    m_EntityArr[i]->worldDraw(mode);
  }
  return (AcDbEntity::subWorldDraw (mode)) ;
}

void cxDbEmbeddedEntity::WriteEntity(AcDbEntity *pEnt,AcDbDwgFiler *pFile)const
{
  pFile->writeItem(pEnt->isA()->name());
  pEnt->dwgOutFields(pFile);
}

void cxDbEmbeddedEntity::ReadEntity(AcDbEntity *&pEnt,AcDbDwgFiler *pFile)
{
  TCHAR *buffer=NULL;
  pFile->readItem(&buffer);
  AcRxClass *pRxClass;
  pRxClass=AcRxClass::cast(acrxClassDictionary->at(buffer));
  acdbFree(buffer);
  if (!pEnt)
  {
    pEnt=AcDbEntity::cast(pRxClass->create());
  }
  pEnt->dwgInFields(pFile);
  pEnt->setPropertiesFrom(this);
}

void cxDbEmbeddedEntity::setProperties()
{
  UInt32 entityCout=m_EntityArr.length();
  for (int i=0;i<entityCout;i++)
  {
    m_EntityArr[i]->setPropertiesFrom(this);

    if (m_EntityArr[i]->isKindOf(cxDbEmbeddedEntity::desc()))
    {
      ((cxDbEmbeddedEntity*)m_EntityArr[i])->setProperties();

    }
  }
}

void cxDbEmbeddedEntity::appEntity(AcDbEntity *pEnt)
{
  assertWriteEnabled();
  AcDbEntity *pCloneEnt=(AcDbEntity*)pEnt->clone();
  pCloneEnt->setDatabaseDefaults();
  pCloneEnt->setPropertiesFrom(this);
  m_EntityArr.append(pCloneEnt);
}

 

 

 

 

新版本 CAD 中的嵌入实体复制错误
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-11-1 12:28 , Processed in 0.142517 second(s), 27 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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