高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】move model space entities to a layou
move model space entities to a layout
move model space entities to a layout
i'm looking for the best way to move model space entities to a layout.
can this be done with deepclone or deepcloneobjects?
also, do i have to iterate the ms block table record, or can i just clone the entire thing into the layout?
thanks,
mike
also, does oda have a similar method to objectarx's acdbblocktablerecord::assumeownershipof() method?
thanks,
mike
no, we have no assumeownershipof() method. (we will add it in 2.6: )
currently you should use deepcloneobjects().
vladimir
last edited by vkalinin; 7th may 2008 at 05:16 amfff">.
thank you vladimir.
also, would setownerid() also be an option to set the owner to the layout blocktablerecord?
thanks,
mike
owner of any block table record is always a block table.
what do you mean?
vladimir
quote:
originally posted by wvk
owner of any block table record is always a block table.
what do you mean?
i was wondering if i could change the owner from the modelspace blocktablerecord to the layout's blocktablerecord with setownerid(). would this have the same effect as the deepcloneobjects?
deepcloneobjects would create copies of the objects correct? while setownerid would "move" the objects to a new owner?
is there an example of iterating modelspace and copying them to a layout?
thanks,
mike
quote:
originally posted by mike caruso
i was wondering if i could change the owner from the modelspace blocktablerecord to the layout's blocktablerecord with setownerid(). would this have the same effect as the deepcloneobjects?
deepcloneobjects would create copies of the objects correct? while setownerid would "move" the objects to a new owner?
no, changing the owner is not enough - entities should be removed from one container and put into another, which is impossible via current blocktablerecord interface.
quote:
is there an example of iterating modelspace and copying them to a layout?
see e.g. examples\excustobjs\drxdebugcmds.cpp, 2582-2624 _deepclone1_func()
it is quite trivial - while iterating modelspace, append object ids to an array, then call deepcloneobjects, passing layout id as a new owner.
vladimir
thank you very much for your help.
mike
hello vladimir,
i am getting an error about an invalid owner object when trying the deepcloneobjects(). could you advise on what may be the problem?
code:
// get the drawing db pointer
oddbobjectid idmodelspace = pdb->getmodelspaceid();
// get modelspace and iterator
oddbblocktablerecordptr pmodelspace = idmodelspace.safeopenobject();
oddbobjectiteratorptr pit = pmodelspace->newiterator();
// create new layout
oddblayoutmanagerptr plmgr = svcs.layoutmanager();
oddbobjectid playoutid = plmgr->createlayout(pdb, strlayoutname);
// create id map
oddbidmappingptr pmap = oddbidmapping::createobject();
pmap->setdestdb(pdb);
// grab all object id's from modelspace
oddbobjectidarray ids;
for (pit->start(); !pit->done(); pit->step())
{
ids.push_back(pit->objectid());
}
pmodelspace.release();
// copy to paperspace
pdb->deepcloneobjects(ids, playoutid, *pmap); // fails here
// save drawing
odwrfilebuf fb("test.dwg
pdb->writefile(&fb, oddb::kdwg, oddb::vac21, false);
you are trying to put entities to the layout object, not to the layout block.
createlayout() function has 3-rd parameter: oddbobjectid* pblocktablerecid.
this is an object id of the block table record corresponding to the newly created layout. it will be the owner of the cloned objects in your case.
vladimir
|