几何尺寸与公差论坛------致力于产品几何量公差标准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:25 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】how to validate oddbrasterimage scale

how to validate oddbrasterimage scale
how to validate oddbrasterimage scale
hi, all
to create oddbrasterimage, i tried these code.
oddbobjectid createraster( oddbdatabaseptr pdatabase, const char* rastername, const char* imagedefname, const odgepoint3d& point, double width, double height, double wsize, double hsize )
{
oddbblocktableptr ptable = pdatabase->getblocktableid().openobject();
oddbblocktablerecordptr precord = ptable->getat( "*model_space" ).openobject( oddb::kforwrite );
oddbdictionaryptr pimagedict;
oddbobjectid imagedictid = oddbrasterimagedef::imagedictionary( pdatabase );
if ( !imagedictid.isnull() )
pimagedict = imagedictid.safeopenobject( oddb::kforwrite );
if ( !pimagedict.get() )
pimagedict = oddbrasterimagedef::createimagedictionary( pdatabase ).safeopenobject( oddb::kforwrite );
oddbrasterimagedefptr pimagedef = oddbrasterimagedef::createobject();
oddbobjectid imagedefid = pimagedict->setat( imagedefname, pimagedef );
pimagedef->setsourcefilename( rastername );
pimagedef->setimage( odgirasterimagedesc::createobject( width, height ) );
pimagedef->load();
oddbrasterimageptr pimage = oddbrasterimage::createobject();
precord->appendoddbentity( pimage );
pimage->setdatabasedefaults( pdatabase );
pimage->setimagedefid( imagedefid );
pimage->setorientation( point, odgevector3d( wsize, 0, 0 ), odgevector3d( 0, hsize, 0 ) );
pimage->setdisplayopt( oddbrasterimage::kshow, true );
pimage->setdisplayopt( oddbrasterimage::kshowunaligned, true );
pimage->setbrightness( oduint8( 50 ) );
pimage->setcontrast( oduint8( 50 ) );
odgepoint2darray pts;
pts.push_back( odgepoint2d( 0, 0 ) );
pts.push_back( odgepoint2d( width, height ) );
pimage->setclipboundary( pts );
oddbrastervariablesptr prvars = oddbrastervariables: penrastervariables( pdatabase, oddb::kforwrite );
prvars->setuserscale( odgirasterimage::kmillimeter );
prvars->setimageframe( oddbrastervariables::kimageframeabove );
prvars->setimagequality( oddbrastervariables::kimagequalityhigh );
return pimage->objectid();
}
the problem is, until the database is saved to a dwg file, the image is displayed with non-scaled size.
after i save it, the image is displayed with scaled size.
i want the database keep unsaved until the user want it to.
should i call some other functions before display the oddbrasterimage to make the scale valid?
thank you for your help.
junichi yoshimoto

the problem is caused by bugs in dd 1.07. they are fixed already. before next release (a week or so) i suggest you a hack to bypass the bug.
the key moment of it is calling pimage()->imagesize() after imagedef is loaded. it will update image size cached in image entity. this also happens during saving to dwg or dxf.
see also other comments in code below:
oddbobjectid createraster( oddbdatabaseptr pdatabase, const char* rastername,
const char* imagedefname,
const odgepoint3d& point,
// it would be better to use image size in pixels
// from real raster file double width, double height,
double wsize, double hsize )
{
//oddbblocktableptr ptable = pdatabase->getblocktableid().openobject();
//oddbblocktablerecordptr precord = ptable->getat( "*model_space" ).openobject( oddb::kforwrite );
oddbblocktablerecordptr precord = pdatabase->getmodelspaceid().openobject( oddb::kforwrite );
oddbdictionaryptr pimagedict;
oddbobjectid imagedictid = oddbrasterimagedef::imagedictionary( pdatabase );
if ( !imagedictid.isnull() )
pimagedict = imagedictid.safeopenobject( oddb::kforwrite );
if ( !pimagedict.get() )
pimagedict = oddbrasterimagedef::createimagedictionary( pdatabase ).safeopenobject( oddb::kforwrite );
oddbrasterimagedefptr pimagedef = oddbrasterimagedef::createobject();
oddbobjectid imagedefid = pimagedict->setat( imagedefname, pimagedef );
pimagedef->setsourcefilename( rastername );
// next line is senseless
//pimagedef->setimage( odgirasterimagedesc::createobject(width, height ) );
pimagedef->load();
oddbrasterimageptr pimage = oddbrasterimage::createobject();
precord->appendoddbentity( pimage );
pimage->setdatabasedefaults( pdatabase );
pimage->setimagedefid( imagedefid );
pimage->setorientation( point, odgevector3d( wsize, 0, 0 ), odgevector3d( 0, hsize, 0 ) );
pimage->setdisplayopt( oddbrasterimage::kshow, true );
pimage->setdisplayopt( oddbrasterimage::kshowunaligned, true );
pimage->setbrightness( oduint8( 50 ) );
pimage->setcontrast( oduint8( 50 ) );
// setting clip boundary to whole image is not necessary in future releases
// but it is required to avoid 1.07 bug
odgepoint2darray pts;
pts.push_back( odgepoint2d::korigin );
pts.push_back( odgepoint2d(odgepoint2d::korigin + pimage->imagesize()));
pimage->setclipboundary( pts );
// raster variable exist as a single instance per database -
// no need in setting them creating each image
//oddbrastervariablesptr prvars = oddbrastervariables: penrastervariables( pdatabase, oddb::kforwrite );
//prvars->setuserscale( odgirasterimage::kmillimeter );
//prvars->setimageframe( oddbrastervariables::kimageframeabove );
//prvars->setimagequality( oddbrastervariables::kimagequalityhigh );
return pimage->objectid();
}
sergey slezkin

thank you, slezkin.
my problem is solved by the hack, and your comments are very suggestive.
junichi yoshimoto
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】byte data from a oddbrasterimage yang686526 DirectDWG 0 2009-05-04 05:14 PM
【转帖】adjusting texture bitmap yang686526 DirectDWG 0 2009-05-04 03:47 PM
【转帖】plotting to scale for templates yang686526 American standards 0 2009-04-29 09:17 PM
【转帖】drawing scale yang686526 American standards 0 2009-04-29 07:47 PM
【转帖】view scale yang686526 SolidWorks二次开发 0 2009-04-13 03:17 PM


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


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