Message 1 of 2
Insert block from another database
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am new to ObjectARX so please bear with me if I ask something already answered.
Now I like to insert a block from another drawing(source drawing) in current drawing. I would not like to insert the whole drawing and delete all others. now from the sample I found in this newsgroup/sample/google,
1. use readDwgFile to read source drawing.
2. pDwgBlockTbl->getAt("TPLT-DR", pBlkTblRcd, AcDb::kForRead ) to get the objectid of block
3. pBlkTblRcd->getBlockReferenceIds( list );
4. wblock to a temp database
AcDbDatabase *pCurrentDB = acdbHostApplicationServices()->workingDatabase();
es = pDwg->wblock(pTempDb, list, AcGePoint3d(0,0,0));
5. insert in current drawing
es = pCurrentDB->insert(AcGeMatrix3d::kIdentity, pTempDb);
now I have 2 problem, if there are more than 1 INSERT in source drawing, then all of them will insert in current drawing. I fix by remove all but 1 left in AcDbObjectIdArray list;
2nd if there is no INSERT for that block in source drawing. only block definition exist in blocktable. How I can make it work.
I tried:
AcDbBlockReference *pWindowBlock =new AcDbBlockReference(point, blockId);
It crash and I understand it try to create a new blockReference in current drawing which does not exist the definition yet.
How I can make this work?
actually block definition is all I want. so how to copy a block definition from one database to another if there is no instance (INSERT) in source database?
Thank you,
Wes
AutoCAD 2004, Visual Studio 2002, Windows XP pro
I am new to ObjectARX so please bear with me if I ask something already answered.
Now I like to insert a block from another drawing(source drawing) in current drawing. I would not like to insert the whole drawing and delete all others. now from the sample I found in this newsgroup/sample/google,
1. use readDwgFile to read source drawing.
2. pDwgBlockTbl->getAt("TPLT-DR", pBlkTblRcd, AcDb::kForRead ) to get the objectid of block
3. pBlkTblRcd->getBlockReferenceIds( list );
4. wblock to a temp database
AcDbDatabase *pCurrentDB = acdbHostApplicationServices()->workingDatabase();
es = pDwg->wblock(pTempDb, list, AcGePoint3d(0,0,0));
5. insert in current drawing
es = pCurrentDB->insert(AcGeMatrix3d::kIdentity, pTempDb);
now I have 2 problem, if there are more than 1 INSERT in source drawing, then all of them will insert in current drawing. I fix by remove all but 1 left in AcDbObjectIdArray list;
2nd if there is no INSERT for that block in source drawing. only block definition exist in blocktable. How I can make it work.
I tried:
AcDbBlockReference *pWindowBlock =new AcDbBlockReference(point, blockId);
It crash and I understand it try to create a new blockReference in current drawing which does not exist the definition yet.
How I can make this work?
actually block definition is all I want. so how to copy a block definition from one database to another if there is no instance (INSERT) in source database?
Thank you,
Wes
AutoCAD 2004, Visual Studio 2002, Windows XP pro
Windows 10 64 bit, AutoCAD (ACA, Map) 2023