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

    Autodesk ObjectARX

    Reply
    Contributor
    mgriesser
    Posts: 15
    Registered: ‎10-27-2010

    wblockCloneObjects draworder

    99 Views, 3 Replies
    11-08-2012 04:51 AM

    Hello!

     

    I am using wblockCloneObjects to load a certain block from an external dwg. The block consists of a hatch and some lines. In the external dwg it looks like this:

    1.png  The lines are on top of the hatch.

     

    After inserting it to the current dwg, the block looks like this:

     2.png

     

    The hatch is now on top of the lines. Is this a know side-effect of wblockCloneObjects?

     

     

    Regards

    Markus

    Please use plain text.
    Mentor
    Posts: 239
    Registered: ‎08-06-2002

    Re: wblockCloneObjects draworder

    11-08-2012 07:24 AM in reply to: mgriesser

    Are you cloning the AcDbBlockTableRecord object? if so, I would expect the draworder information to get cloned as well. On the other hand, if you clone only the entities owned by the block table record, then I would expect the results you show.

    --
    Owen Wengerd
    ManuSoft
    Please use plain text.
    Contributor
    mgriesser
    Posts: 15
    Registered: ‎10-27-2010

    Re: wblockCloneObjects draworder

    11-08-2012 07:36 AM in reply to: owenwengerd

    owenwengerd wrote:

    Are you cloning the AcDbBlockTableRecord object?


     

    Yes. I search the block in the external blocktable, and pass its id wblockCloneObjects.

     

    Please use plain text.
    ADN Support Specialist
    Balaji_Ram
    Posts: 343
    Registered: ‎03-21-2011

    Re: wblockCloneObjects draworder

    11-20-2012 01:59 AM in reply to: mgriesser

    Hi Markus,

     

    I tried to reproduce this behavior but it seems to be working ok on AutoCAD 2011.

    Here is the code snippet and the drawing that I am using to test.

     

    To try this :

    1) copy the attached Test.dwg to c:\Temp

    2) Run the command to clone the "Test1" and "Test2" blocks from Test.dwg to the current drawing

    3) Insert "Test1" and "Test2" blocks

     

    Test1 and Test2 have different draw orders for the hatch and a circle which are being cloned correctly.

     

    Acad::ErrorStatus es;
    TCHAR fullpath[_MAX_PATH];
    
    int ret = acedFindFile( ACRX_T("C:\\Temp\\Test.dwg"), fullpath );
    if ( ret != RTNORM )
    	  return;
    
    AcDbDatabase *pSrcDb = new AcDbDatabase( false, false );
    es = pSrcDb->readDwgFile( fullpath, _SH_DENYNO );
    if ( es != Acad::eOk )
    {
    	  acutPrintf( _T("\nCan not open file.") );
    	  delete pSrcDb;
    	  return;
    }
    
    AcApDocument *pActiveDoc = acDocManager->mdiActiveDocument();
    AcDbDatabase *pDestDb    = pActiveDoc->database();
    
    AcDbObjectIdArray objIds2Copy;
    AcDbBlockTable *pBlockTable;
    
    es = pSrcDb->getSymbolTable(pBlockTable, AcDb::kForRead);
    AcDbObjectId recordId = AcDbObjectId::kNull;
    
    es = pBlockTable->getAt(ACRX_T("TEST1"), recordId, AcDb::kForRead);
    objIds2Copy.append(recordId); 
    
    es = pBlockTable->getAt(ACRX_T("TEST2"), recordId, AcDb::kForRead);
    objIds2Copy.append(recordId); 
    
    es = pBlockTable->close();
    
    AcDbIdMapping idMap;
    es = pSrcDb->wblockCloneObjects(objIds2Copy, acdbSymUtil()->blockModelSpaceId(pDestDb), idMap, AcDb::kDrcReplace);
    if(es == Acad::ErrorStatus::eOk)
    	acutPrintf( _T("\nCloned the block to the current drawing.") );
    else
    	acutPrintf( _T("\nFailed to clone the block to the current drawing.") );
    
    delete pSrcDb;

     



    Balaji
    Developer Technical Services
    Autodesk Developer Network

    Please use plain text.