ObjectARX

Reply
Contributor
mgriesser
Posts: 15
Registered: ‎10-27-2010
Message 1 of 4 (150 Views)

wblockCloneObjects draworder

150 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

Distinguished Mentor
owenwengerd
Posts: 606
Registered: ‎08-06-2002
Message 2 of 4 (147 Views)

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
Contributor
mgriesser
Posts: 15
Registered: ‎10-27-2010
Message 3 of 4 (143 Views)

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.

 

ADN Support Specialist
Balaji_Ram
Posts: 666
Registered: ‎03-21-2011
Message 4 of 4 (115 Views)

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community