• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk ObjectARX

    Reply
    Active Contributor
    Posts: 30
    Registered: ‎02-26-2008

    encapsulated AcDbText object during wblockClone()

    273 Views, 7 Replies
    06-13-2008 11:26 PM
    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.
    Please use plain text.
    *Owen Wengerd

    Re: encapsulated AcDbText object during wblockClone()

    06-13-2008 11:34 PM in reply to: xiehui.luo
    > 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. :smileyhappy:
    --
    Owen Wengerd
    President, ManuSoft <>
    VP Americas, CADLock, Inc. <>
    Please use plain text.
    Active Contributor
    Posts: 30
    Registered: ‎02-26-2008

    Re: encapsulated AcDbText object during wblockClone()

    06-13-2008 11:44 PM in reply to: xiehui.luo
    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
    Please use plain text.
    *Owen Wengerd

    Re: encapsulated AcDbText object during wblockClone()

    06-14-2008 06:37 AM in reply to: xiehui.luo
    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. :smileyhappy:
    --
    Owen Wengerd
    President, ManuSoft <>
    VP Americas, CADLock, Inc. <>
    Please use plain text.
    Active Contributor
    Posts: 30
    Registered: ‎02-26-2008

    Re: encapsulated AcDbText object during wblockClone()

    06-14-2008 11:56 PM in reply to: xiehui.luo
    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??
    Please use plain text.
    *Owen Wengerd

    Re: encapsulated AcDbText object during wblockClone()

    06-15-2008 07:00 AM in reply to: xiehui.luo
    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. :smileyhappy:
    --
    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??
    Please use plain text.
    Active Contributor
    Posts: 30
    Registered: ‎02-26-2008

    Re: encapsulated AcDbText object during wblockClone()

    06-16-2008 01:46 AM in reply to: xiehui.luo
    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();
    }
    Please use plain text.
    Active Member
    Posts: 6
    Registered: ‎05-31-2010

    Re: encapsulated AcDbText object during wblockClone()

    06-12-2011 07:54 AM in reply to: xiehui.luo

    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?

    

    Please use plain text.