找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1496|回复: 4

[编程申请]:如何不改HANDLE的情况下,一种实体变为另一种实体

[复制链接]
发表于 2002-3-6 01:49:29 | 显示全部楼层 |阅读模式

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

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

×
在AUTOCAD中,一条XLINE两边被TRIM后,变为LINE线,但HANDLE没有变,在编程上如何实现的?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 145个

财富等级: 日进斗金

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

使用道具 举报

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-3-6 01:59:13 | 显示全部楼层

Re: [编程申请]:如何不改HANDLE的情况下,一种实体变为另一种实体

最初由 hiw 发布
[B]在AUTOCAD中,一条XLINE两边被TRIM后,变为LINE线,但HANDLE没有变,在编程上如何实现的? [/B]


关于ID转换的,还有:

Acad::ErrorStatus
swapIdWith(
    AcDbObjectId otherId,
    Adesk::Boolean swapXdata = Adesk::kFalse,

    Adesk::Boolean swapExtDict = Adesk::kFalse);

otherId        Input objectId of object to swap with
swapXdata        Input Boolean indicating whether to swap extended entity data
swapExtDict        Input Boolean indicating whether to swap extension dictionaries

This function swaps objectIds and handles between the object specified by otherId and the object invoking this function. Both objects must currently be database-resident and must reside in the same database. If swapXdata == Adesk::kTrue, then the objects swap extended entity data as well. If
swapExtDict == Adesk::kTrue, then the objects swap extension dictionaries also.
If the object specified by otherId or the object invoking this function are not database-resident, then Acad::eNoDatabase is returned. If both objects involved are not in the same database, then Acad::eWrongDatabase is returned.
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2002-3-8 01:25:56 | 显示全部楼层

帮助好找,例子难迅,XD给个实例如何>

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

使用道具 举报

发表于 2002-3-9 01:01:37 | 显示全部楼层
如果只是修改的话,HANDLE应该不会变,除非你重新生成实体
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-16 04:18 , Processed in 0.357087 second(s), 40 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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