![]() |
【转帖】exploding polyline in region
exploding polyline in region
exploding polyline in region hello, i am trying to explode a polyline contained inside a region using the explode command in dwgdirect. it appears that explode generates ellipses instead of the arcs and lines contained in the original polyline. is this normal behavior? thanks no this isn't normal. explode should generate arcs, not full ellipse. what toolkit version did you use? did you try it with last releases? could you please attach sample file ? attached sample drawing with polyline inside region hi alexander, i am attaching an autocad 2002 drawing with a region containing a polyline with two lines and three arcs. when exploding the region using autocad, you get the original entities. when exploding the region with dwglib v2.4 (the last release before 2.5.1), you get two lines and three ellipses. thanks attached files (19.4 kb, 4 views) last edited by robertpantangco@hotmail.com; 18th march 2008 at 10:49 pmfff">. reason: missing text hi, i have checked your file. the problem with explode of region is very old. it was fixed in 2.4.2. i have tested explode in 2.4.2 and 2.5.2 production. results are in attachment. attached images (29.3 kb, 8 views) hi alexander, actually i was using 2.4.2 released in october 2007. did you use explode() or explodegeometry()? nevertheless, i will wait for 2.5.2. thanks hi, i just call for explode command in the mfcapp. some time ago i got report about region explode bug. i dont remember the date, but it was fixed. btw : 2.5.2 production is available now. i dont know about member area, but it is already available from gridzone ftp. alexander, i have updated my files to 2.5.2 and the results are the same. if i explode a polyline containing arcs inside a region, the arcs are converted to elliptical arcs! if the polyline is not inside a region, the arcs are converted normally to regular arcs! i think that when you tested my sample drawing, you thought that the exploded arcs are regular arcs. if you would test it again, you will find that they are elliptical arcs. if this is so, the question remains, is this a bug? if it is by design, how do i convert the elliptical arcs to regular arcs? o! now i understand your question i thought that you asked about full ellipse generation insead elliptical arc, but you asked about elliptical arc instead circle arc. this isn't defect, but i can implement your suggestion later. there is no information inside region about original elements type. it stores arcs as some 'elliptical curve type'. so i can only redesign explode in the way of oddbarc creation instead oddbellipse, if major radius is equal to minor. but it is possible to create region from oddbellipse with equal radiuses and explode will generate oddbarc (or dbcircle for full arc). you got entities array after call of explode() or explodegeometry(). so you should iterate through array and replace all r=r oddbellipse to oddbarc or oddbcircle. hi alexander, thank you for your response. by the way, autocad returns circular arcs instead of elliptical arcs when exploding from a region so they must have some information or that it checks for equal radii. i am not sure how to replace oddbellipse with oddbarc in the array after testing if radius ratio = 1. do you have any sample code? my existing code is currently: odrxobjectptrarray array; entity->explode(array); // insert code to examine array and replace elliptical arcs with circular arcs entity->erase(); // crashes with invalid execution the application also crashes when doing the entity->erase() after explode with "invalid execution" on dbtransactimpl.cpp at line 288. any suggestion on how to fix it? happy easter! hi, please, check that objects\tables are opened for kwrite. line 288 is throw oderror(enotopenforwrite); code: odrxobjectptrarray entityset; oddbregionptr(pent)->explode(entityset); odrxobjectptrarray::iterator pit = entityset.begin(); odrxobjectptrarray::iterator ped = entityset.end(); while(pit != ped) { oddbellipseptr pel = oddbellipse::cast(*pit); if (!pel.isnull()) { if (odequal(pel->radiusratio(), 1.)) { odgepoint3d center; odgevector3d unitnormal, majoraxis; double radiusratio, startangle, endangle; pel->get(center, unitnormal, majoraxis, radiusratio, startangle, endangle); double angle = unitnormal.perpvector().angleto(pel->majoraxis(), unitnormal); oddbarcptr pc = oddbarc::createobject(); pc->setpropertiesfrom(pel); pc->setcenter(center); pc->setradius(majoraxis.length()); pc->setnormal(unitnormal); pc->setstartangle(startangle + angle); pc->setendangle(endangle + angle); *pit = pc; //pms->appendoddbentity(pc); } } ++pit; thanks a lot alexander. the code works except that the original extrusions for the arcs got changed from z-extrusion of 0 to -1. the start and end angles also were changed to correspond to the change of z-extrusion (group code 230). see output of list command following based on sample drawing sent earlier in this thread on one of the arcs: after autocad explode (it still corresponds to original polyline) arc layer: "0" space: model space handle = 34 center point, x= 6.2298 y= 3.3278 z= 0.0000 radius 2.7347 start angle 168 end angle 316 length 7.0449 after your code transformation: arc layer: "0" space: model space handle = 55 center point, x= 6.2298 y= 3.3278 z= 0.0000 radius 2.7347 extrusion direction relative to ucs: x= 0.0000 y= 0.0000 z= -1.0000 length 7.0449 total angle 148 the dxfout after your code replacing elliptical arc with circular arc now shows arc 5 55 330 1f 100 acdbentity 8 0 100 acdbcircle 10 -6.229767603933802 (note: change of sign) 20 3.32778604616263 30 0.0 40 2.734733019176701 210 0.0 220 0.0 230 -1.0 100 acdbarc 50 224.0245308389181 (note change of start angle) 51 11.62247665517381 (note change of end angle) 0 ----------------- future request: what would be nice if possible for a future version of the library is a dwgdirect function to convert any ellipse to a polyline. that is for those autocad applications whose pellipse variable was not set to 1. thanks again. last edited by robertpantangco@hotmail.com; 25th march 2008 at 09:13 pmfff">. reason: additional request |
adopting a dog
【隐藏帖】
|
unlock iphone 3g
【隐藏帖】
|
所有的时间均为北京时间。 现在的时间是 02:14 AM. |