高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】relating font types to te
relating font types to text
relating font types to text
hello,
i am trying to read a dwg file with multiple font types described in it. i could get the font file names and the font face from the database using the oddbtextstyletableptr. i wanted to know if there is a way to corelate these font types to the entities (which can be either text, mtext or rtext) in the drawing
thanks.
amit
hi,
i'm not sure i understand what you mean. if you mean some built-in way to find these entities - then answer is no.
oddbtext, oddbmtext references a test style (oddbtextstyletablerecord). you can get text style id by textstyle() method.
oddbtextstyletablerecord stores font information.
oddbmtext is also able to switch font inside it using special character sequence like "abc{farial}bcd
sergey slezkin
problems about cloning a text style
using dwgdirect 1.14.01, i am trying to place a series of ordered marks/flags along a path. my program (a tailored odamfcapp) is meant to load a dwg source file as an xref, and place a block reference in the target file when needed.
one of the entities of the flag file is an attribute definition; that will be properly substituted with an attribute, with custom text, belonging to each block reference.
however, i haven't yet managed deep cloning the text style of the attribute definition: the target file gets a textstyletablerecord with proper names, but with fake properties. performing a wblockcloneobjects makes the same result, so i guess i miss something.
the code follows:
code:
oddbtextstyletableptr targettst = targetb->database()->gettextstyletableid().safeopenobject(oddb::kforwrite);
oddbtextstyletablerecordptr sourcets = attrdef->textstyle().safeopenobject();
oddbtextstyletablerecordptr targetts = oddbtextstyletablerecord::createobject();
oddbidmappingptr map2clone = oddbidmapping::createobject();
oddbobjectidarray obj2clone;
obj2clone.append(sourcets->objectid());
map2clone->setdestdb(targetb->database());
map2clone->assign(oddbidpair(sourcets->objectid(), targetts->objectid()));
targetts->setname(flagb->getname());
targettst->add(targetts);
flagb->database()->deepcloneobjects(obj2clone, targettst->objectid(), *map2clone);
where
targetb is the target file model space block
attrdef is the attribute definition whose text style is to be retrieved
flagb is the database containing the drawing of the flag
attached you find the three source flag files (ac3, kpa and rkp, created with 2004 lt) and a target file made from scratch, intended to be read from autocad 2006 (odamfc1).
thanks in advance for your help.
mirko pontrelli.
attached files (44.7 kb, 2 views)
(27.0 kb, 2 views)
(29.2 kb, 2 views)
(43.2 kb, 2 views)
deepcloneobjects is intended to be used within the same database. to clone objects between different databases wblockcloneobjects() should be used.
you need not create tablerecord in destination database.
code:
oddbdatabaseptr psourcedb = flagb->database();
oddbdatabaseptr pdestdb = targetb->database();
oddbobjectid idtargettst = pdestdb->gettextstyletableid();
oddbobjectid idsourcets = attrdef->textstyle();
oddbidmappingptr map2clone = oddbidmapping::createobject();
map2clone->setdestdb(pdestdb);
oddbobjectidarray obj2clone;
obj2clone.append(idsourcets);
psourcedb->wblockcloneobjects(obj2clone, idtargettst, *map2clone, cloning_type);
also take care to use appropriate cloning_type defining how duplicate names should be handled.
sergey slezkin
cool. i also tried with wblockcloneobjects without succeeding. i guess i didn't manage because i defined an empty target text style record and tried to copy the source over it.
i should have missed something in the documentation and in the forums; however i thought the difference between the two methods was the shallow/deep types of cloning.
thanks, mr. slezkin.
mirko pontrelli.
|