自定义实体 arx

1.       

extern "C" AcRx::AppRetCode

acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)

{

switch (msg) {

    case AcRx::kInitAppMsg:

       acrxDynamicLinker->unlockApplication(pkt);

        // create and fill inAcRxClass objects for

        // the custom classes

        //

       CustomClass1::rxInit();

       CustomClass2::rxInit();

        CustomClass3::rxInit();

        // Add the new classesto the runtime class tree

        //

        acrxBuildClassHierarchy();

        break;

    case AcRx::kUnloadAppMsg:

        deleteAcRxClass(CustomClass1::desc());

       deleteAcRxClass(CustomClass2::desc());

        deleteAcRxClass(CustomClass3::desc());

    }

    return AcRx::kRetOK;

}

 

注意顺序基类实体先注册, 派生类实体后注册 卸载时相反

 

 

 

2.       

ACRX_DXF_DEFINE_MEMBERS(CLASS_NAME,PARENT_CLASS, DWG_VERSION, MAINTENANCE_VERSION, PROXY_FLAGS, DXF_NAME, APP)

CLASS_NAME

Input the name of the class being declared

PARENT_CLASS

Input the name of the ObjectARX tree-resident base class

DWG_VERSION

Input major version number (DWG version) in which the class was introduced

MAINTENANCE_VERSION

Input minor version number (maintenance release version) in which the class was introduced

PROXY_FLAGS

Input the Proxy flag bits for this class

DXF_NAME

Input DXF name (must be all uppercase)

APP

Input application name

 

ACRX_DXF_DEFINE_MEMBERS(TDbSunCutter, TDbEntity,AcDb::kDHL_CURRENT,

                             AcDb::kMReleaseCurrent,  1, TCH_SUN_CUTTER, "TCH_SUNLIGHT|缺乏解释器天正图形看不见, 请下载天正插件|网址: www.tangent.com.cn");

 

 

3.       

assertReadEnabled()

assertWriteEnabled();

带参数

 

如何存储一个点数组

Acad::ErrorStatusTDbDimension::dwgInFields(AcDbDwgFiler* pFiler)

{

         assertWriteEnabled();

         Acad::ErrorStatuses = AcDbEntity::dwgInFields(pFiler);

         if(es != Acad::eOk)

                   returnes;

 

         Adesk::UInt8nVer;

         pFiler->readItem(&nVer);

         if(nVer > g_nVersion)

         {

                   //Version is too new

                   returnAcad::eMakeMeProxy;

         }

 

         Adesk::Int16nCount = 0;

         pFiler->readInt16(&nCount);

         AcGePoint3dpt = AcGePoint3d::kOrigin;

         m_arDimPt.setLogicalLength(0);

         for(int i = 0; i < nCount; i++)

         {

                   pFiler->readItem(&pt);

                   m_arDimPt.append(pt);

         }

 

         returnpFiler->filerStatus();

}

 

 

4.       

Acad::ErrorStatusTDbDimension::dwgOutFields(AcDbDwgFiler* pFiler) const

{

         assertReadEnabled();

         Acad::ErrorStatuses = AcDbEntity::dwgOutFields(pFiler);

         if(es != Acad::eOk)

                   returnes;

 

         pFiler->writeItem(g_nVersion);

        

         intiCount = m_arDimPt.length();

         pFiler->writeInt16(Adesk::Int16(iCount));

         for(int i = 0; i < iCount; i++)

                   pFiler->writeItem(m_arDimPt[i]);

 

         returnpFiler->filerStatus();

}

 

 

必须重载的函数

virtual Adesk::Boolean worldDraw(AcGiWorldDraw* mode);

virtual Acad::ErrorStatus getGeomExtents(AcDbExtents&extents) const;

virtual Acad::ErrorStatus transformBy(constAcGeMatrix3d& xform);

virtual Acad::ErrorStatus getGripPoints(AcDbGripDataPtrArray&grips,const double curViewUnitSize,const int gripSize,const AcGeVector3d&curViewDir,const int bitflags) const;

virtual Acad::ErrorStatus moveGripPointsAt(constAcDbVoidPtrArray& gripAppData,const AcGeVector3d& offset,const intbitflags);

 

 

 

1.      dwgOut()函数由以下命令调用

save

saveas

wblock

insert

copy

purge

当一个对象被从显示页面中调出时

当一个对象被修改时

2.      dwgIn()

open

undo

insert

copy

wblock

3.      dxfOut()

wblock

save

saveas

acdbEntGet()

4.      dxfIn()

open

insert

acdbEntMod(),acdbEntMake()

 

 

作业

1.      从AcDbCurve派生一个实体类TDbDimension

2.      重载如下函数

virtual Acad::ErrorStatus         dwgInFields(AcDbDwgFiler* pFiler);

// 写出dwg

virtual Acad::ErrorStatus         dwgOutFields(AcDbDwgFiler* pFiler)const;

virtualAdesk::Boolean               worldDraw(AcGiWorldDraw*mode);

virtualAcad::ErrorStatus explode(AcDbVoidPtrArray&entitySet) const;

 

 

  1. AcGePoint3dArray                        m_arDimPt;                        // 记录标注点
  2. 选择图中TDbDimension实体 然后将其炸散显示到模型空间并删除原来实体

5.      

 

 

 

 

 

 

 

 

 

.h

 

 

class TDbDimension : public AcDbCurve

{

public:

         ACRX_DECLARE_MEMBERS(TDbDimension);

        

         TDbDimension();

         virtual~TDbDimension();

        

public:

         //读入dwg

         virtualAcad::ErrorStatus         dwgInFields(AcDbDwgFiler*pFiler);

         //写出dwg

         virtualAcad::ErrorStatus         dwgOutFields(AcDbDwgFiler*pFiler) const;

         //绘制

virtualAdesk::Boolean              worldDraw(AcGiWorldDraw*mode);

 

 

 

private:

         //版本号

const staticAdesk::UInt8        g_nVersion;

        

private:

void *operatornew[](unsigned nSize) { return 0; }

void operatordelete[](void *p) {};

void *operatornew[](unsigned nSize, const char *file, int line) { return 0; }

}

 

 

 

.cpp

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值