ObjectARX

ObjectARX

Reply
Contributor
15 Posts
0 Kudos
Registered: ‎10-27-2010
Post 1 of 4

wblockCloneObjects draworder

174 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
739 Posts
100 Kudos
Registered: ‎08-06-2002
Post 2 of 4

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
15 Posts
0 Kudos
Registered: ‎10-27-2010
Post 3 of 4

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
762 Posts
100 Kudos
Registered: ‎03-21-2011
Post 4 of 4

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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!