几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】assert exception in adding a new linetypetable record (http://www.dimcax.com/hust/showthread.php?t=15137)

yang686526 2009-05-04 04:13 PM

【转帖】assert exception in adding a new linetypetable record
 
assert exception in adding a new linetypetable record
assert exception in adding a new linetypetable record
1. i want to add a new linetypetable record in one oddbdatabase to another one, the main code is as follows:
//////////////
oddblayertableptr players = c_pdb->getlayertableid().safeopenobject();
players->generateusagedata();
oddblinetypetableptr m_dhfrom = (oddblinetypetableptr)c_pdb->getlinetypetableid().safeopenobject(oddb::kforwri te);
//
for(int j=0;j<m_amaptolayer.getsize();j++)
{
oddbobjectid newltype;
oddbsymboltableiteratorptr piter = players->newiterator();
int i = 0;
for (piter->start(); !piter->done(); piter->step(), ++i)
{
oddblayertablerecordptr player = piter->getrecordid().safeopenobject(oddb::kforwrite);
if (player->getname() == m_amapfromlayer[j].name)
{
player->setname(m_amaptolayer[j].name);
player->setcolorindex((odint16)m_amaptolayer[j].color);
player->setlineweight((oddb::lineweight)m_amaptolayer[j].lineweight);
if (!m_dhfrom->has(m_amaptolayer[j].linetypename))
{ //to add a new record
oddblinetypetablerecordptr pltype = m_amaptolayer[j].linetypeobjhandle.safeopenobject();
newltype = m_dhfrom->add(pltype);
player->setlinetypeobjectid(newltype);
}
else
{
player->setlinetypeobjectid(getltypeid(m_amaptolayer[j].linetypename, false));
}
break;
}
}
}
try
{
c_pdb->writefile(theapp.m_fpath, c_pdb->originalfiletype(), c_pdb->originalfileversion());
}
catch(oderror& /*e*/)
{
}
catch(userbreak)
{
afxmessagebox("failed to save:" + theapp.m_fpath);
return ;
}
cstring strtemp;
strtemp = theapp.m_fpath + "is saved.";
afxmessagebox(strtemp, mb_ok|mb_iconinformation);
return;
/////////////
at runtime in debug mode, there is an assert exception at the code line "newltype = m_dhfrom->add(pltype);". the record is failed to be add. why? how to resolve it?
2. when i save the file, it is ok. but the size of saved file is less than 2kb(the origional one is more than 100kb). what's the wrong? the file is opend by using:
c_pdb = theapp.readfile(lpszpathname, false, false);
thanks for any answer.
i have resolved it now.


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