LoveArx 发表于 2018-12-13 22:50:04

从AcDbPolyline派生

AcDb: deriving from AcDbPolyline
Published date: 2008-10-14
ID: TS47354

Applies to:
AutoCAD® 2009
AutoCAD® 2008
AutoCAD® 2007

问题:
Deriving from AcDbPolyline works correctly, however, it seems DWG files
containing instances of my custom entity derived from AcDbPolyline do not
contain proxy graphic information for them. Why?

解决方案:
AutoCAD does not save the proxy graphic information for classes derived from
AcDbPolyline. The reason for this is that the 'saveAs()' method is implemented
as follows:


void AcDbPolyline::saveAs(AcGiWorldDraw* mode, AcDb::SaveType st) {
    assertReadEnabled();

    if ( st == AcDb::kR12Save )
      // ... do something to convert into AcDb2dPolyline
}
Whereas it should be as follows:


void AcDbPolyline::saveAs(AcGiWorldDraw* mode, AcDb::SaveType st) {
    assertReadEnabled();

    if ( st == AcDb::kR12Save )
      // ... do something to convert into AcDb2dPolyline
    else
      worldDraw (mode) ;
}
As a result, proxy graphic data is never saved, which causes your derived
AcDbPolyline entity to be invisible if your DBX-object enabler application is
not loaded. Although this is not ideal, it does not affect any other behavior or
functionality of your custom entity.

A simple override of the 'saveAs()' method can solve this problem as follows:

**** Hidden Message *****
When the "_PEDIT" command starts, the AsdkEdReactor::commandWillStart() reactor
callback is called and the bPEdit Boolean is set to True. Then AutoCAD verifies
that the entity selected is "kind of" an AcDbPolyline. To do this AutoCAD calls
the AcRxObject::isKindOf() method, this in turn calls the class descriptor of
the entity (AcDbMyPloyline::desc()), which returns the AutoCAD AcDbPolyline
class descriptor. In all other situations, it returns a real custom entity class
descriptor (child of AcDbCurve).

Forward Compatibility Issues
The two problems will be fixed in a later release of AutoCAD, it should be asked
if the custom entity derived from AcDbPolyline will continue to work. Although a
custom entity derived from AcDbPolyline will continue to work, you will also be
allowed to remove the workarounds in this solution without any problems,
including reloading files from one implementation to another.

weizcw2008 发表于 2019-2-18 17:11:20

需要回复查看

Throne 发表于 2019-3-2 09:41:00

回复查看...

基于中 发表于 2019-10-24 15:49:42


需要回复查看

nacl_cn 发表于 2019-11-1 21:55:43

这是关于什么的问题啊?

zxc_000 发表于 2019-11-28 15:31:40

看看楼主的分享

1121443108qaz 发表于 2019-12-27 02:01:13

我来看看看代码

wkur 发表于 2020-1-30 23:27:16

需要回复查看

机械工人 发表于 2020-2-7 21:56:08

很好,干得好

gis2000 发表于 2021-3-16 13:19:35

不知道有什么用

Cherish易 发表于 2021-4-2 09:48:42

回复查看隐藏内容

cable2004 发表于 2024-3-14 21:03:48

需要回复查看
页: [1]
查看完整版本: 从AcDbPolyline派生