- UID
- 1
- 积分
- 15891
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
发表于 2002-3-6 01:58:21
|
显示全部楼层
Re: [编程申请]:如何不改HANDLE的情况下,一种实体变为另一种实体
最初由 hiw 发布
[B]在AUTOCAD中,一条XLINE两边被TRIM后,变为LINE线,但HANDLE没有变,在编程上如何实现的? [/B]
数据库对象AcDbObject有方法AcDbObject::handOverTo()
Acad::ErrorStatus
handOverTo(
AcDbObject* pNewObject,
Adesk::Boolean keepXData = Adesk::kTrue,
Adesk::Boolean keepExtDict = Adesk::kTrue);
pNewObject Input pointer to object to be used to replace the current object
keepXData Input Boolean indicating if xdata is to be transferred during the process
keepExtDict Input Boolean indicating whether the extension dictionary is passed on from the old object to the new one. If set to kTrue, the extension dictionary will be passed on, otherwise it will be left behind.
This function provides the ability to exchange a non-database-resident object (NDBRO) in place of an existing database-resident object (DBRO) while retaining the objectId, handle, and reactor list of the DBRO. An example of this situation is when the BREAK command is used to break a circle into one or two arc segments. AcDbArc is a completely different class from AcDbCircle, so a new AcDbArc object must be substituted in place of the AcDbCircle
object that is there now, yet the arc must get the handle and objectId that the circle has.
To use the handOverTo() function, the object to be replaced (the AcDbCircle in the example) must be open AcDb::kForWrite. The object's handOverTo() function is called with pNewObject pointing to a non-database-resident object that replaces it (the AcDbArc in the example). keepXData is set to Adesk::kTrue if the xdata is to be retained or Adesk::kFalse if the xdata is to be thrown out. keepExtDict is set to Adesk::kTrue if the extension dictionary and its contents are to be retained, or set to Adesk::kFalse if the extension dictionary and its contents are to be thrown out.
Once returned from this function, the replacement object (the AcDbArc in the example) is open for AcDb::kForWrite and must have its close() member called to commit the change and close out Undo recording. Then it's up to the ObjectARX application to delete the old object (the AcDbCircle in the example) from memory since it's no longer database-resident.
Returns Acad::eObjectToBeDeleted if the operation is successful. If pNewObject is pointing to an object that is already in the database, or the object invoking handOverTo() is not database-resident, then Acad::eIllegalReplacement is returned.
Note This method is not allowed on objects that are transaction resident. If the object on which the method is called is transaction resident, then no handOverTo operation is performed and Acad::eInvalidContext is returned. |
|