从AcDbPolyline派生
AcDb: deriving from AcDbPolylinePublished 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.
需要回复查看 回复查看...
需要回复查看 这是关于什么的问题啊? 看看楼主的分享 我来看看看代码 需要回复查看 很好,干得好 不知道有什么用
回复查看隐藏内容 需要回复查看
页:
[1]