几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-05-06, 03:08 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】how to resize paper background

how to resize paper background?
how to resize paper background?
how to resize paper background to fit my drawing extends? now paper background is too small (see attachment paperbackground.jpg).
i try to use following code, but it does not work:
oddbobjectid id = m_pdd->createlayout(buffer, &idblock);
oddblayoutptr newdwglayout = id.safeopenobject(oddb::kforwrite);
makeoddbhandle(&drwlayout->getid());
// next line sets layout extends etc.
setlayoutdata(newdwglayout, drwlayout);
m_pdd->setcurrentlayout(odstring(buffer));
oddbplotsettingsvalidator* pmanager = this->plotsettingsvalidator();
pmanager->setusestandardscale(newdwglayout, true);
pmanager->setplottype(newdwglayout, oddbplotsettings::kextents);
pmanager->setstdscaletype(newdwglayout, oddbplotsettings::kscaletofit);
-jpa
attached images
hi,
i need more information from you. could you prepare small code example with file creation? or reproduce situation in mfcapp ?
last edited by sslezkin; 27th october 2006 at 05:22 amfff">.
you can reproduce "problem" if you replace odwriteex-example dbfiller::filldatabase -method with following code:
code:
oddbsetdwgcodepage(*pdb, (odcodepageid)0x0c);

oddbhandle seed(oduint64(10));
pdb->getoddbobjectid(seed, true);
// viewports
oddbviewporttableptr pviewports = pdb->getviewporttableid().safeopenobject(oddb::kforwrite);

oddbsymboltableiteratorptr piter(pviewports->newiterator());
piter->start();
bool usedefault = !piter->done();
oddbviewporttablerecordptr pviewport;
if (usedefault)
{
pviewport = piter->getrecordid().safeopenobject(oddb::kforwrite);
}
else
{
pviewport = oddbviewporttablerecord::createobject();
}

pviewport->setlowerleftcorner(odgepoint2d(0.0, 0.0));
pviewport->setupperrightcorner(odgepoint2d(1.0, 1.0));
pviewport->setsnapbase(odgepoint2d(0.0, 0.0));
pviewport->setsnapincrements(odgepoint2d(10.0, 10.0));
pviewport->setgridincrements(odgepoint2d(10.0, 10.0));
pviewport->setcenterpoint(odgepoint2d(243.0, 148.5));
pviewport->setheight(297.0);
pviewport->setwidth(297.0 * 1.63921);
pviewport->setlenslength(50.0);
pviewport->setviewdirection(odgevector3d(0, 0, 1));
pviewport->settarget(odgepoint3d(0,0,0));
pviewport->setucs(odgepoint3d(0,0,0),
odgevector3d(1,0,0),
odgevector3d(0,1,0));
pviewport->setucsperviewport(true);
pviewport->setviewtwist(0.0);
pviewport->setelevation(0.0);
pviewport->seticonenabled(true);
pviewport->setsnappair(2);
pviewport->setgridenabled(false);
pviewport->setsnapenabled(true);
pviewport->setsnapangle(0.0);
pviewport->setisometricsnapenabled(0);
if (usedefault)
{
piter->step();
usedefault = !piter->done();
}
else
{
pviewports->add(pviewport);
}

// layouts
//
oddblayoutptr dwgmodel;
bool model = false;
bool onlymodel = true;
int numobjects = 0;
oddbobjectid idblock;
oddbdictionaryptr dic;


odstring prefix("kd210920051217_x82hwfy2082348iowefiou2309wjx_");
dic = pdb->getnamedobjectsdictionaryid().openobject(oddb::kforread);
if (dic.get())
{
oddbdictionaryptr layouts = dic->getat("acad_layout", oddb::kforwrite);

if (layouts.get())
{
oddbdictionaryiteratorptr iter = layouts->newiterator();

int count = 1;

// rename "default" paperspace layouts and remove later
//
for (; !iter->done(); iter->next())
{
oddblayoutptr layout = iter->objectid().safeopenobject(oddb::kforwrite);

std(_tcout) << _t("\n") << layout->getlayoutname();
if (layout->getlayoutname() == odstring("model"))
{
dwgmodel = layout;
model = true; // modelspace layout found
}
else
{
odstring strtemp;
strtemp.format(odstring("%d"), count++);
strtemp = prefix + strtemp;
pdb->renamelayout(layout->getlayoutname(), strtemp);
}
}
}
}


// add "our" layouts.
//
if (dic.get())
{
// modelspace-layout
//
dwgmodel->setpsltscale(false);

dwgmodel->setlimmin(odgepoint2d(0.0, 0.0));
dwgmodel->setlimmax(odgepoint2d(297.0, 210.0));
dwgmodel->setinsbase(odgepoint3d(0.0, 0.0, 0.0));
dwgmodel->settaborder(1);
idblock = dwgmodel->getblocktablerecordid();

oddbblocktablerecordptr layoutblock = idblock.safeopenobject(oddb::kforwrite);

// add one circle to modelspace
//
oddbcircleptr pdwgcircle = oddbcircle::createobject();
pdwgcircle->setdatabasedefaults(pdb);
pdwgcircle->setnormal(odgevector3d(0,0,1));
pdwgcircle->setcenter(odgepoint3d(200.0, 160.0, 0.0));
pdwgcircle->setradius(22.0);
layoutblock->appendoddbentity(pdwgcircle);

// create one paperspace layout
//
oddbobjectid id = pdb->createlayout(_t("psone"), &idblock);
pdb->setcurrentlayout(_t("psone"));
oddblayoutptr newdwglayout = id.safeopenobject(oddb::kforwrite);
oddbblocktablerecordptr pslayoutblock = idblock.safeopenobject(oddb::kforwrite);

newdwglayout->setextmin(odgepoint3d(110.0, 50.0, 0.0));
newdwglayout->setextmax(odgepoint3d(440.0, 240.0, 0.0));

// resize overall viewport
//
oddbviewportptr pdwgviewportoverall = newdwglayout->overallvportid().safeopenobject(oddb::kforwrite);
pdwgviewportoverall->setheight(356);
pdwgviewportoverall->setwidth(728);
pdwgviewportoverall->setviewheight(356);
pdwgviewportoverall->setviewcenter(odgepoint2d(322.0, 152.0));
pdwgviewportoverall->seton();


// create one "floating" viewport
//
oddbviewportptr pdwgviewport;

pdwgviewport = oddbviewport::createobject();
pdwgviewport->setdatabasedefaults(pdb);
pdwgviewport->setwidth(330);
pdwgviewport->setheight(190);
pdwgviewport->setcenterpoint(odgepoint3d(275.0, 145.0, 0.0));
pdwgviewport->setviewcenter(odgepoint2d(200.0, 160.0));
pdwgviewport->setviewheight(44.0);
pdwgviewport->seton();
pdwgviewport->setviewtarget(odgepoint3d(0, 0, 0));
pdwgviewport->setviewdirection(odgevector3d(0, 0, 1));
pdwgviewport->setucsfollowmodeoff();
pdwgviewport->zoomextents();
pslayoutblock->appendoddbentity(pdwgviewport);
newdwglayout->setactiveviewportid(newdwglayout->overallvportid());
// remove "default" layouts
//
oddbdictionaryptr dic = pdb->getnamedobjectsdictionaryid().openobject(oddb::kforread);
if (dic.get())
{
oddbdictionaryptr layouts = dic->getat("acad_layout", oddb::kforwrite);

if (layouts.get())
{
oddbdictionaryiteratorptr iter = layouts->newiterator();

for (; !iter->done(); iter->next())
{
oddblayoutptr layout = iter->objectid().safeopenobject(oddb::kforwrite);
odstring strname;

if (layout->getlayoutname().getlength() > prefix.getlength())
{
strname = layout->getlayoutname().left(prefix.getlength());
if (strname.icompare(prefix) == 0)
pdb->deletelayout(layout->getlayoutname());
}

}
}
}
}
i cannot reproduce problem with current toolkit sources. could you tell me your used toolkit version ?
i have added
code:
oddbplotsettingsvalidator* pmanager = pdb->appservices()->plotsettingsvalidator();
pmanager->setusestandardscale(newdwglayout, true);
pmanager->setplottype(newdwglayout, oddbplotsettings::kextents);
pmanager->setplotcentered(newdwglayout, true);
pmanager->setstdscaletype(newdwglayout, oddbplotsettings::kscaletofit);
before '// remove "default" layouts' comment
ps : pmanager->setplotcentered(newdwglayout, true); is usefull too.
our toolkit version is 2.1.0 (vc8).
now it抯 works. i have to put oddbplotsettingsvalidator calls after everything is added to layout (before i call oddbplotsettingsvalidator just after layout was created).
before:
code:
oddbobjectid id = m_pdd->createlayout(buffer, &idblock);
newdwglayout = id.safeopenobject(oddb::kforwrite);
makeoddbhandle(&drwlayout->getid());
setlayoutdata(newdwglayout, drwlayout);
m_pdd->setcurrentlayout(odstring(buffer));
oddbplotsettingsvalidator* pmanager = this->plotsettingsvalidator();
pmanager->setusestandardscale(newdwglayout, true);
pmanager->setplottype(newdwglayout, oddbplotsettings::kextents);
pmanager->setplotcentered(newdwglayout, true);
pmanager->setstdscaletype(newdwglayout, oddbplotsettings::kscaletofit);
.. add objects to layout block (idblock) ..
now:
code:
oddbobjectid id = m_pdd->createlayout(buffer, &idblock);
newdwglayout = id.safeopenobject(oddb::kforwrite);
makeoddbhandle(&drwlayout->getid());
setlayoutdata(newdwglayout, drwlayout);
m_pdd->setcurrentlayout(odstring(buffer));
.. add objects to layout block (idblock) ..
oddbplotsettingsvalidator* pmanager = this->plotsettingsvalidator();
pmanager->setusestandardscale(newdwglayout, true);
pmanager->setplottype(newdwglayout, oddbplotsettings::kextents);
pmanager->setplotcentered(newdwglayout, true);
pmanager->setstdscaletype(newdwglayout, oddbplotsettings::kscaletofit);
thanks.
yes, i see. validator cannot calculate extents if there are no objects in the layout.
now there is another problem. oddbplotsettingsvalidator calls do not work (or there are not any visible differences, see dll_toolkit.jpg) if i build our application by using dll-version of toolkit (defining _toolkit_in_dll_ preprocessor definition and linking with dd_xx_dll 杔ib抯). when i use dd_vc8md_xx-lib抯 everything works fine (see no_dll_toolkit.jpg)
is that toolkit bug or do i miss something? dwgdirect version is 2.1.0
-jpa
attached images (100.6 kb, 7 views)
(112.1 kb, 7 views)

recalculate function is a database module functionality, so it is linked always with the application. differences can be only in available\unavailable plotsettingsvalidator.drx, but it take effect with not 'none' devices.
is it called in your dll project ?
:drxdynamiclinker()->loadapp(l"plotsettingsvalidator");
what is a device name in the layout ? try to set it to none and test again...
i add ?drxdynamiclinker()->loadapp(dd_t("plotsettingsvalidator"))?-call (after odinitialize 朿all) and now i try to set layout device name to 搉one?by using 損manager->setplotcfgname(newdwglayout, odstring("none"))? is that right method to do this?
but now paper background is even smaller than before (see dll_toolkit.jpg).
attached images (91.2 kb, 4 views)

please, test if dd_gs_dll linked to your application. also check result of pmanager->setstdscaletype. i think that you have missed some module. i have tested your code with write_ex_dll project. it was ok.
yes, dd_gs_dll.lib is linked with our application. we links following modules:
dd_br_dll.lib
dd_acisbuilder_dll.lib
dd_acisrenderer_dll.lib
dd_modelergeometry_dll.lib
dd_db_dll.lib
dd_ge_dll.lib
dd_root_dll.lib
dd_gi_dll.lib
dd_alloc_dll.lib
dd_gs_dll.lib
dd_spatialindex_dll.lib
plotsettingsvalidator_dll.lib
and same folder with executable is following dll and drx files:
dd_acisbuilder.dll
dd_acisrenderer.dll
dd_alloc.dll
dd_br.dll
dd_db.dll
dd_ge.dll
dd_gi.dll
dd_gs.dll
dd_root.dll
dd_spatialindex.dll
modelergeometry.drx
plotsettingsvalidator.drx
setstdscaletype return value is not 0 (eok) it is 5 (einvalidinput).
-jpa
it return einvalidinput if
1. pplotset is null
oddbplotsettingsvalidatorimpl::setstdscaletype(
oddbplotsettings* pplotset,
const stdscaletype scaletype)
2. exception appears inside. for example if application cannot load module.
writeex also uses dd_bmpexport.dll, winbitmap.gs, rasterprocessor.drx, dd_spatialindex.dll.
i think that you need dd_spatialindex.dll at least. it is used in extents calculation.
and what is linked libs list for lib version of your app ?
problem is solved. we have old version of dd_spatialindex.dll on our application folder. my mistake.
-jpa
good news.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】how to get the last used viewport of current layou yang686526 DirectDWG 0 2009-05-06 02:45 PM
【转帖】dwf background color yang686526 DirectDWG 0 2009-05-04 08:15 PM
【转帖】display drawing without background yang686526 DirectDWG 0 2009-05-04 07:50 PM
【转帖】changing paper space background color yang686526 DirectDWG 0 2009-05-04 05:44 PM
【转帖】background color yang686526 DirectDWG 0 2009-05-04 04:34 PM


所有的时间均为北京时间。 现在的时间是 12:58 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多