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

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】inserting images into dxfdwg (http://www.dimcax.com/hust/showthread.php?t=16897)

yang686526 2009-05-06 03:59 PM

【转帖】inserting images into dxfdwg
 
inserting images into dxf/dwg
inserting images into dxf/dwg
hi,
i'd like to insert images into dxf file. i saw examples and i think that did everything like there, but when i open the dxf file in autocad images are't displayed . my code is similar to this:
code:
oddbobjectid imagedictid = oddbrasterimagedef::createimagedictionary(m_pdxfdatabase);
oddbdictionaryptr pimagedict = imagedictid.safeopenobject(oddb::kforwrite);
odstring key = "asdasd";

oddbobjectid imagedefid = pimagedict->getat(key);
if (imagedefid.isnull())
{
odrxmoduleptr pmodule = ::odrxdynamiclinker()->loadmodule("rxrasterservices.drx");
odgirasterimageptr prasterimage = ((odrxrasterservicesptr)pmodule)->loadrasterimage(m_imagename);

oddbrasterimagedefptr pimagedef = oddbrasterimagedef::createobject();
imagedefid = pimagedict->setat(key, pimagedef);
pimagedef->setsourcefilename(m_imagename);
pimagedef->setimage(prasterimage);
if(!prasterimage.isnull())
{
nheight = prasterimage->pixelheight();
nwidth = prasterimage->pixelwidth();
}
oddbrastervariablesptr prvars = oddbrastervariables::openrastervariables(m_pdxfdatabase, oddb::kforwrite);
if (odgirasterimage::knone == prvars->userscale())
{
prvars->setuserscale(odgirasterimage::kmillimeter);
prvars->setimageframe(oddbrastervariables::kimageframeabove);
prvars->setimagequality(oddbrastervariables::kimagequalityhigh);
}
}
oddbrasterimageptr pdbraster = oddbrasterimage::createobject();
blockrecord->appendoddbentity(pdbraster);
pdbraster->setimagedefid(imagedefid);
odgepoint3d pt(ptx, pty, 0.0);
pdbraster->setorientation(pt, odgevector3d(50, 0, 0), odgevector3d(0, 50, 0));
pdbraster->setdisplayopt(oddbrasterimage::kshow, true);
pdbraster->setdisplayopt(oddbrasterimage::kshowunaligned, true);
the image is loaded. its width and height is correct. the image file is placed in the same directory where the dxf file is.
should i do something more ?
thanks
marcin
attached images
you saved absolute path to the image file: "c:\image33.bmp"
autocad fails to find it in this location. if file path is changed to "image33.bmp" it shows the image having found the file in the same folder as dwg.
sergey slezkin


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