![]() |
【转帖】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 |
所有的时间均为北京时间。 现在的时间是 03:02 AM. |