![]() |
【转帖】insert external block
insert external block
insert external block hi, is there a easy way to insert a block from external file (e.g. d:\block.dwg)? i am using dd1.12 with vc6 i am using the following code, it doesn't work. oddbobjectid id; oddbblocktableptr ptable = pdb->getblocktableid().safeopenobject(oddb::kforwrite) ; oddbblocktablerecordptr pentry = oddbblocktablerecord::createobject(); pentry->setpathname(blockpath); pentry->setname(blockname); // add the object to the table. id = ptable->add(pentry); //then i use this block id to insert into drawing .... thanks, alan see block handling functions in dwgdirect examples, dbfiller.cpp first add the block to the dwg file, then insert in the required location e.g. paperspace, modelspace or another block call 1. addblock() 2. addinsert() // adds a block with the specified name to the passed in database. note that // the table and newly created block are implicitly closed before this function returns. oddbobjectid dbfiller::addblock(oddbdatabase* pdb, const odstring& name) { oddbobjectid id; oddbblocktableptr ptable = pdb->getblocktableid().safeopenobject(oddb::kforwrite) ; oddbblocktablerecordptr pentry = oddbblocktablerecord::createobject(); // block must have a name before adding it to the table. pentry->setname(name); // add the object to the table. id = ptable->add(pentry); return id; } // adds a new insert entity to the passed in block record, returning // the object id of the newly created entity. note that all objects // created or opened by this function are implicitly closed before // the function returns. oddbobjectid dbfiller::addinsert( oddbdatabase* pdb, // owning database oddbblocktablerecord* pblock, // block to which insert will be added const oddbobjectid& blockid, // id of block to be inserted double xscale, // x scale for insertion double yscale) // x scale for insertion { oddbobjectid brefid; // create the new insert entity. oddbblockreferenceptr pblkref = oddbblockreference::createobject(); // add the entity to the parent block. brefid = pblock->appendoddbentity(pblkref); // set the remaining entity properties. pblkref->setblocktablerecord(blockid); pblkref->setscalefactors(odgescale3d(xscale, yscale, 1.0)); pblkref->setposition(odgepoint3d(6, 6, 0)); return brefid; } // end dbfiller::addinsert i have the block as an external drawing, e.g. block1.dwg. as you know, i can insert a block by browsing the block1.dwg using autocad. i am trying to find a way in dd1.12 to do the same thing. has anyone tried this? thanks, alan xref blocks (referencing external dwg file) are created in a bit different manner. see odwriteex sample. dbfiller.cpp: find dbfiller::addxref(... sergey slezkin thanks, it seems the one i was looking for. al |
所有的时间均为北京时间。 现在的时间是 06:37 AM. |