高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】units, Converting
units, converting
units, converting
i'm having a bit of trouble doing scaling of a drawing generated by the opendesign api. presently, all of our drawings have been created/manipulated with the assumption that all drawings were using "inches".
my output drawing is fine, but i now want to convert said output drawing from inches to either cm or mm. i know i can "scale" the drawing by inserting it into another drawing and applying a scale factor (2.54/25.4) to the block reference, and then once i explode the block back to modelspace, all of the entities will have the proper scaling applied.
i'm just "confused", as i had assumed that setting the insunits of the source and target dwg would apply the translation for me.
psourcedb->setinsunits(oddb::kunitsinches);
psourcedb->setinsbase(odgepoint3d::korigin);
...
ptargetdb->setinsbase(odgepoint3d::korigin);
ptargetdb->setinsunits(oddb::kunitscentimeters);
i've even tried mucking with the measurement sys var, but i still have no luck when inserting one drawing into another, with different insunits defined.
i am able to scale the block reference, and get the entities in the "proper units", but i was hoping for a more intelligent insert that would handle scaling of the styles as well.
any additional input would be appreciated.
insunits is used only in some operations like inserting xref. in this case difference in insunits values of host drawing and xref will result in non-unit scale of block reference (representing xref insertion).
if you need to scale all contents of the drawing you can use
code:
oddbdatabase::insert(const odgematrix3d&, oddbdatabase*);
sergey slezkin
will
oddbdatabase::insert(const odgematrix3d&, oddbdatabase*);
scale lines as well, as presently i am doing:
code:
...
_pdb->setinsunits(oddb::kunitsinches);
_pdb->setinsbase(odgepoint3d::korigin);
_services.readfile(gettemplatefilebuf());
ptargetdb->initialize(oddb::measurementvalue::kmetric);
ptargetdb ->disableundorecording(true);
ptargetdb->setinsbase(odgepoint3d::korigin);
ptargetdb->setinsunits(oddb::kunitscentimeters);
odstring oname = _t("scaleddrawing");
oddbobjectid pchilddrawing = ptargetdb->insert(oname, _pdb,true);
_asserte(pchilddrawing.isvalid());
{
oddbblocktablerecordptr pmodelspaceblock = ptargetdb->getmodelspaceid().safeopenobject(oddb::kforwrite);
oddbblockreferenceptr pblkref = oddbblockreference::createobject();
pblkref->setblocktablerecord(pchilddrawing);
pblkref->setscalefactors(odgescale3d(2.54));
pmodelspaceblock->appendoddbentity(pblkref);
}
|