找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 4331|回复: 13

[弹指神通]:实现自定义实体的方法

[复制链接]
发表于 2003-11-17 11:23:10 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
要实现自定义实体,最好由AcDbEntity类派生,要定义实体的独有特性,就要
重新实现AcDbEntity类的虚拟子函数SaveAs, dxfOutFields ,dxfInFields ,
worldDraw, viewportDraw等函数, 要实现实体的拉伸,就要重新实现类的虚拟子函数
getStretchPoints,实现实体的捕捉,要重新实现类的虚拟子函数getOsnapPoints().等等。
附AcDbEntity类的说明如下:
AcDbEntity类



具有一个图形表示的所有数据库对象的基类。



继承自

AcDbObject



包含文件

dbmain.h



参见

AcRxObject



成员



AcDbEntity建构器和析构器

AcDbEntity::~AcDbEntity 函数

inline virtual

~AcDbEntity();

析构器。



AcDbEntity::AcDbEntity 函数

AcDbEntity();

默认建构器。此建构器被保护以强制将此类作为基类使用。此建构器初始化color为257,linetype和layer的objectIds为AcDbObjectId::kNull,且实体为可见的。

如果在实体增加至数据库中时,color、layer和linetype没有被设置,则实体使用数据库默认的color、LayerTableRecord对象ID和LinetypeTableRecord对象ID。




AcDbEntity编辑函数

AcDbEntity::explode 函数

virtual Acad::ErrorStatus

explode(

AcDbVoidPtrArray& entitySet) const;

entitySet
输入包含新实体指针的数组。这个数组可能已包含来自其他explode()方法的指针。输出分解此实体得到的所有实体,增加至数据库。


函数用途

此函数主要用于被AutoCAD调用实现包含此实体的一个分解操作的部分。然而,此函数可被ObjectARX应用程序使用以取得非数据库驻留的实体对象的指针的数组,这些实体对作为它的分解后的部分。

当调用此函数时,entitySet数组不需要为空。此函数将它创建的作为分解结果的实体的指针增加至这个数组中。

如果此函数成功将返回Acad::eOk。其他的返回值可能根据执行的方式而定。

在派生类中的执行

此函数应动态地创建(使用C++的new操作符)适当的作为分解结果取代原实体的实体对象。这些实体的指针则增加至entitySet数组中。一旦这些指针被增加,函数将返回一个Acad::eOk的状态。

注意:此函数不能将新实体增加至数据库中,也不能删除实体的部分。这些步骤将由AutoCAD(或调用此函数的其他应用程序考虑。

这也表示在一个应用程序调用一个对象的分解方法时,调用的应用程序要负责处理结果实体(即,增加它们至数据库或在不需要时删除它们)和删除原始实体(如果合适)。

默认的执行

立即返回Adesk::eNotApplicable。

自定义实体

当使用一个自定义实体时,必须定义一个分解方法使AutoCAD命令BHATCH和EXPLODE工作。分解方法应打散实体至更简单的实体。如果这些实体不是本地实体,则这个方法将返回eExplodeAgain,这将导致BHATCH在返回的实体上递归地调用分解方法,直至实体被分为本地实体。



AcDbEntity::moveGripPointsAt 函数

virtual Acad::ErrorStatus

moveGripPointsAt(

const AcDbIntArray& indices,

const AcGeVector3d& offset);

indices
输入包含索引值(对应于getGripPoints()方法报告的夹点)的一个数组,这些索引值表示当前为“热点”的夹点

offset
输入表示夹点被变换的方向和大小的一个矢量(WCS坐标中)


函数用途

此函数在实体的夹点编辑中被AutoCAD调用。然而,ObjectARX应用程序也可能调用此函数。

在调用此函数之间应先调用实体的getGripPoints()方法,以取得有效的夹点和它们进入的顺序(用于确定在indices数组中传递的索引值)。

偏移矢量表示应用至indices指定的夹点的变换的方向和大小。

最终,此函数将以适当的方法修改实体,从而使indices中的索引值标识的夹点以offset矢量表示方向和大小移动。

如果此函数成功将返回Acad::eOk。其他的返回值根据执行的方式而定。

在派生类中的执行

此函数必须修改实体,从而使indices数组标识的夹点变换至offset矢量(WCS坐标中)表示的方向和大小。这对实体其余部分的影响将根据实体而定,但此函数的其他影响也必须被考虑,因为这个函数将执行夹点编辑导致的所有实体修改。

如果此函数在一个派生类中执行,则getGripPoints()方法也必须被执行,因为indices数组中的索引值表示夹点的基于0的索引,这些索引被增加至传递给getGripPoints()方法的数组中。因此indices数组中的0值对应getGripPoints()方法增加至传递给它的数组的第一点,indices数组中的1值对应getGripPoints()方法增加的第二点,依此类推。因此,例如,如果用户“夹住”getGripPoints()方法增加的第一点和第三点,则indices数组将有两个元素。第一个为0,第二个为2。

因为此函数依赖于getGripPoints()方法增加的点,所有此函数知道getGripPoints()方法报告的点和报告的顺序(即,它们增加至传递给getGripPoints()方法的数组的顺序)。

如果执行成功则返回Acad::eOk。错误条件下的返回值根据执行器而定。

默认执行

使用将整个实体变换offset的一个变换矩阵调用实体的AcDbEntity::transformBy()方法。返回transformBy()方法返回的状态值。



AcDbEntity::moveStretchPointsAt 函数

virtual Acad::ErrorStatus

moveStretchPointsAt(

const AcDbIntArray& indices,

const AcGeVector3d& offset);

indices
输入包含索引值(对应于getStretchPoints()方法报告的拉伸点)的一个数组,这些索引值表示要被变换的拉伸点

offset
输入表示拉伸点被变换的方向和大小的一个矢量(WCS坐标中)


函数用途

此函数在有选中实体的拉伸命令执行时被AutoCAD调用。然而,ObjectARX应用程序也可能调用此函数。

在调用此函数之间应先调用实体的getStretchPoints()方法,以取得有效的拉伸点和它们进入的顺序(用于确定在indices数组中传递的索引值)。

偏移矢量表示应用至indices指定的拉伸点的变换的方向和大小。

最终,此函数将以适当的方法修改实体,从而使indices中的索引值标识的拉伸点以offset矢量表示方向和大小移动。

如果此函数成功将返回Acad::eOk。其他的返回值根据执行的方式而定。

在派生类中的执行

此函数必须修改实体,从而使indices数组标识的拉伸点变换至offset矢量(WCS坐标中)表示的方向和大小。这对实体其余部分的影响将根据实体而定,但此函数的其他影响也必须被考虑,因为这个函数将执行拉伸点操作导致的所有实体修改。

如果此函数在一个派生类中执行,则getStretchPoints()方法也必须被执行,因为indices数组中的索引值表示夹点的基于0的索引,这些索引被增加至传递给getStretchPoints()方法的数组中。因此indices数组中的0值对应getStretchPoints()方法增加至传递给它的数组的第一点,indices数组中的1值对应getStretchPoints()方法增加的第二点,依此类推。因此,例如,如果getGripPoints()方法增加的第一点和第三点被拉伸操作“拉伸”,则indices数组将有两个元素。第一个为0,第二个为2。

因为此函数依赖于getStretchPoints()方法增加的点,所有此函数知道getStretchPoints()方法报告的点和报告的顺序(即,它们增加至传递给getStretchPoints()方法的数组的顺序)。

如果执行成功则返回Acad::eOk。错误条件下的返回值根据执行器而定。

默认执行

使用将整个实体变换offset的一个变换矩阵调用实体的AcDbEntity::transformBy()方法。返回transformBy()方法返回的状态值。



AcDbEntity::setColor 函数

virtual Acad::ErrorStatus

setColor(

const AcCmColor& color,

Adesk::Boolean doSubents = true);

color
输入包含实体将被设置的颜色的AutoCAD颜色索引的AcCmColor对象

doSubents
输入布尔值,表示是否将变化应用至实体可能拥有的所有子实体上


函数用途

此方法设置实体的颜色为包含在color中的索引。如果实体拥有子实体且doSubents == Adesk::kTrue,则颜色变化也将应用至子实体上。

注意:kTrue有效的内建的实体只有:AcDb2dPolyline, AcDb3dPolyline, AcDbPolyFaceMesh,和AcDbPolygonMesh。

注意:此方法提供方法允许未来的AutoCAD版本扩允当前支持的256种颜色。setColorIndex()方法提供了此函数当前具有的相同的功能,但更易使用且更有效,因为它直接使用AutoCAD颜色索引。

如果成功返回Acad::eOk。如果不成功,将产生一个普通的AutoCAD错误,因为此函数在AutoCAD内部发生错误时一定失效。

在派生类中的执行

如果此函数被重载且希望设置实体的颜色,则必须传递color和doSubents参数调用AcDbEntity::setColorIndex()或传递从color取得的AutoCAD颜色索引和doSubents值调用AcDbEntity::setColor()。

此函数也可以直接处理任何子实体并将Adesk::kFalse的doSubents值传递给AcDbEntity::setColor()或AcDbEntity::setColorIndex()。

如果颜色设置操作成功,则此函数返回Acad::eOk。错误的返回值根据执行器而定。



AcDbEntity::setColorIndex 函数

virtual Acad::ErrorStatus

setColorIndex(

Adesk::UInt16 color,

Adesk::Boolean doSubents = true);

color
输入包含实体将被设置的颜色的AutoCAD颜色索引

doSubents
输入布尔值,表示是否将变化应用至实体可能拥有的所有子实体上


函数用途

此方法设置实体的颜色为包含在color中的索引。如果实体拥有子实体且doSubents == Adesk::kTrue,则颜色变化也将应用至子实体上。

注意:kTrue有效的内建的实体只有:AcDb2dPolyline, AcDb3dPolyline, AcDbPolyFaceMesh,和AcDbPolygonMesh。

颜色值必须在0至256之间。0和256为特殊值。

0表示实体使用显示它的块参照的颜色。如果实体不通过一个块参照显示(例如,它直接被模型空间的块表参照拥有)且它的颜色为0,则它将以颜色7显示。

256表示实体使用它参照的层表记录中指定的颜色。

如果成功返回Acad::eOk。如果颜色值超出许可范围则返回Acad::eInvalidIndex。

在派生类中的执行

如果此函数被重载且希望设置实体的颜色,则必须传递color和doSubents参数调用AcDbEntity::setColorIndex()或传递从color取得的AutoCAD颜色索引和doSubents值调用AcDbEntity::setColor()。

此函数也可以直接处理任何子实体并将Adesk::kFalse的doSubents值传递给AcDbEntity::setColor()或AcDbEntity::setColorIndex()。

如果颜色设置操作成功,则此函数返回Acad::eOk。错误的返回值根据执行器而定。



AcDbEntity::setDatabaseDefaults 函数

void

setDatabaseDefaults(

AcDbDatabase* pDb);

pDb
输入数据库,其默认值将用于设置实体的值


此函数设置实体的以下属性:

·   颜色

·   层

·   线型

·   线型比例

·   可见性

·   绘图样式名

·   线宽

为pDb表示的数据库的默认值。如果pDb == NULL,则使用AutoCAD编辑器中当前的数据库。


--------------------------------------------------------------------------------

void

setDatabaseDefaults();

此函数设置实体的以下属性:

·   颜色

·   层

·   线型

·   线型比例

·   可见性

·   绘图样式名

·   线宽

为实体当前驻留的数据库的默认值,或者,如果实体不是一个数据库的部分,则使用AutoCAD编辑器中的当前数据库。



AcDbEntity::setLayer 函数

virtual Acad::ErrorStatus

setLayer(

AcDbObjectId newVal,

Adesk::Boolean doSubents = true);

newVal
输入要被实体参考的Input objectId of the AcDbLayerTableRecord to be referenced by the entity

doSubents
Input Boolean indicating whether to propagate the change to any subentities the entity may own


This method sets the entity to reference the AcDbLayerTableRecord that has the object ID newVal. If the entity owns subentities and doSubents == Adesk::kTrue, then the layer change will be applied to the subentities as well.

Note The only built-in entities for which kTrue has an effect are: AcDb2dPolyline, AcDb3dPolyline, AcDbPolyFaceMesh, and AcDbPolygonMesh.

If the 函数 is successful, then Acad::eOk is returned.

If the object with object ID newVal is not an AcDbLayerTableRecord, then Acad::eWrongObjectType will be returned.

An attempt is made to open (for read) the object identified by newVal in order to determine if it is indeed an AcDbLayerTableRecord. If the open attempt fails, then the error status returned by the failed open attempt will be returned by this 函数 (see the acdbOpenObject() method documentation for possible return values).

函数 implementation in derived classes

If this 函数 is overridden and wishes to set the layer of the entity, then it must call AcDbEntity::setLayer() passing on the layer and doSubents arguments or call the other AcDbEntity::setLayer() passing in the doSubents value and a string which is the layer's name.

It is also possible for this 函数's implementation to deal directly with any subentities and pass a doSubents value of Adesk::kFalse to AcDbEntity::setLayer()

If this 函数 is successful, it should return Acad::eOk. Any other error return values are up to the implementor, but if it calls either of the AcDbEntity::setLayer() methods and that call returns an error, then it's recommended that the ErrorStatus value returned be returned by this 函数 as well.


--------------------------------------------------------------------------------

virtual Acad::ErrorStatus

setLayer(

const char* newVal,

Adesk::Boolean doSubents = true);

newVal
Input name of the LayerTableRecord to be referenced by the entity

doSubents
Input Boolean indicating whether to propagate the change to any subentities the entity may own


This method sets entity to reference the AcDbLayerTableRecord identified by the name specified in newVal. If the entity owns subentities and doSubents == Adesk::kTrue, then the layer change will be applied to the subentities as well.

Note The only built-in entities for which kTrue has an effect are: AcDb2dPolyline, AcDb3dPolyline, AcDbPolyFaceMesh, and AcDbPolygonMesh.

The database containing the entity is searched for the AcDbLayerTableRecord object with the name pointed to by newVal. If the entity is not currently in a database, then the database currently in the AutoCAD editor is searched.

If a matching LayerTableRecord is found then the entity will be set to reference it and Acad::eOk will be returned.

If no LayerTableRecord object is found with the name pointed to by newVal, then Acad::eKeyNotFound will be returned.

If the LayerTableRecord object found has been erased, then Acad::eDeletedEntry will be returned.

If the entity is not within a database and there is no database in the AutoCAD editor, then Acad::eNoDatabase will be returned.

函数 implementation in derived classes

If this 函数 is overridden and wishes to set the layer of the entity, then it must call AcDbEntity::setLayer() passing on the layer and doSubents arguments or call the other AcDbEntity::setLayer() passing in the doSubents value and the objectId of the AcDbLayerTableRecord to reference.

It is also possible for this 函数's implementation to deal directly with any subentities and pass a doSubents value of Adesk::kFalse to AcDbEntity::setLayer().

If this 函数 is successful, it should return Acad::eOk. Any other error return values are up to the implementor, but if it calls either of the AcDbEntity::setLayer() methods and that call returns an error, then it's recommended that the ErrorStatus value returned be returned by this 函数 as well.



AcDbEntity::setLinetype 函数

virtual Acad::ErrorStatus

setLinetype(

const char* newVal,

Adesk::Boolean doSubents = true);

newVal
Input name of the LinetypeTableRecord to be referenced by the entity

doSubents
Input Boolean indicating whether to propagate the change to any subentities the entity may own


函数 usage

This method sets the entity to reference the AcDbLinetypeTableRecord with the name specified in newVal. If the entity owns subentities and doSubents == Adesk::kTrue, then the linetype change will be applied to the subentities as well.

Note The only built-in entities for which kTrue has an effect are: AcDb2dPolyline, AcDb3dPolyline, AcDbPolyFaceMesh, and AcDbPolygonMesh.

The database containing the entity is searched for the AcDbLinetypeTableRecord object with the name pointed to by newVal. If the entity is not currently in a database, then the database currently in the AutoCAD editor is searched.

If a matching LinetypeTableRecord is found then the entity will be set to reference it and Acad::eOk will be returned.

If no LinetypeTableRecord object is found with the name pointed to by newVal, then Acad::eKeyNotFound will be returned.

If the LinetypeTableRecord object found has been erased, then Acad::eDeletedEntry will be returned.

If the entity is not within a database and there is no database in the AutoCAD editor, then Acad::eNoDatabase will be returned.

函数 implementation in derived classes

If this 函数 is overridden and wishes to set the LinetypeTableRecord referenced by the entity, then it must call AcDbEntity::setLinetype(char*, Adesk::Boolean) passing on the newVal and doSubents arguments or call AcDbEntity::setLinetype(AcDbObjectId, Adesk::Boolean) passing in the doSubents argument and the object ID of the LinetypeTableRecord that has the name pointed to by newVal.

It is also possible for this 函数's implementation to deal directly with any subentities and pass a doSubents value of Adesk::kFalse to AcDbEntity::setLinetype().

If this 函数 is successful, it should return Acad::eOk. Any other error return values are up to the implementor, but if it calls either of the AcDbEntity::setLinetype() methods and that call returns an error, then it's recommended that the ErrorStatus value returned be returned by this 函数 as well.


--------------------------------------------------------------------------------

virtual Acad::ErrorStatus

setLinetype(

AcDbObjectId newVal,

Adesk::Boolean doSubents = true);

newVal
Input objectId of the LinetypeTableRecord to be referenced by the entity

doSubents
Input Boolean indicating whether to propagate the change to any subentities the entity may own


函数 usage

This method sets the linetype value for an entity by the AcDbObjectId specified in "newVal", which must be a symbol table record specifying the linetype. If the entity owns subentities and doSubents == Adesk::kTrue, then the linetype change will be applied to the subentities as well.

Note The only built-in entities for which kTrue has an effect are: AcDb2dPolyline, AcDb3dPolyline, AcDbPolyFaceMesh, and AcDbPolygonMesh.

If the 函数 is successful, then Acad::eOk is returned.

If the object with object ID newVal is not an AcDbLinetypeTableRecord, then Acad::eWrongObjectType will be returned.

An attempt is made to open (for read) the object identified by newVal in order to determine if it is indeed an AcDbLinetypeTableRecord. If the open attempt fails, then the error status returned by the failed open attempt will be returned by this 函数 (see the acdbOpenObject() method documentation for possible return values).

函数 implementation in derived classes

If this 函数 is overridden and wishes to set the LinetypeTableRecord referenced by the entity, then it must call AcDbEntity::setLinetype(AcDbObject, Adesk::Boolean) passing on the newVal and doSubents arguments or call AcDbEntity::setLinetype(char*, Adesk::Boolean) passing in the doSubents argument and a pointer to a string that's the name of the LinetypeTableRecord with the object ID newVal.

It is also possible for this 函数's implementation to deal directly with any subentities and pass a doSubents value of Adesk::kFalse to AcDbEntity::setLinetype().

If this 函数 is successful, it should return Acad::eOk. Any other error return values are up to the implementor, but if it calls either of the AcDbEntity::setLinetype() methods and that call returns an error, then it's recommended that the ErrorStatus value returned be returned by this 函数 as well.



AcDbEntity::setLinetypeScale 函数

virtual Acad::ErrorStatus

setLinetypeScale(

double newval,

Adesk::Boolean doSubents = true);

newval
Input linetype scale factor for the entity

doSubents
Input Boolean indicating whether to propagate the change to any subentities the entity may own


This method sets the entity to use newval as its linetype scale factor. newVal must be nonnegative. If the entity owns subentities and doSubents == Adesk::kTrue, then the linetype scale change will be applied to the subentities as well.

Note The only built-in entities for which kTrue has an effect are: AcDb2dPolyline, AcDb3dPolyline, AcDbPolyFaceMesh, and AcDbPolygonMesh.

Returns Acad::eOk if successful. If newVal is negative then Acad::eNegativeValueNotAllowed is returned.

函数 implementation in derived classes

If this 函数 is overridden and wishes to set the Linetype scale of the entity, then it must call AcDbEntity::setLinetypeScale() passing on the newVal and doSubents arguments.

It is also possible for this 函数's implementation to deal directly with any subentities and pass a doSubents value of Adesk::kFalse to AcDbEntity::setLinetypeScale().

If this 函数 is successful, it should return Acad::eOk. Any other error return values are up to the implementor, but if it calls the AcDbEntity::setLinetypeScale() method and that call returns an error, then it's recommended that the ErrorStatus value returned be returned by this 函数 as well.



AcDbEntity::setLineWeight 函数

virtual Acad::ErrorStatus

setLineWeight(

AcDb::LineWeight newVal,

Adesk::Boolean doSubents = true);

newVal
Input AcDb::LineWeight for the entity

doSubents
Input to apply the lineweight change to subentities


This method sets the entity to use lineweight. If the entity owns subentities and doSubents == Adesk::kTrue, then the line weight change will be applied to the subentities as well.

Returns Acad::eOk if successful.

函数 implementation in derived classes

If this 函数 is overridden and wishes to set the line weight of the entity, then it must call AcDbEntity::setLineWeight() passing on the lineweight and doSubents arguments.

It is also possible for this 函数's implementation to deal directly with any subentities and pass a doSubents value of Adesk::kFalse to AcDbEntity:: setLineWeight().

If the line weight setting operation is successful, then this 函数 should return Acad::eOk. If lineweight is not an acceptable value, then this 函数 should return Acad::eInvalidInput. Any other error return values are up to the implementor.



AcDbEntity::setPlotStyleName 函数

virtual Acad::ErrorStatus

setPlotStyleName(

const char* newName,

Adesk::Boolean doSubents = true);

newName
Input plotStyleName string to be used by the entity

doSubents
Reserved for future use


This 函数 searches the PlotStyleName dictionary for an entry with the name that matches newName and if found, sets the entity to use that plotStyleName entry. Because a lookup in the PlotStyleName dictionary is required, the entity must be database-resident for this method to succeed. The names ByLayer and ByBlock are allowed as well as user-defined names.

Returns Acad::eOk if successful. If the entity is not database-resident, then Acad::eNoDatabase will be returned. If there is no entry in the PlotStyleName dictionary for newName, then Acad::eKeyNotFound will be returned.

The plotStyleName value is used for DXF group code 390.


--------------------------------------------------------------------------------

virtual Acad::ErrorStatus

setPlotStyleName(

AcDb::PlotStyleNameType unnamed,

AcDbObjectId newId = AcDbObjectId::kNull,

Adesk::Boolean doSubents = true);

unnamed
未说明

newId
未说明

doSubents
未说明


未说明



AcDbEntity::setPropertiesFrom 函数

Acad::ErrorStatus

setPropertiesFrom(

const AcDbEntity* pEntity,

Adesk::Boolean doSubents = true);

pEntity
Input entity from which to copy the properties

doSubents
Input Boolean indicating whether to propagate the change to any subentities the entity may own


This method copies the

·   Color

·   Layer

·   Linetype

·   Linetype scale

·   Visibility

values from the entity pointed to by pEntity into this entity. If the entity owns subentities and doSubents == Adesk::kTrue, then the property changes will be applied to the subentities as well.

Returns Acad::eOk if successful.



AcDbEntity::setVisibility 函数

virtual Acad::ErrorStatus

setVisibility(

AcDb::Visibility newVal,

Adesk::Boolean doSubents = true);

newVal
Input visibility value to which the entity will be set. The possible AcDb::Visibility values are:
AcDb::kInvisible
AcDb::kVisible

doSubents
Input Boolean indicating whether to propagate the change to any subentities the entity may own


This method sets the visibility of an entity to the value specified by newVal. If the entity owns subentities and doSubents == Adesk::kTrue, then the visibility change will be applied to the subentities as well.

Note The only built-in entities for which kTrue has an effect are: AcDb2dPolyline, AcDb3dPolyline, AcDbPolyFaceMesh, and AcDbPolygonMesh.

Returns Acad::eOk if successful.

函数 implementation in derived classes

If this 函数 is overridden and wishes to set the visibility of the entity, then it must call AcDbEntity::setVisibility() passing on the newVal and doSubents arguments.

It is also possible for this 函数's implementation to deal directly with any subentities and pass a doSubents value of Adesk::kFalse to AcDbEntity::setVisibility().

If the color setting operation is successful, then this 函数 should return Acad::eOk. If color is not an acceptable value, then this 函数 should return Acad::eInvalidIndex. Any other error return values are up to the implementor.



AcDbEntity::subSetDatabaseDefaults 函数

virtual void

subSetDatabaseDefaults(

AcDbDatabase* pDb);

pDb
Input database to set defaults from. This argument is forwarded by the internal setDatabaseDefaults() method that calls this method.


函数 usage

This 函数 is not intended to be called by ObjectARX applications. It is designed to be called by the AcDbEntity::setDatabaseDefaults() method in order to provide a "hook" into the setDatabaseDefaults process.

函数 implementation in derived classes

This 函数 is called from within setDatabaseDefaults() after the property values have been set within the entity. As such, it provides a hook into the setDatabaseDefaults operation at a time when you can see what the new values are, change them if desired, and make other changes as well.

The entity is open for write, and there are no restrictions on what you can do within this 函数 other than those normally imposed on any object open for write.

Default implementation

Immediately return without performing any action.



AcDbEntity::transformBy 函数

virtual Acad::ErrorStatus

transformBy(

const AcGeMatrix3d& xform);

xform
Input transformation matrix to be applied to the entity


函数 usage

This 函数 provides a means by which AutoCAD and ObjectARX applications can ask the entity to apply a transformation matrix (xform) to itself.

Each entity class must implement this 函数, so restrictions on what types of transformations are supported are up to the implementor of the entity class. The AutoCAD built-in entity classes for entity types that existed before R13 (that is, all the classes listed in the header file dbents.h such as AcDbCircle, AcDbLine, AcDbArc, AcDb2dPolyline, etc.) require that the transformation matrix represent a uniformly scaling orthogonal transformation (if it is not, then Acad::eCannotScaleNonUniformly will be returned). Other AutoCAD built-in classes have no restrictions.

Returns Acad::eOk if successful. Return values for errors are implementation-dependent.

函数 implementation in derived classes

This 函数 must apply the transformation matrix xform to the entity and change the entity's state to reflect the transformation. It is completely up to the implementor as to how to apply the transformation. It is also up to the implementor to decide what, if any, restrictions will be placed on the type of transformations supported. If any restrictions are desired, then it's up to the implementation of this 函数 to enforce them.

If your derived class implements transformBy() without calling the base class, you must call AcDbObject:: xDataTransformBy() or your Xdata will not be transformed.

If this 函数 successfully transforms the entity, then it should return Acad::eOk.

Return values for error conditions are completely up to the implementor of this 函数. However, if the error is caused by a non-uniformly scaling or non-orthogonal matrix, then to be consistent with other entities that have this restriction, it is recommended that Acad::eCannotScaleNonUniformly be returned.

Note If this method is not overridden, then AutoCAD commands such as MOVE, ROTATE, SCALE, etc. will have no effect on entities of this class.

Default implementation

Calls assertWriteEnabled(Adesk::kFalse, Adesk::kFalse) and then returns Acad::eNotApplicable.




AcDbEntity Graphic Functions


AcDbEntity::cloneMeForDragging 函数

virtual Adesk::Boolean

cloneMeForDragging();

This 函数 indicates to AutoCAD whether a clone should be created for use in a dragging operation. AutoCAD has always created a clone in the past, but due to entities with large amounts of data (for example, polylines) it is sometimes desirable to have AutoCAD perform dragging with the original entity.

Default implementation: Returns Adesk::kTrue indicating that a clone will be created for the dragging operation.




AcDbEntity::draw 函数

Acad::ErrorStatus

draw();

This 函数 queues up the entity's graphics and flushes the graphics queue, forcing the entity and anything else in the queue to be drawn or re-drawn on-screen.

Returns Acad::eOk if successful.

If the entity is not in a database, then Acad::eNotInDatabase will be returned.

If the entity is in a database other than the one currently loaded into the AutoCAD editor, then Acad::eNotCurrentDatabase will be returned.




AcDbEntity::highlight 函数

virtual Acad::ErrorStatus

highlight(

const AcDbFullSubentPath& subId = kNullSubent,

const Adesk::Boolean highlightAll = false) const;

subId
Input AcDbFullSubentPath that identifies the subentity to highlight

highlightAll
Input Boolean indicating whether to highlight all


函数 usage

This 函数 uses the AcDbFullSubentPath id to determine which subentity in the entity is desired. It then highlights that subentity on screen. If no AcDbFullSubentPath argument is provided, then the entire entity will be highlighted.

Typically, the AcDbFullSubentPath object passed in via subId is obtained from the entity's AcDbEntity::getSubentPathsAtGsMarker() method. This guarantees that it is fully and properly filled in.

This 函数 uses the entity's getGsMarkersAtSubentPath() method to get the GS markers associated with subId. If that 函数 does not return Acad::eOk, then this 函数 will fail and return whatever ErrorStatus was returned by getGsMarkersAtSubentPath().

If this 函数 succeeds, then it returns Acad::eOk.

The highlight and unhighlight methods must be called in pairs. If highlight is called for this entity, a call to unhighlight for this entity must follow. If an AcDbFullSubentPath objectID is provided for highlight, that same AcDbFullSubentPath object is required for unhighlight.

Warning If the entity on which this method is called has its graphics queued for regeneration (that is, changes have been made to the entity but have not yet been reflected on screen), then this method will not cause a highlight to occur. Also, calling this method on an entity that's open for write and whose graphics are queued for regeneration may terminate AutoCAD.

To avoid this limitation, before calling highlight(), you should flush the entity's graphics by either calling the entity's draw() method, or calling the AcTransactionManager::flushGraphics() 函数.

函数 implementation in derived classes

The AcDbEntity::highlight() implementation does all the work necessary to highlight any subentities that correspond to the subId FullSubentPath. So, there is no need to override this method unless you wish to do some pre-or post-processing, or you wish to disable the ability to highlight subentities.

If this method is overridden and it is supposed to highlight subentities, then the AcDbEntity::highlight() method will need to be invoked at some point within this 函数 in order to do the actual highlighting.

Within the AcDbEntity::highlight() method, the getGsMarkersAtSubentPath() method of this entity is called to translate the FullSubentPath into the corresponding GS markers. So, if this 函数 is to succeed, the getGsMarkersAtSubentPath() method needs to be implemented as well.

For more information on the subId AcDbFullSubentPath argument, see the documentation on the AcDbEntity::getGsMarkersAtSubentPath() or AcDbEntity::getSubentPathsAtGsMarker() methods.






AcDbEntity::recordGraphicsModified 函数

void

recordGraphicsModified(

Adesk::Boolean autoUndo = true);

autoUndo
Input Boolean value to indicate if the entity's graphics should be updated on screen when the object is closed


This method sets the entity's state to indicate whether or not the entity should be updated on screen when it is closed. If the entity is set not to update, then any changes made will appear the next time the entity is regenerated.

If setModified == Adesk::kFalse and the entity is currently set to update its graphics on close (which is its default state), then this 函数 sets the entity so that it will not update on screen when it is closed and objectModified notification is sent to all entity type reactors attached to the entity. If setModified == Adesk::kFalse and the entity is already set not to update its graphics on close, then this 函数 simply returns.

If setModified == Adesk::kTrue, then the entity is set to update on screen when it is closed.




AcDbEntity::saveAs 函数

virtual void

saveAs(

AcGiWorldDraw* mode,

AcDb::SaveType st);

mode
Input pointer to fully initialized AcGiWorldDraw object (or an object of a class derived from AcGiWorldDraw)

st
Input SaveType indicates why the saveAs is being called.


函数 usage

This 函数 is used by AutoCAD to generate the graphic primitives whenever the SAVEASR12 command is executed in AutoCAD or a DWG save is occurring that requires proxy graphics to be saved for the entity. Overriding this 函数 allows control of the graphics that will be stored in these two cases.

It is possible for an ObjectARX application to call this 函数, but it will need to provide a fully functional AcGiWorldDraw object and the AcGiWorldGeometry and AcGiSubEntityTraits objects for which it provides references. The only way to do this is to derive custom classes from these three AcGi classes. The acgisamp.cpp sample program supplied with the ObjectARX SDK demonstrates how to do this.

函数 implementation in derived classes

The AcGiWorldDraw object pointed at by pMode, as well as the AcGiWorldGeometry and AcGiSubEntityTraits objects available from the AcGiWorldDraw object, are all provided to allow this 函数 to generate whatever graphics primitives are desired to represent the entity in an R12 drawing file, or when the entity is a proxy and needs to be displayed. Chapter 10 in the ObjectARX Developer's Guide explains how to use these classes.

In the contexts that this 函数 is called, there is no need to deal with GS marker assignments. However, all the visible properties such as colors, layer, linetypes, visibilities, etc. are relevant.

The st argument provides the context for the call of this 函数. The possible values are:

AcDb::kNoSave
Do nothing. This value should never be seen when called from AutoCAD

AcDb::kR12Save
Saving graphics to an R12 drawing file

AcDb::kR13Save
Saving graphics for display when entity is a proxy


When the context is kR12Save, the graphics primitives generated by this 函数 will be converted into R12 entities and saved to the R12 drawing file.

When the context is kR13Save, the graphics primitives generated by this 函数 will be stored with the entity in the R13 drawing file so that if the drawing is ever loaded up with the entity's controlling application not loaded (that is, the entity becomes a proxy), the entity can still be displayed.

Default implementation

By default, this method calls the entity's worldDraw() method using the mode pointer.




AcDbEntity::unhighlight 函数

virtual Acad::ErrorStatus

unhighlight(

const AcDbFullSubentPath& subId = kNullSubent,

const Adesk::Boolean highlightAll = false) const;

subId
Input an AcDbFullSubentPath that identifies which subentity to unhighlight

highlightAll
Input Boolean indicating whether to unhighlight all


函数 usage

This 函数 uses the AcDbFullSubentPath id to determine which subentity in the entity is desired. It then unhighlights that subentity on screen. If no AcDbFullSubentPath argument is provided, then the entire entity will be unhighlighted.

Typically the AcDbFullSubentPath object passed in via subId will be obtained from the entity's AcDbEntity::getSubentPathsAtGsMarker() method. This guarantees that it is fully and properly filled in.

This 函数 uses the entity's getGsMarkersAtSubentPath() method to get the GS markers associated with subId. If that 函数 does not return Acad::eOk, then this 函数 will fail and return whatever ErrorStatus was returned by getGsMarkersAtSubentPath().

If this 函数 succeeds, then it will return Acad::eOk.

The highlight and unhighlight methods must be called in pairs. If highlight is called for this entity, a call to unhighlight for this entity must follow. If an AcDbFullSubentPath objectID is provided for highlight, that same AcDbFullSubentPath object is required for unhighlight.

函数 implementation in derived classes

The AcDbEntity::unhighlight() implementation does all the work necessary to unhighlight any subentities that correspond to the subId FullSubentPath. So, there is no need to override this method unless you wish to do some pre-or post processing, or you wish to disable the ability to unhighlight subentities.

If this method is overridden and it is supposed to unhighlight subentities, then the AcDbEntity::unhighlight() method needs to be invoked at some point within this 函数 in order to do the actual unhighlighting.

Within the AcDbEntity::unhighlight() method, the getGsMarkersAtSubentPath() method of this entity is called to translate the FullSubentPath into the corresponding GS markers. So, if this 函数 is to succeed, the getGsMarkersAtSubentPath() method needs to be implemented as well.

For more information on the subId AcDbFullSubentPath argument, see the documentation on the AcDbEntity::getGsMarkersAtSubentPath() or AcDbEntity::getSubentPathsAtGsMarker() methods.




AcDbEntity::viewportDraw 函数

virtual void

viewportDraw(

AcGiViewportDraw* mode);

mode
Input pointer to fully initialized AcGiViewportDraw object


函数 usage

Whenever a regeneration of the entity's graphics is required, AutoCAD calls the entity's worldDraw() method. If worldDraw() returns Adesk::kFalse, then AutoCAD calls this 函数 once for each viewport that is currently active in the AutoCAD editor. This 函数 then generates 3D graphic primitives independently for each viewport.

It is possible for ObjectARX applications to call this 函数, but they will need to provide a fully functional AcGiViewportDraw object and the AcGiViewportGeometry, AcGiViewport and AcGiSubentityTraits objects for which it provides references. The only way to do this is to derive custom classes from these four AcGi classes.

函数 implementation in derived classes

The AcGiViewportDraw object pointed to by pMode as well as the AcGiViewportDraw, AcGiViewport, and AcGiSubentityTraits objects available from the AcGiViewportDraw object are all provided to allow this 函数 to generate whatever graphics primitives are desired to represent the entity in a viewport dependent manner.

Since this 函数 will be called once for each viewport that is currently active within AutoCAD, it's possible to generate completely different images in each viewport (for example, a schematic image in one, a mesh image another. In addition, the AcGiViewport object provides detailed information about the viewport being drawn to for each call, so it's possible to draw the same basic image, but adjusted to accommodate the view in each viewport (for example, draw different tesselation lines depending on the view). See Chapter 10 in the ObjectARX Developer's Guide for more information.

Default implementation

Immediately returns without performing any action.




AcDbEntity::worldDraw 函数

virtual Adesk::Boolean

worldDraw(

AcGiWorldDraw* mode);

mode
Input pointer to fully initialized AcGiWorldDraw object


函数 usage

Whenever a regeneration of the entity's graphics is required, AutoCAD calls this 函数 to generate the graphics primitives that will represent this entity on screen. This 函数 will then provide a generic set of 3D graphics primitives that AutoCAD will adjust for each viewport's parameters as they are displayed.

If this 函数 returns Adesk::kFalse, then AutoCAD calls the AcGiViewportDraw() 函数 once for each viewport that is currently active in the AutoCAD editor.

It is possible for an ObjectARX application to call this 函数 (for example, in order to get the face information for an AcDb3dSolid entity), but it will need to provide a fully functional AcGiViewportDraw object and the AcGiWorldGeometry, and AcGiSubentityTraits objects for which it provides references. The only way to do this is to derive custom classes from these three AcGi classes. The acgisamp.cpp sample program supplied with the ObjectARX SDK demonstrates how to do this.

函数 implementation in derived classes

The AcGiWorldDraw object pointed to by pMode as well as the AcGiWorldGeometry and AcGiSubentityTraits objects available from the AcGiWorldDraw object are all provided to allow this 函数 to generate whatever graphics primitives are desired to represent the entity in a viewport independent manner (that is, one 3D image is used for all viewports and is adjusted by AutoCAD for all the different parameters in the different viewports). Chapter 10 in the ObjectARX Developer's Guide explains how to use these classes.

If this 函数 generates the graphics image to be used for display, then it should return Adesk::kTrue.

If the entity intends to do viewport dependent graphics primitives, then this 函数 should simply return Adesk::kFalse. This will cause AutoCAD to call the entity's viewportDraw() method once for each viewport that's currently active.

If this method is not overridden in classes derived from AcDbEntity, then entities of such classes will not display on screen.

Default implementation

Immediately returns Adesk::kTrue.




AcDbEntity Intersection Functions


AcDbEntity::boundingBoxIntersectWith 函数

Acad::ErrorStatus

boundingBoxIntersectWith(

const AcDbEntity* pEnt,

AcDb::Intersect intType,

const AcGePlane& projPlane,

AcGePoint3dArray& points,

int thisGsMarker,

int otherGsMarker) const;

pEnt
Input entity with which "this" entity will intersect

intType
Input requested intersection type

projPlane
Input a projection plane for the apparent intersection of the two entities

points
Output with the points (in WCS coordinates) of intersection appended

thisGsMarker
Input GS marker of subentity of "this" entity that's involved in the intersection operation. May be 0 if not applicable

otherGsMarker
Input GS marker of subentity of the entity pointed to by pEnt that's involved in the intersection operation. May be 0 if not applicable


This version of the 函数 is the same as the one above except that it projects the bounding box edges of this entity and the pEnt entity onto the projPlane, finds the intersection points, and then projects the intersection points back onto the appropriate bounding box edge of this entity. So, all points appended to the points array will be on the bounding box edges of this entity. The projections are done parallel to the projPlane's normal vector.

The possible AcDb::Intersect values for intType are:

Value
Meaning

AcDb::kOnBothOperands
Do not extend either this entity's bounding box edges nor the pEnt entity. This results in only calculating intersections where the bounding box lines actually intersect with the pEnt entity.

AcDb::kExtendThis
Extend this entity's bounding box edges (if necessary) when calculating intersections, but do not extend the pEnt entity.

AcDb::kExtendArg
Extend the pEnt entity (if necessary) when calculating intersections, but do not extend this entity's bounding box edges.

AcDb::kExtendBoth
Extend both the pEnt entity and this entity's bounding box edges (if necessary) when calculating intersections


Returns Acad::eOk if successful. ErrorStatus return values for error conditions depend upon how the entity pointed to by pEnt has implemented its projection plane intersectWith() method.


--------------------------------------------------------------------------------

Acad::ErrorStatus

boundingBoxIntersectWith(

const AcDbEntity* pEnt,

AcDb::Intersect intType,

AcGePoint3dArray& points,

int thisGsMarker,

int otherGsMarker) const;

pEnt
Input entity with which "this" entity will intersect

intType
Input requested intersection type

points
Output with the points (in WCS coordinates) of intersection appended

thisGsMarker
Input GS marker of subentity of "this" entity that's involved in the intersection operation. May be 0 if not applicable.

otherGsMarker
Input GS marker of subentity of the entity pointed to by pEnt that's involved in the intersection operation. May be 0 if not applicable.


This method first calculates the bounding box for this entity (in WCS coordinates) by calling the entity's getGeomExtents() method (so if this method has not been overridden with a valid implementation, then the return status of Acad::eInvalidExtents will be returned by this 函数). It then finds the intersections of the entity pointed to by pEnt and all the edges of the bounding box of this entity.

The intType is used to determine how to deal with extending the boundary edges or the pEnt entity in order to calculate intersections. The possible AcDb::Intersect values are:

Value
Meaning

AcDb::kOnBothOperands
Do not extend either this entity's bounding box edges nor the pEnt entity. This results in only calculating intersections where the bounding box lines actually intersect with the pEnt entity.

AcDb::kExtendThis
Extend this entity's bounding box edges (if necessary) when calculating intersections, but do not extend the pEnt entity.

AcDb::kExtendArg
Extend the pEnt entity (if necessary) when calculating intersections, but do not extend this entity's bounding box edges.

AcDb::kExtendBoth
Extend both the pEnt entity and this entity's bounding box edges (if necessary) when calculating intersections


Any intersection points found are appended to the points array. All points are in WCS coordinates.

Note In the process of determining the intersections of the pEnt entity with the bounding box edges of this entity, the non-projection plane version of pEnt's intersectWith() method may be called (if the pEnt entity is a custom entity, then the intersectWith() method will definitely be called). If the intersectWith() method has not been implemented for the pEnt entity's class, then this 函数 fails if that method is called.

The thisGsMarker and otherGsMarker arguments are only used if the pEnt entity's intersectWith() method is called, and even then they are just passed on into that method where they may still not be used.

Returns Acad::eOk if successful. ErrorStatus return values for error conditions depend upon how the entity pointed to by pEnt has implemented its non-projection plane intersectWith() method.




AcDbEntity::intersectWith 函数

virtual Acad::ErrorStatus

intersectWith(

const AcDbEntity* pEnt,

AcDb::Intersect intType,

AcGePoint3dArray& points,

int thisGsMarker = 0,

int otherGsMarker = 0) const;

pEnt
Input entity with which "this" entity is to intersect

intType
Input type of intersection requested

points
Output with the points of intersection appended

thisGsMarker
Input GS marker of subentity of "this" entity that's involved in the intersection operation. Use the 0 default if not applicable.

otherGsMarker
Input GS marker of subentity of the entity pointed to by pEnt that's involved in the intersection operation. Use the 0 default if not applicable.


函数 usage

It finds the intersections of the entity pointed to by pEnt and all the edges of the bounding box of this entity.

The intType is used to determine how to deal with extending the two entities in order to calculate intersections. The possible AcDb::Intersect values are:

Value
Meaning

AcDb::kOnBothOperands
Do not extend either entity. This results in only calculating intersections where the two entitys' geometry actually intersect

AcDb::kExtendThis
Extend this entity (if necessary) when calculating intersections, but do not extend the pEnt entity.

AcDb::kExtendArg
Extend the pEnt entity (if necessary) when calculating intersections, but do not extend this entity.

AcDb::kExtendBoth
Extend both the pEnt entity and this entity (if necessary) when calculating intersections


Any intersection points found are appended to the points array. All points are in WCS coordinates.

The thisGsMarker and otherGsMarker arguments are intended to provide this 函数 with information to allow it to localize the search for intersections to be between specific subentities. However, this 函数 is not required to make use of either of these arguments (most, if not all, of the AutoCAD built-in entity classes do not). When calling this 函数, either or both of these arguments may be 0 in order to indicate that they should be ignored.

If this 函数 is successful it returns Acad::eOk. Return values for error conditions are dependent on the implementation of this 函数 in the classes involved.

函数 implementation in derived classes

This 函数 should do all it can to find all intersection points between the entity it's being called on and the entity pointed to by pEnt. All intersection points found should be appended to the points array. All such points must be in WCS coordinates.

When implementing the intersection calculation portion of this 函数 you should take a good look at the AcGe classes to see if they can provide any useful functionality to help in finding intersections with the geometric primitives that make up the entity this 函数 is being called on and the pEnt entity. For example, the AcGeCurve3d class has an isOn() method that will indicate if a supplied point is on the curve and the AcGeArc3d class has several intersectWith() methods to find intersections with other AcGe types.

If the pEnt entity is a type not recognized by this 函数, it is quite reasonable to call the pEnt entity's intersectWith() method passing in a pointer to this entity as the "pEnt", and all the other arguments passed into this 函数 (remembering to convert the intType argument If necessary) to see if that entity can determine any intersection points. This is what the AutoCAD built-in classes do.

Also, don't forget to take into account the intType value. The intType tells you which, if any, of the two entities should be extended to find "apparent" intersections. It is not required that apparent intersection be supported, but if it is not, then an appropriate ErrorStatus value should be returned to indicate that the call failed.

The thisGsMarker and otherGsMarker arguments are provided to allow this 函数 to determine exactly which subentities are involved in the intersection operation (for example, if this 函数 is being called by AutoCAD as part of an intersection Osnap operation these arguments would indicate which subentities are within the osnap pickbox). For these arguments, a value less than or equal to zero indicates that that argument should not be used.

If this 函数 completes successfully (even if no intersection points are found), it should return Acad::eOk. Determining what is considered an error and what ErrorStatus return code to use for any such errors are up to the implementor -- there are no conventions in this regard.

Default implementation: Immediately returns Acad::eNotImplemented.


--------------------------------------------------------------------------------

virtual Acad::ErrorStatus

intersectWith(

const AcDbEntity* pEnt,

AcDb::Intersect intType,

const AcGePlane& projPlane,

AcGePoint3dArray& points,

int thisGsMarker = 0,

int otherGsMarker = 0) const;

pEnt
Input entity with which "this" entity is to intersect

intType
Input type of intersection requested. The possible AcDb::Intersect values are:

Value
Meaning

AcDb::kOnBothOperands
Do not extend either entity. This results in only calculating intersections where the two entitys' geometry actually intersect

AcDb::kExtendThis
Extend this entity (if necessary) when calculating intersections, but do not extend the pEnt entity.

AcDb::kExtendArg
Extend the pEnt entity (if necessary) when calculating intersections, but do not extend this entity.

AcDb::kExtendBoth
Extend both the pEnt entity and this entity (if necessary) when calculating intersections



projPlane
Input a projection plane for the apparent intersection of the two entities

points
Output with the points of intersection appended

thisGsMarker
Input GS marker of subentity of "this" entity that's involved in the intersection operation. Use the 0 default if not applicable.

otherGsMarker
Input GS marker of subentity of the entity pointed to by pEnt that's involved in the intersection operation. Use the 0 default if not applicable.


Same as the other version of this 函数 except that it projects this entity and the pEnt entity onto the projPlane, finds the intersection points, and then projects the intersection points back onto this entity. So, all points appended to the points array will be on this entity. The projections are done parallel to the projPlane's normal vector.

When implementing the intersection calculation portion of this 函数, in addition to the intersection functionality mentioned in the documentation on the other version of this 函数, the AcGe classes have functionality available to aid in the projection onto a plane and the projection of points onto AcGe objects.




AcDbEntity Miscellaneous Functions


AcDbEntity::applyPartialUndo 函数

virtual Acad::ErrorStatus

applyPartialUndo(

AcDbDwgFiler* undoFiler,

AcRxClass* classObj);

undoFiler
未说明

classObj
未说明


未说明




AcDbEntity::audit 函数

virtual Acad::ErrorStatus

audit(

AcDbAuditInfo* pAuditInfo);

pAuditInfo
未说明


未说明




AcDbEntity::drawable 函数

virtual AcGiDrawable *

drawable();

未说明




AcDbEntity::dwgInFields 函数

virtual Acad::ErrorStatus

dwgInFields(

AcDbDwgFiler* pFiler);

pFiler
未说明


未说明




AcDbEntity::dxfOutFields 函数

virtual Acad::ErrorStatus

dxfOutFields(

AcDbDxfFiler* pFiler) const;

pFiler
未说明


未说明




AcDbEntity::dxfInFields 函数

virtual Acad::ErrorStatus

dxfInFields(

AcDbDxfFiler* pFiler);

pFiler
未说明


未说明




AcDbEntity::dxfOutFields 函数

virtual Acad::ErrorStatus

dxfOutFields(

AcDbDxfFiler* pFiler) const;

pFiler
未说明


未说明




AcDbEntity::getClassID 函数

virtual Acad::ErrorStatus

getClassID(

CLSID* pClsid) const;

pClsid
未说明


未说明




AcDbEntity::getPlotStyleNameId 函数

AcDb::PlotStyleNameType

getPlotStyleNameId(

AcDbObjectId& id) const;

id
未说明


未说明




AcDbEntity::gsNode 函数

virtual AcGsNode *

gsNode() const;

未说明




AcDbEntity::setAttributes 函数

virtual Adesk::UInt32

setAttributes(

AcGiDrawableTraits* pTraits);

pTraits
未说明


未说明




AcDbEntity::setGsNode 函数

virtual void

setGsNode(

AcGsNode* pNode);

pNode
未说明


未说明




AcDbEntity Query Functions


AcDbEntity::blockId 函数

AcDbObjectId

blockId() const;

This 函数 returns the AcDbObjectId of the entity's owner, which must be an AcDbBlockTableRecord.

If the entity does not have an owner yet, then AcDbObjectId::kNull will be returned.




AcDbEntity::color 函数

AcCmColor

color() const;

This 函数 returns the AutoCAD color number of the entity within an instance of AcCmColor.

The index value will be in the range 0 to 256. 0 and 256 are special values.

0 indicates the entity uses the color of the BlockReference that's displaying it. If the entity is not displayed through a BlockReference (for example, it's directly owned by the model space BlockTableRecord) and its color is 0, then it will display as though its color were 7.

256 indicates the entity uses the color specified in the LayerTableRecord it references.

Note The AcDbEntity::colorIndex() method is a more direct method to access the AutoCAD color number of the entity.




AcDbEntity::colorIndex 函数

Adesk::UInt16

colorIndex() const;

This 函数 returns the AutoCAD color number of the entity.

The index value will be in the range 0 to 256. 0 and 256 are special values.

0 indicates the entity uses the color of the BlockReference that's displaying it. If the entity is not displayed through a BlockReference (for example, it's directly owned by the model space BlockTableRecord) and its color is 0, then it will display as though its color were 7.

256 indicates the entity uses the color specified in the LayerTableRecord it references.




AcDbEntity::getCompoundObjectTransform 函数

virtual Acad::ErrorStatus

getCompoundObjectTransform(

AcGeMatrix3d & xMat) const;

xMat
Output filled in with transformation matrix used for nested objects


This 函数 is intended to be overridden by derived classes that are compound objects (in other words, objects that behave like blocks in the display list).

A compound object has little or no geometry of its own; instead it relies on nested entities, perhaps the contents of a BlockTableRecord, to represent itself. A compound object must use the same transformation matrix for all of its contained entities. Otherwise selection and osnap will not 函数 correctly. This is the method that the system uses to obtain that matrix from the compound object.

This method should only be overridden if you return the kDrawableIsCompoundObject flag from setAttributes. The matrix you should return here is the one that you pass to pushModelTransform before you render your nested objects. You must override this method if you return the compound object flag in setAttributes, even if you don't push a transform for your nested objects. In that case you would return Acad::eOk and the identity transform in xMat.

Default implementation: Returns Acad::eNotApplicable and the identity matrix in xMat.




AcDbEntity::getEcs 函数

virtual void

getEcs(

AcGeMatrix3d& retVal) const;

retVal
Output filled in with transformation matrix to go from OCS to WCS


This 函数 is intended to be overridden by derived classes that need to be able to provide access to an object coordinate system for objects of the class. The intent is that this 函数 provide a transformation matrix that can be used to transform vectors or points from the object's object coordinate system (OCS) to the World Coordinate System (WCS).

Default implementation: Return the identity matrix (ones along the diagonal, zeros elsewhere) in retVal.

We recommend that all data stored in custom classes be stored in WCS coordinates. If this is done, then the object's OCS will be the WCS and the transformation matrix will be the identity matrix. Then this 函数 will not need to be overridden since the identity matrix is this 函数's default return.

Note Even the pre-R13 entity types that store their data in OCS format (that is, circle, polyline, inserts, etc.) return the identity matrix.




AcDbEntity::getGeomExtents 函数

virtual Acad::ErrorStatus

getGeomExtents(

AcDbExtents& extents) const;

extents
Output the entity's extents


Unimplemented at the AcDbEntity level, this method is intended to be overridden in derived classes.

Derived classes should calculate and return the corner points (in WCS coordinates) of a box (with edges parallel to the WCS X, Y, and Z axes) that encloses the 3D extents of the entity, and return those points as an instance of class AcDbExtents in the "extents" parameter.

Default implementation: Immediately returns Acad::eInvalidExtents.




AcDbEntity::getGripPoints 函数

virtual Acad::ErrorStatus

getGripPoints(

AcGePoint3dArray& gripPoints,

AcDbIntArray& osnapModes,

AcDbIntArray& geomIds) const;

gripPoints
Input a pre-existing array to append grip points to Output with the entity's grip points appended

osnapModes
not currently in use

geomIds
not currently in use


函数 usage

This 函数 is not intended to be called by ObjectARX applications. However, it is possible to do so (for example, as a pass-through from the getStretchPoints() method).

函数 implementation in derived classes

This 函数 should append to the gripPoints array any points that are to treated as grip points for the entity.

The gripPoints array is passed to all entities involved in the grip operation, so the array may already contain grip points for other entities. Therefore, it is very important to append the new points rather than assigning them to any existing elements in the array.

When finished appending all desired grip points, return Acad::eOk. If anything other than Acad::eOk is returned, then grips are not activated for this entity.

The osnapModes and geomIds arguments are not currently used.

Default implementation

Immediately returns Adesk::eNotImplemented.




AcDbEntity::getGsMarkersAtSubentPath 函数

virtual Acad::ErrorStatus

getGsMarkersAtSubentPath(

const AcDbFullSubentPath& subPath,

AcDbIntArray& gsMarkers) const;

subPath
Input an AcDbFullSubentPath object that contains an AcDbSubentId object with the information necessary to determine the subentity (or subentities) for which the GS Marker(s) is requested.

gsMarkers
Output array with the GSMarker(s) for the subentity (or subentities)


Entities use various graphic primitives defined in AcGi to draw themselves. Part of this mechanism is the ability to associate an integer identifier called a graphics system marker (or, GS marker) with each primitive or with groups of primitives. Through the use of certain selection mechanisms the GS marker for the actual subentity selected on screen can be obtained and used with this 函数 and several other functions for various purposes such as highlighting or unhighlighting the subentity on screen.

函数 usage

This 函数 uses the AcDbSubentId object within the subPath object to determine which GS markers within the entity are appropriate. Any GS markers that match are appended to the gsMarkers array.

The subPath object's object ID array is not used, so it does not need to be filled in.

The subentId object within subPath does needs to be fully filled in with the desired SubentType and a valid index value (which may or may not actually be the GS marker).

Typically, this 函数 will be called with an AcDbFullSubentPath object that was filled in by the entity's AcDbEntity::getSubentPathsAtGsMarker() method.

Return values for this 函数 may vary depending on how the 函数 is implemented (see below).

函数 implementation in derived classes

This 函数 must be able to properly interpret the SubentType and index values in the AcDbSubentId object within subPath in order to determine the GS markers for the corresponding subentity (or subentities). The GS markers thus determined are then appended to the gsMarkers array.

The index values in AcDbSubentId objects can be any values you want (they are often simply the GS markers themselves), but if implemented, the getSubentPathsAtGsMarker() method must be able to calculate them based on a provided GS marker and, if implemented, the subentPtr() method must be able to interpret them to determine the corresponding subentity (or subentities):

Which return codes to use are completely up to the implementor, but to be consistent with other existing entity class implementations of this 函数, the following should be used:

·   If the 函数 succeeds, it should return Acad::eOk.

·   If an invalid or unsupported SubentType is passed in, then Acad::eWrongSubentityType should be returned.

·   If an invalid index is passed in, then Acad::eInvalidIndex should be returned.

Default implementation

Immediately returns Adesk::eNotApplicable.

Note The AcDbEntity::highlight() and AcDbEntity::unhighlight() methods both call this 函数 to obtain the GS marker(s) associated with a FullSubentPath. So, if this 函数 is not overridden, then they will not work.




AcDbEntity::getOsnapPoints 函数

virtual Acad::ErrorStatus

getOsnapPoints(

AcDb::OsnapMode osnapMode,

int gsSelectionMark,

const AcGePoint3d& pickPoint,

const AcGePoint3d& lastPoint,

const AcGeMatrix3d& viewXform,

AcGePoint3dArray& snapPoints,

AcDbIntArray& geomIds) const;

osnapMode
Input the osnap mode being requested

gsSelectionMark
Input the GS marker of the subentity involved in the object snap operation

pickPoint
Input the point (in WCS coordinates) picked during the object snap operation

lastPoint
Input the point (in WCS coordinates) selected just before pickPoint

viewXform
Input transformation matrix to transform from WCS to DCS

snapPoints
Input pre-existing array to append osnap points to (may already contain points); output with object snap points appended

geomIds
Not in use


This 函数 must use the material provided in osnapMode, gsSelectionMark, pickPoint, lastPoint, and viewXform to determine all appropriate osnap points for the entity. It must then append all such osnap points to the snapPoints array.

The snapPoints array is passed to all entities involved in the osnap operation, so it's possible that the array will already have entries in it when passed in. For this reason, it's very important that points be appended to the snapPoints array instead of assigning to any existing elements.

The osnapMode argument indicates which osnap mode is involved in the operation. Not all modes are applicable to all entity types (for example, AcDb::kOsModeIns is not applicable to a line). The possible values for this argument are:

Value
Meaning

AcDb::kOsModeEnd
Find the endpoint on the entity that is nearest to the pickPoint.

AcDb::kOsModeMid
Find the midpoint (of any line, arc, etc., subentity) that is nearest to the pickPoint.

AcDb::kOsModeCen
Find the center point (of any circle or arc subentity) that is nearest to the pickPoint.

AcDb::kOsModeNode
Find the node point (for example, dimension node points) that is nearest to the pickPoint.

AcDb::kOsModeQuad
Find the quad point (traditionally the four quadrant points on a circle) that's nearest to pickPoint.

AcDb::kOsModeIns
Find the insertion point of the entity (for example, the insertion point of a BlockReference or an MText object).

AcDb::kOsModePerp
Find the intersection point of the entity and a line perpendicular to the entity that passes through lastPoint.

AcDb::kOsModeTan
Find a point on the entity where a line that passes through lastPoint will be tangent to the entity

AcDb::kOsModeNear
Find the point on the entity that's nearest to pickPoint. You decide what 搉earest?means.


The gsSelectionMark argument contains the GS marker of the subentity that's involved in the osnap operation. If the entity hasn't set any GS markers, then this is the default GS marker value of 0. The GS marker is provided to allow narrowing down the osnap point(s) search parameter if desired.

The pickPoint argument provides the point (in WCS coordinates) that started this osnap operation.

The lastPoint argument provides the point picked just prior to the pickPoint point. This point is used when determining perpendicular and tangent osnap values.

The viewXform argument provides a transformation matrix to transform from WCS (World Coordinate System) to DCS (display coordinate system).

The display coordinate system is oriented such that the positive Z axis is coming out of the display screen towards the user, the positive X axis is horizontally from left to right on screen, and the positive Y axis is vertically upward on screen.

So, if the current viewpoint is at (1,0,0) (the viewer is always looking towards (0,0,0)) then the viewXform matrix would be:

0 1 0 0

0 0 1 0

1 0 0 0

0 0 0 1

In this matrix the last row and the last column are not used. Notice also that the third row is the DCS Z axis in WCS coordinates (which is the WCS version of the AutoCAD VIEWPOINT system variable).

This transformation matrix is provided to allow you to determine positions of various points in the current view. This is most useful for the AcDb::kOsModeNear mode where "nearest" may depend on the viewpoint.

The snapPoints argument is the array to append the resulting osnap points to. You may append zero or more points to the array.

This same array is passed to all entities involved in the osnap operation. When all entities have been queried, AutoCAD determines which point in the array is most appropriate for the desired osnap mode. So, this 函数 does not need to narrow the search down to one point.

AutoCAD does not care what the return status is from this 函数 (there's no reason for it to), but to be meaningful to anything else that might wish to call it, we recommend that Acad::eOk be returned for any snap modes that are supported whether they append any points or not.

Note This 函数 does not work for dimensions, in which case it returns eNotApplicable. To obtain osnap data for dimensions, use AcDbDimension::getOsnapPoints().




AcDbEntity::getPlane 函数

inline virtual Acad::ErrorStatus

getPlane(

AcGePlane& unnamed,

AcDb::Planarity& unnamed) const;

unnamed
Returns the plane which contains the curve

unnamed
Returns the curve's configuration. Possible values are:
AcDb::kNonPlanar
AcDb::kPlanar
AcDb::kLinear


If the entity is planar, then the plane containing the entity is returned in plane and flag is set to AcDb::kPlanar.

If the entity is nonplanar, but is linear, then plane is set to an arbitrary plane that contains the entity and flag is set to AcDb::kLinear.

If the entity is nonplanar and nonlinear, then plane is left unset and flag is set to AcDb::kNonPlanar.

Returns Acad::eOk if successful. Other ErrorStatus return values are implementation-dependent.

The default implementation is to return Acad::eNotApplicable.




AcDbEntity::getStretchPoints 函数

virtual Acad::ErrorStatus

getStretchPoints(

AcGePoint3dArray& stretchPoints) const;

stretchPoints
Input a pre-existing array to append the stretch points to; output with the entity's stretch points appended


函数 usage

This 函数 is not intended to be called by ObjectARX applications. However, it is possible to do so (for example, as a pass-through from the getGripPoints() method).

函数 implementation in derived classes

This 函数 should append to the stretchPoints array any points that are to treated as stretch points for the entity.

Stretch points are used by the stretch command within AutoCAD. Any stretch points that are within the crossing selection window during the stretch command, will be moved by whatever amount the user decides to "stretch" the selected entities. Any stretch points not in the crossing selection window will be left alone. This combination of some stretch points moving while others do not is what "stretches" the entity. If all stretch points are in the crossing window, then the entity is moved instead of stretched.

The stretchPoints array is passed to all entities involved in the stretch operation, so the array may already contain stretch points for other entities. Therefore it is very important to append the new points rather than assigning them to any existing elements in the array.

When finished appending all desired stretch points, return Acad::eOk. If anything other than Acad::eOk is returned, then this entity's stretch points will be ignored by the stretch operation.

Default implementation

Calls the AcDbEntity::getGripPoints() method. So, unless the entity needs to have stretch points that are different from the grip points, there is no need to override this method.




AcDbEntity::getSubentPathsAtGsMarker 函数

virtual Acad::ErrorStatus

getSubentPathsAtGsMarker(

AcDb::SubentType type,

int gsMark,

const AcGePoint3d& pickPoint,

const AcGeMatrix3d& viewXform,

int& numPaths,

AcDbFullSubentPath*& subentPaths,

int numInserts = 0,

AcDbObjectId* entAndInsertStack = NULL) const;

type
Input the subent type desired. The possible SubentTypes are:
AcDb::kFaceSubentType
AcDb::kEdgeSubentType
AcDb::kVertexSubentType
AcDb::kMlineSubentCache

gsMark
Input a GS marker representing a specific subentity (typically obtained from ads_ssnamex())

pickPoint
Input point (in WCS coordinates) picked during selection of the entity (this point will be on or very near the desired subentity)

viewXform
Input transformation matrix to transform from WCS to DCS

numPaths
Output the number of AcDbFullSubentPath objects in the subentPaths array

subentPaths
Output the address of a dynamically allocated array of one or more AcDbFullSubentPaths generated from the GS marker and other information passed into this 函数

numInserts
Input the number of object IDs for AcDbBlockReferences in entAndInsertStack (should be one less than the total number of entries in entAndInsertStack because the first entry is the entity itself, which is not a BlockReference). If the entity is directly owned by the model or paper space BlockTableRecords, then leave this argument out so its default of 0 will be used.

entAndInsertStack
Input an array of objectIds of the objects that are the nested containers of the subentity. The list is in order from the "main" entity that the subentity is a part of, out to the outermost AcDbBlockReference that is in model or paper space. If the entity is itself directly owned by model or paper space, then leave this argument out so that its default of NULL will be used.


Entities use various graphic primitives defined in AcGi to draw themselves. Part of this mechanism is the ability to associate an integer identifier called a graphics system marker (or, GS marker) with each primitive or with groups of primitives. Through the use of certain selection mechanisms, the GS marker for the actual subentity selected on screen can be obtained and, along with some other information passed into this 函数, can be used to create one or more AcDbFullSubentPath objects, each one representing a subentity and providing a more complete description of the subentity and its environment. These AcDbFullSubentPath objects can be used by several other functions for various purposes such as highlighting or unhighlighting the subentities on screen.

函数 usage

If the entity (of which the subentity is a part) is directly owned by the model or paper space BlockTableRecords, then leave out numInserts and entAndInsertStack so that their default value will be used.

Typically the GS marker is obtained via the use of ads_ssget() followed by ads_ssnamex() (see the ObjectARX Developer's Guide for more information on this).

The pickPoint can be obtained from ads_ssnamex() as well (it's the first group 5009 in the returned list).

The viewXform can be calculated using the ads_trans() 函数 on the vectors (1,0,0), (0,1,0), and (0,0,1) to translate them from DCS to WCS. The translations of these three vectors (with an extra 0 appended on to the end of each) would be used as the first three rows of the matrix. The last row is not used so it can be left as is. This argument is not used by any of the AutoCAD built-in entities.

If the entity is nested inside one or more block definitions, then the numInserts and entAndInsertStack arguments must also be filled in with non-zero or non-null values. If they are not filled in, then this 函数 will fail and return an error status. One way to get the necessary object IDs is to use ads_nentselp() to obtain the list of ads_names of the container objects. This list must then be converted to object IDs and reversed.

Upon return, the subentPaths argument will point to a dynamically allocated array of one or more AcDbFullSubentPath objects. The numPaths argument will contain the number of AcDbFullSubentPath objects being returned.

The calling application is responsible for deallocating the memory used by the subentPaths array. The C++ delete [ ] operator should be used.

Return values for this 函数 may vary depending on how the 函数 has been implemented (see below).

函数 implementation in derived classes

Entity classes which do not set GS markers probably should not implement this 函数 since the GS marker is the primary (and often the only) means of subentity distinction.

When implemented, this 函数 must use the material provided in type, gsMark, pickPoint, viewXform, numInserts, and entAndInsertStack to determine which subentity or subentities meet the criteria in these arguments. Next it must create a dynamically allocated array of AcDbFullSubentPaths (using the C++ new operator) with one element for each subentity determined in the first step. Finally it must fill in each AcDbFullSubentPath object in the array with the information appropriate to the subentity it will represent.

If numInserts == 0 and entAndInsertStack == NULL, it's important to check to be sure that the entity's owner is indeed the model or paper space BlockTableRecord. This can be done by using the entity's ownerId() method to obtain the objectId of its owner, and then opening up that object and using its name() method to obtain its name string. If the owner is not the model or paper space BlockTableRecord, and numInserts == 0 or entAndInsertStack == NULL, or both, then the input data is invalid and this 函数 should set numPaths to 0, set subentPaths to NULL and then return the error status Acad::eInvalidInput.

Each AcDbFullSubentPath object has two parts, an array of objectIds containing all the container objects, and an embedded AcDbSubentId object which in turn has two elements: an index value and a SubentityType.

If the "main" entity (the entity on which this 函数 is being called) is not nested within BlockReferences (that is, numInserts == 0 and entAndInsertStack == NULL), then the objectId array should contain only the objectId of the "main" entity. If the "main" entity is nested in one or more BlockReferences, then the AcDbObjectIdArray is the same as entAndInsertStack, so copying the entAndInsertStack elements into the AcDbObjectIdArray is all that's required.

The SubentType data item within the embedded AcDbSubentId should be set the same as type.

The index data item within the embedded AcDbSubentId can be any value you wish (it is often simply the GS marker), but if implemented, the following functions must be able to interpret them to determine the corresponding GS marker(s) or subentity (or subentities):

getGsMarkersAtSubentPath()

subentPtr()

The pickPoint and viewXform arguments are provided as extra aids (if necessary) in determining which subentity is involved. For example, some entity types might display differently depending on the display viewpoint. The viewXform transformation matrix can be used in such cases.

The viewXform argument provides a transformation matrix to transform from WCS (World Coordinate System) to DCS (display coordinate system).

The display coordinate system is oriented such that the positive Z axis is coming out of the display screen towards the user, the positive X axis is horizontally from left to right on screen, and the positive Y axis is vertically upwards on screen.

So, if the current viewpoint is at (1,0,0) (the viewer is always looking towards (0,0,0)) then the viewXform matrix would be:

0 1 0 0

0 0 1 0

1 0 0 0

0 0 0 1

In this matrix the last row and the last column are not used. Notice also that the third row is the DCS Z axis in WCS coordinates (which is the WCS version of the AutoCAD VIEWPOINT system variable).

When this 函数 returns, the return code to use is completely up to the implementor, but to be consistent with other existing entity class implementations of this 函数 the following should be used:

·   If the 函数 succeeds, it should return Acad::eOk.

·   If an invalid or unsupported SubentType is passed in, then numPaths should be set to 0, subentPaths should be set to NULL, and Acad::eWrongSubentityType should be returned.

·   If an invalid GS marker (or any other data item that turns out to be needed) is passed in, then numPaths should be set to 0, subentPaths should be set to NULL, and Acad::eInvalidInput should be returned.

Default implementation

Immediately returns Adesk::eNotApplicable.




AcDbEntity::getTransformedCopy 函数

virtual Acad::ErrorStatus

getTransformedCopy(

const AcGeMatrix3d& xform,

AcDbEntity*& pEnt) const;

xform
Input the matrix by which to transform the copy of the entity

pEnt
Input a reference to an "empty" pointer; output pointing to the transformed copy of the entity


函数 usage

This 函数 creates a clone of the entity, applies the xform transformation matrix to the clone, and then returns with pEnt pointing to the transformed clone.

Warning For AutoCAD built-in complex entities such as polylines, this 函数 produces a shallow clone of the header entity only, which also owns the original set of "owned" entities (such as vertices for a polyline) which are then transformed by the xform matrix. This results in a corrupt drawing (two header entities owning the same set of "owned" entities) as well as transforming the original set of "owned" entities instead of a copied set.

Returns Acad::eOk if successful.

If xform is a non-uniform scaling matrix or non-orthogonal then Acad::eCannotScaleNonUniformly or Acad::eNotImplemented is returned.

函数 implementation in derived classes

The default AcDbEntity implementation of this 函数 should be adequate for most derived entity types. However, derived entity classes that wish to support non-uniform scaling or non-orthogonal transformations will need to override this method with their own implementation.

This 函数 must create a copy of the entity (using memory that has been dynamically allocated via the C++ new operator), apply the transformation matrix xform to the copy and then return with pEnt pointing to the transformed copy.

Determining what constitutes a valid transformation matrix and whether to do a shallow clone (that is, the entity's clone() method), a deepclone (if the entity owns other objects), or no clone at all (that is, make this 函数 a no-op), is up to the implementor.

Return values for this 函数 are also up to the implementor, but to be consistent with other existing classes the following is recommended:

·   If the 函数 succeeds, it should return Acad::eOk.

·   If the 函数 is to be a no-op, it should return Acad::eNotImplemented

·   If non-uniform scaling is not to be supported and a non-uniform scaling matrix is passed in, then either Acad::eCannotScaleNonUniformly or Acad::eNotImplemented should be returned.

Default implementation

If the entity is uniformly scaled and orthogonal, AcDbEntity::getTransformedCopy will call the entity's clone() method to create a clone of the entity, then call AcDbEntity::transformBy() on the clone, and then return with pEnt set to point to the transformed clone. If xform is a non-uniformly scaled or a non-orthogonal matrix, then this 函数 will return Acad::eNotImplemented.




AcDbEntity::isPlanar 函数

inline virtual Adesk::Boolean

isPlanar() const;

This 函数 returns Adesk::kTrue if and only if there is a plane which contains the entity. Otherwise Adesk::kFalse is returned.

Note Where appropriate, AutoCAD built-in entity types check for planarity within a tolerance value (for example, for AcDb3dPolyline the tolerance is 1e-10).

Returns Acad::kFalse in the default implementation.




AcDbEntity::layer 函数

char *

layer() const;

This 函数 returns a copy of the name string in the AcDbLayerTableRecord object referenced by the entity.

The calling application is responsible for deallocating the memory used by the returned string. The acutDelString() 函数 is recommended.

Warning Calling this 函数 before the entity has had its referenced layer object ID set (that is, it抯 still set to AcDbObjectId::kNull) will terminate AutoCAD. If the referenced layer objectId is AcDbObjectId::kNull when the entity is added to a database, it will be set to the object ID of the database抯 current default layer.




AcDbEntity::layerId 函数

AcDbObjectId

layerId() const;

This 函数 returns the AcDbObjectId of the AcDbLayerTableRecord referenced by the entity. If the layerId has not been set yet, then AcDbObjectId::kNull is returned.




AcDbEntity::linetype 函数

char *

linetype() const;

This 函数 returns a copy of the name string in the AcDbLinetypeTableRecord object referenced by the entity.

The calling application is responsible for deallocating the memory used by the returned string. Either the C++ delete [ ] operator or the C free() 函数 may be used.

Warning Calling this 函数 before the entity has had its referenced linetype object ID set (that is, it's still set to AcDbObjectId::kNull) will terminate AutoCAD. If the referenced linetype objectId is AcDbObjectId::kNull when the entity is added to a database it will be set to the object ID of the database's current default linetype




AcDbEntity::linetypeId 函数

AcDbObjectId

linetypeId() const;

This 函数 returns the AcDbObjectId of the AcDbLinetypeTableRecord referenced by the entity. If the linetypeId has not been set yet, then AcDbObjectId::kNull will be returned.




AcDbEntity::linetypeScale 函数

double

linetypeScale() const;

This 函数 returns the linetype scale factor for the entity




AcDbEntity::lineWeight 函数

AcDb::LineWeight

lineWeight() const;

This 函数 returns the AcDb::LineWeight of the entity.




AcDbEntity::list 函数

virtual void

list() const;

函数 usage

This 函数 is intended to be called from AutoCAD whenever the entity is selected during the LIST command. However, it can be called from ObjectARX applications if desired.

This 函数 will print entity specific information to the AutoCAD command line.

函数 implementation in derived classes

When implementing this 函数 in a derived class, the first thing that should be done in the 函数 is to make a call to assertReadEnabled(). The next thing to do is to call the parent class's list() method to allow the parent class to list it's information (the parent class should in turn call its parent class first and so on up the inheritance chain until AcDbObject is reached. This way all the entity's information will be properly printed out in order). Once the parent class's list 函数 has been called then a series of ads_printf() calls can be used to list whatever information is desired.

Default implementation

Lists out the entity's DXF name, the layer, the space the entity resides in (model or paper), and the entity's handle.




AcDbEntity::plotStyleName 函数

char *

plotStyleName() const;

This 函数 returns a copy of the plotStyleName string of the entity. The caller is responsible for deallocating the returned string.

The plotStyleName value is used for DXF group code 390.




AcDbEntity::subentPtr 函数

virtual AcDbEntity *

subentPtr(

const AcDbFullSubentPath& id) const;

id
Input an AcDbFullSubentPath that identifies the subentity to be copied


函数 usage

This 函数 uses the AcDbFullSubentPath id to determine which subentity in the entity is desired. It then creates a copy of that subentity using one of the classes derived from AcDbEntity so that the copy is a true "entity" that can be added to the database. If the 函数 succeeds then a pointer to the resulting copy is returned, otherwise NULL is returned.

Typically the AcDbFullSubentPath object passed in via id will be obtained from the entity's AcDbEntity::getSubentPathsAtGsMarker() method. This guarantees that it is fully and properly filled in.

The copy will be created using dynamically allocated memory (that is, using the new operator), so if it is not added to the database it will need to be deleted when it's no longer needed.

函数 implementation in derived classes

This 函数 must be able to interpret the information in the AcDbFullSubentPath id to determine which subentity in the entity is desired. It then must create an object (using the C++ new operator so that it's dynamically allocated and can be added to a database later if desired) of the appropriate class derived from AcDbEntity and fill it in with the data necessary to make it a copy of the subentity just determined. The 函数 then returns a pointer to the newly allocated and filled in entity.

The id AcDbFullSubentPath object has two parts, an array of objectIds containing all the container objects of the "main" entity (the entity on which this 函数 is being called), and an embedded AcDbSubentId object which in turn has two elements: an index value and a SubentType.

The SubentType data item within the embedded AcDbSubentId should be used to determine what type of subentity is being looked for. Possible SubentTypes are:

AcDb::kFaceSubentType

AcDb::kEdgeSubentType

AcDb::kVertexSubentType

AcDb::kMlineSubentCache

Of course it's up to the implementor of this 函数 to decide what type of entity to create for each of the SubentTypes, but most commonly a face subentity will be copied as an AcDbFace, vertex subentities are usually an AcDbPoint object, and for edge subentities you have your choice of the appropriate curve entities such as AcDbArc, AcDbLine, AcDbCircle, AcDbSpline, etc. However, since the AcGi graphics primitives can only be lines, circles, arcs, xlines, and rays, those are most likely to be the entity types you'll use.

The index data item within the embedded AcDbSubentId is then used to determine exactly which subentity is to be copied.

Though the index value is often the same as the GS marker, there are no rules governing how to assign and interpret index values other than that the getSubentPathsAtGsMarker() method needs to be able to assign them properly and this 函数 and the getGsMarkersAtSubentPath() must be able to interpret them to determine the corresponding GS marker(s).

If the "main" entity is not nested within BlockReferences, then the FullSubentPath's objectId array will contain only the objectId of the "main" entity and will not be needed by this 函数.

If the "main" entity is nested in one or more BlockReferences, then the AcDbObjectIdArray contains the objectIds of the objects that are the nested containers of the subentity. The list is in order from the "main" entity that the subentity is a part of, out to the outermost AcDbBlockReference that is in model or paper space.

This list of containers will need to be used to obtain the model coordinate system to World Coordinate System transform for each container and combine them to obtain the total transformation from the subentity's coordinate system out to the World Coordinate System.

(Another possibility might be to implement the entity class's worldDraw to call the getModelToWorldTransform() method in the AcGiWorldGeometry or AcGiViewportGeometry [depending on whether the class is using worldDraw() or viewportDraw()] object passed into it. Then cache the matrix returned since this will be the complete transformation matrix you need.)

Regardless of how the transformation matrix is obtained, it needs to be applied to the subentity's data to transform the data to WCS coordinates to be used by the new AcDb entity just created. The new entity will expect all its information to be in WCS coordinates.

If the 函数 runs to completion then it should return a pointer to the newly created entity that copies the subentity. If anything goes wrong, then the 函数 should simply return NULL.

Default implementation

Immediately returns NULL.




AcDbEntity::visibility 函数

AcDb::Visibility

visibility() const;

This method returns the entity's current visibility state, either AcDb::kVisible or AcDb::kInvisible.
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2003-11-17 18:22:49 | 显示全部楼层
也可以使用向导,当然还要多练习、实践!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-11-19 21:42:05 | 显示全部楼层
能不能给一个例子让大家看看!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-11-22 15:05:06 | 显示全部楼层
暂时看不懂

我也是一个菜鸟,请各位帮帮忙,十分感谢!
各位前辈,先给您敬礼!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-7-19 11:34:17 | 显示全部楼层
说得太笼统了,能不能给一个例子看一看?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-7-19 14:53:59 | 显示全部楼层
最好是向导生成的小例子,谢谢!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-7-19 15:01:17 | 显示全部楼层
ARX sample里面有一个例子
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-7-23 11:18:41 | 显示全部楼层
是那个文件?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-7-26 12:29:04 | 显示全部楼层
我热切期望,我刚学ARX,希望能多看到些源代码
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-7-27 21:09:34 | 显示全部楼层
这个例子
\ObjectARX 2000\samples\polysamp
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-9-16 13:46:29 | 显示全部楼层
好象大家现在都对自定义实体感兴趣
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-9-23 12:22:33 | 显示全部楼层
上面很长的那一段话好象来自于ARX文档 arxdev.chm 中。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-9-23 14:44:13 | 显示全部楼层
arxdev.chm是英文的
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2005-8-2 15:49:16 | 显示全部楼层
虽然不太确定,但可能有些帮助,谢谢先
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-6-18 19:13 , Processed in 0.529365 second(s), 57 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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