查看单个帖子
旧 2009-05-06, 08:15 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】oddbtable exception when trying to create table with 1 colu

oddbtable: exception when trying to create table with 1 colu
oddbtable: exception when trying to create table with 1 column
hi,
my dwgdirect version is 2.3.1. i am generating a dxf file for acad version 2004.
i am using the addtable() code from the examples (odwriteex/dbfiller.cpp) to draw a table.
drawing a table with 2 columns and 2 rows works perfectly. but when i set the number of columns to 1, then the function pacadtable->setnumcolumns(ncols)fff"> throws an oderror "invalid input" exception.
creating a table with only 1 column in autocad works. is there a bug related to this in dwgdirect?
the code i use:
int cdwgwrap::addtable(bool isrelative, int layid, double xpos, double ypos,
int ncols, int nrows, double height, double width,
double textsize, int textstyid, int cellalign) {
oddbobjectid id = dbmanager::getinstance()->getdb()->getmodelspaceid();
oddbblocktablerecordptr precord = id.safeopenobject(oddb::kforwrite);
/************************************************** ********************/
/* get the lower-left corner and center of the box */
/************************************************** ********************/
odgepoint3d point;
odgepoint3d center;
if(isrelative) {
xpos = layoutcornerpnt.x + layoutwidth*xpos;
ypos = layoutcornerpnt.y + layoutheight*ypos;
height = layoutheight*height;
width = layoutwidth*width;
}
point.x = xpos;
point.y = ypos + height;
point.z = 0.0;
center = point + odgevector3d( 0.5*width, 0.5*height, 0.0 );
/************************************************** ********************/
/* create the table */
/************************************************** ********************/
oddbtableptr pacadtable = oddbtable::createobject();
oddbobjectid tableid = precord->appendoddbentity(pacadtable);
/************************************************** ********************/
/* set the parameters */
/************************************************** ********************/
pacadtable->setdatabasedefaults(precord->database());
pacadtable->setnumcolumns(ncols);
pacadtable->setnumrows(nrows);
pacadtable->setheight(height);
pacadtable->setwidth(width);
pacadtable->generatelayout();
pacadtable->setcolumnwidth(width/pacadtable->numcolumns());
pacadtable->setrowheight(height/pacadtable->numrows());
oddb::lineweight linewt = oddb::lineweight(5);
pacadtable->setgridlineweight(linewt, oddb::khorzinside, oddb::kdatarow);
pacadtable->setgridlineweight(linewt, oddb::kvertinside, oddb::kdatarow);
pacadtable->setposition(point);
if(textstyid > 0)
pacadtable->settextstyle(dbmanager::getinstance()->getobjectidarray()->at(textstyid));
pacadtable->settextheight(textsize, oddb::kallrows);
pacadtable->setalignment(oddb::cellalignment(cellalign), oddb::kallrows);
pacadtable->setlayer(dbmanager::getinstance()->getobjectidarray()->at(layid));
return dbmanager::getinstance()->getobjectidarray()->append(tableid);
}
thanks a lot for any help,
christoph
hello christoph,
it is really bug in dwgdirect. it will be fixed in next release. thank you for report. as work around - table is created (oddbtable::createobject(); ) with 1 row and 1 column so you don't need to set this values.
best regards,
sergey z.
hi sergey,
your workaround works. thanks a lot.
christoph
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)