Autodesk ObjectARX
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
encapsulat ed AcDbText object during wblockClon e()
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.
Re: encapsulat ed AcDbText object during wblockClon e()
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
You shouldn't have to implement wblockClone at all. Just implement
dwgIn/dwgOut properly.
--
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>>>
Re: encapsulat ed AcDbText object during wblockClon e()
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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(
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
Re: encapsulat ed AcDbText object during wblockClon e()
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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. <>>>
Re: encapsulat ed AcDbText object during wblockClon e()
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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??
Re: encapsulat ed AcDbText object during wblockClon e()
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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??>>
Re: encapsulat ed AcDbText object during wblockClon e()
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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();
}
Re: encapsulat ed AcDbText object during wblockClon e()
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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?
