![]() |
【转帖】oddbellipse problem
oddbellipse problem
oddbellipse problem hi, i use the oddbellipse object to create elliptical arcs. i set all the data with the "set" method from oddbellipse. but i have a problem with the start and end angle. when i open my dwg file, the start an end angles of elliptical arcs are not correct. in the old opendwg i used the start and end param instead of the angles, but if i try to set the start and end param in dwgdirect, the loading of the dwg file fails. does anybody know how to set the start and end param, or what may be wrong with my start and end angles? thanks for any help. could you please post sample code reproducing the problem, with all numeric values (sample of set method creating "invalid" ellipse and ellipse, which fails to load) sincerely yours, george udov hi, sorry for the delay, but here is some more information. numerical values: majoraxis: 3.5 / 6.06 / 0 minoraxis: -3.5 / 2.02 / 0 normal: 0 / 0 / 1 center: 0 / 0 / 0 ratio: 0.577 startangle: 329 degree endangle: 210 degree code with dwgdirect: oddbellipseptr ent=oddbellipse::createobject(); oddbblocktablerecordptr modelspace=database->getmodelspaceid().safeopenobject(oddb::kforwrite) ; modelspace->appendoddbentity(ent); ell->set(center,normal,majoraxis,ratio,startangle*pi/180.0,endangle*pi/180); this creates a different elliptical arc as the code from opendwg libraries. the following code causes a crash when loading the dwg file in acad: ell->set(center,normal,majoraxis,ratio); ell->setstartparam(startangle*pi/180.0); ell->setendparam(endangle*pi/180.0); any ideas? all these methods works just like objectarx's ones. i can't reproduce any issues with such input data on release 1.10 update 2. also i can't reproduce autocad's crash. which version of autocad crashes? you should pass angles to oddbellipse::set method. angles are calculated from major axis around normal. you should pass parameters to oddbellipse::setstartparam and oddbellipse::setendparam methods. parameters are calculated from major axis around normal too. sincerely yours, george udov have the same ellipse problem was this issue ever resolved? i am having the same or a similar problem. we use this code to produce an ellipse: oddbellipseptr pellipse = oddbellipse::createobject(); odgepoint3d center(p->pt0[0], p->pt0[1], p->pt0[2]); oddbobjectid id = pblock->appendoddbentity(pellipse); odgevector3d normal_vector(0,0,1), major; major.x = p->pt1offset[0]; major.y = p->pt1offset[1]; major.z = p->pt1offset[2]; pellipse->set(center, normal_vector, major, p->minortomajorratio, p->startparam, p->endparam); with center of (0,0,0), major of (2.5,0,0) ratio of 0.4, startparam of 1.19 and endparam of 5.09 we end up with a dxf 41 entry of 1.41 and 42 entry of 4.87 instead of the expected 1.19 and 5.09. thanks, barry add the following code after the set method, that worked for me (starting with dwgf direct 1.11) pellipse->setstartparam(p->startparam); pellipse->setendparam(p->endparam); i cannot explain why, but the results are correct. thanks for the tip quote: originally posted by stefan waldner add the following code after the set method, that worked for me (starting with dwgf direct 1.11) pellipse->setstartparam(p->startparam); pellipse->setendparam(p->endparam); i cannot explain why, but the results are correct. that worked like a charm. thanks alot. oddbellipse::set() method expects not start and end parameters but angles. ellipse parametrization is: point = center + major_vector * cos(param) + minor_vector * sin(param) sergey slezkin the above posted code is working fine in most of the cases but in this specific case this code is not working an converting a normal elliptical arc to a closed elliptical arc, please check the code sds_point centerpoint; pellipse->get_10(centerpoint); sds_point majaxis; pellipse->get_11(majaxis); double axisratio; pellipse->get_40(&axisratio); double startparam, endparam; pellipse->get_41(&startparam); pellipse->get_42(&endparam); sds_point extrusion; pellipse->get_210(extrusion); poddbellipse->set(odgepoint3d(centerpoint[0], centerpoint[1], centerpoint[2]), odgevector3d(extrusion[0],extrusion[1], extrusion[2]), odgevector3d(majaxis[0], majaxis[1], majaxis[2]), axisratio, startparam, endparam); please also check the file attached files (28.1 kb, 3 views) this is in continuation of the above post...... ****please this code to the code written above. poddbellipse->setcenter(odgepoint3d(centerpoint[0], centerpoint[1], centerpoint[2])); poddbellipse->setradiusratio(axisratio); poddbellipse->setstartparam(startparam); ..................(1) poddbellipse->setendparam(endparam);.......................(2 ) if i comment the line (1) & (2) then this specific ellipse displayed fine, but then normal ellipse goes hayward. ........plz tell me if i m making mistakes, or anything i have to add......... ........thanks in advanced ellipse angles and parameters are not the same. set() expects angles and setstartparam() and setendparam() - parameters. in your file both start and end parameters are larger than 2 pi. setstartparam() and setendparam() implementation in dd follows arx description of these methods (below) as a result 2 pi is subtracted from start parameter if it's larger than 2 pi but not from end parameter. as a result ellipse looks like closed. ---------------------------------- acad::errorstatus setstartparam( double startparam); startparam input new start parameter for the ellipse sets startparam to be the new start parameter of the ellipse. if startparam is larger than the current end parameter, then it is decremented in steps of 2pi until it is less than the current end parameter. ---------------------------------- acad::errorstatus setendparam( double endparam); endparam input new end parameter for the ellipse sets endparam to be the new end parameter of the ellipse. if endparam is less than the current start parameter, then it is incremented in steps of 2pi until it is larger than the current start parameter. sergey slezkin thanks a lot, it was really nice info,, |
所有的时间均为北京时间。 现在的时间是 10:49 AM. |