My custom object encapsulates a AcDbText object. I didn't implement both the deepClone() and wblockClone() for it. For commands like copy mirror array ect, which just invoke the deepClone() method,it works all right.But for copy and paste or the wblock command it failed to copy some properties of my encapsulated AcDbText object, like the height, horizontal and vertical mode, position ect.
So i implement wblockClone() like this
Acad::ErrorStatus SLFText::wblockClone(AcRxObject* pOwnerObject,
AcDbObject*& pClonedObject,
AcDbIdMapping& idMap,
Adesk::Boolean isPrimary) const
{
assertReadEnabled();
AcDbObject::wblockClone(pOwnerObject, pClonedObject, idMap, isPrimary);
if(pClonedObject->isA()!=SLFText::desc()){
return Acad::eNotApplicable;
}
SLFText *pSlfText=SLFText::cast(pClonedObject);
AcGePoint3d position; pSlfText->position(position);
acutPrintf("\n *SLFText WblockClone(): height is %f",pSlfText->height());
acutPrintf("\n *SLFText WblockClone(): positionPt is\n x:%f,y:%f,z:%f",position.x,position.y,position.z);
acutPrintf("\n *SLFText WblockClone(): height is %d",pSlfText->textStyle());
acutPrintf("\n *SLFText WblcokClone(): horz is: %d",pSlfText->horizontalMode());
acutPrintf("\n *SLFText WblcokClone(): vert is: %d",pSlfText->verticalMode());
return Acad::eOk;
}
just to check the properties of the pClonedObject; To my suprise all these properties are exactly the same as the origin one. But when i used ctr+v to pasted the cloned one into the database,whether the same drawing as the origin one or a completely new drawing, the cloned object lost these properties obtained during wblockClone() method. Insead the height of the encapsulted AcDbText Object became to zero and both vertical and horizontal mode became to databse default
By the curveText sample in object SDK, i am sure that the same problem won't happen for the encapsulated AcDbCurve object. So I think the problem lies within the textStyle. Because the I found textStyleId for the cloned one pClonedObject during wblockClone was differnt from the origin one, while there is only one textStyle in the dawing. I don't know where exactly the textStyleId points to.
Do i have to fully implement the wblockClone() to make it work all right?
Thanks.