ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

encapsulated AcDbText object during wblockClone()

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
675 Views, 7 Replies

encapsulated AcDbText object during wblockClone()

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.
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

> Do i have to fully implement the wblockClone() to make it work all right?

You shouldn't have to implement wblockClone at all. Just implement
dwgIn/dwgOut properly. 🙂
--
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>
Message 3 of 8
Anonymous
in reply to: Anonymous

Thanks, Owen Wengerd:

Here is my code for the dwgIn and dwgOut which is almost the same as the CurveText sample:
*** DwgOut()
// Write the Class name of the embedded object for recreating it;
pFiler->writeItem(m_EmbeddedText->isA()->name());
m_EmbeddedText->dwgOutFields(pFiler);

*** DwgIn()
// Create a new instance of the embedded object using the class name saved in dwgOut;
buffer=NULL;
pFiler->readItem(&buffer);
AcRxClass *pRxClass=AcRxClass::cast(acrxClassDictionary->at(buffer));
acutDelString(buffer);
m_EmbeddedText=AcDbText::cast(pRxClass->create());
assert(m_EmbeddedText);

// Fill the embedded object with the information saved
m_EmbeddedText->dwgInFields(pFiler);
m_EmbeddedText->setPropertiesFrom(this);

Please tell me where the problem is, thanks!
ps. Since i've checked the wblockClone() and properties of the cloned one are the same as the origin one after i call the AcDbObject::wblockClone(). I think there should be no problem with dwgin/dwgout. Further, why it's not the case for deepClone() if the dwgin/dwgout is not properly implemented? Message was edited by: xiehui.luo
Message 4 of 8
Anonymous
in reply to: Anonymous

Remove the call to m_EmbeddedText->setPropertiesFrom(this). Everything
else should work, although I would not file the class name if you know it
will always be AcDbText. 🙂
--
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>
Message 5 of 8
Anonymous
in reply to: Anonymous

Owen Wengerd:
I tried by removing the call to m_EmbeddedText->setPropertiesFrom(this).But it made no difference.

Strange thing is that why it appeared to be the case just for wblockClone() while not for deepClone()?? Since i didn't implemet both these two functions??
Message 6 of 8
Anonymous
in reply to: Anonymous

I don't think the problem has anything to do with your implementation of
wblockClone. If the properties are set correctly during dwgIn(), then later
they are incorrect, somewhere your code is changing the properties. 🙂
--
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>


"xiehui.luo" wrote in message news:5957681@discussion.autodesk.com...
Owen Wengerd:
I tried by removing the call to m_EmbeddedText->setPropertiesFrom(this).But
it made no difference.

Strange thing is that why it appeared to be the case just for wblockClone()
while not for deepClone()?? Since i didn't implemet both these two
functions??
Message 7 of 8
Anonymous
in reply to: Anonymous

Owen Wengerd:
You are right that i didn't implement dwgin/dwgout properly. I forgot to deal with Xlate stage. So I added following lines to the dwgIn & dwgOut.Now it works perfect! Thank you!
********dwgIn()
if(pFiler->filerType()==AcDb::kIdXlateFiler){
AcDbHardPointerId objId;
ISOK(pFiler->readItem(&objId));
AOK(m_EmbeddedText->setTextStyle(objId));
return pFiler->filerStatus();
}

********dwgOut()
if(pFiler->filerType()==AcDb::kIdXlateFiler){
AcDbHardPointerId objId=m_EmbeddedText->textStyle();
ISOK(pFiler->writeItem(objId));
return pFiler->filerStatus();
}
Message 8 of 8
blackriver9
in reply to: Anonymous

I met the problem too. When I encapsulated a AcDbRotatedDimension object in my custom entity. The copy/paste opertation failed.

 

I processed relative id when pFiler->filerType()==AcDb::kIdXlateFiler as follow:

 

     AcDbHardPointerId DimstyleId;
     pFiler->readHardPointerId(&DimstyleId);
     pDim->setDimensionStyle(DimstyleId);
     pDim->setDimstyleData(DimstyleId);

     AcDbHardPointerId DimblockId;
     pFiler->readHardPointerId(&DimblockId);
     pDim->setDimBlockId(DimblockId);
     AcDbHardPointerId DimblkId;
     pFiler->readHardPointerId(&DimblkId);
     pDim->setDimblk(DimblkId);
     AcDbHardPointerId DimblkId1;
     pFiler->readHardPointerId(&DimblkId1);
     pDim->setDimblk1(DimblkId1);
     AcDbHardPointerId DimblkId2;
     pFiler->readHardPointerId(&DimblkId2);
     pDim->setDimblk2(DimblkId2);
     AcDbHardPointerId TextstyleId;
     pFiler->readHardPointerId(&TextstyleId);
     pDim->setDimtxsty(TextstyleId);

 

But still can't resolve the problem. Anyone can give me some help?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost