Problem with AcDbPolyline::convertTo() function

Problem with AcDbPolyline::convertTo() function

Anonymous
Not applicable
530 Views
6 Replies
Message 1 of 7

Problem with AcDbPolyline::convertTo() function

Anonymous
Not applicable
I want to convert a pline (type 2 or 1) to a 2dpline (type 0). I didn't find any sample on that...so what should be open for write... my algorithm is: - select an entity - chech it's type - if isKindOf AcDbPolyline - it should be converted to AcDb2dPolyline or, what type of pline is best to use? (plinetype); I want my users not to worry with plinetype, so a pline manipulation function must behave the same for all type of plines...Since I don't know how to iterate trough vertices of an AcDbPolyline, I want to use just AcDb2dPolyline (or 3d...). I hope I was clear enough... Thanks, ing. Vladimir Gora
0 Likes
531 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Well, I did it myself. If it can use...here is the source: /////////////////////////////////////////////// void TestPline() { int rc; ads_name en; AcGePoint3d pt; rc = acedEntSel("\nSelect a polyline: ", en, asDblArray(pt)); if (rc != RTNORM) { acutPrintf("\nNo entity selected..."); return; } AcDbObjectId eId, eId2; acdbGetObjectId(eId, en); AcDbObject *pObj; AcDbPolyline *pline2; AcDb2dPolyline *pline0 = new AcDb2dPolyline; acdbOpenObject(pObj, eId, AcDb::kForRead); if (pObj->isKindOf(AcDbPolyline::desc())) { pObj->close(); acdbGetObjectId(eId2, en); acdbOpenObject(pline2, eId2, AcDb::kForWrite); acdbOpenObject(pline0, eId, AcDb::kForWrite); pline2->convertTo(pline0, Adesk::kTrue); pline2->close(); pline0->close(); acutPrintf("\nSelected entity is an AcDbPolyline. \n ...but it was converted to 2d"); } else if (pObj->isKindOf(AcDb2dPolyline::desc())) { pObj->close(); acutPrintf("\nSelected entity is an AcDb2dPolyline."); return; } }
0 Likes
Message 3 of 7

Anonymous
Not applicable
Hi Vladimir,
in older AutoCAD versions there were only 2dplines and old applications 
use them. In a new application i would use lwplines. When you save a 
drawing in 14 or 13 format the plines are saved as 2dplines. When you 
then open it you can decide if you want them created as 2dplines ( set 
plinetype =0) or lwplines ( set plinetype =2).
Regards, Petra.

Vladimir Gora wrote:
> I want to convert a pline (type 2 or 1) to a 2dpline (type 0). I didn't find
> any sample on that...so what should be open for write...
> my algorithm is:
> - select an entity
> - chech it's type
> - if  isKindOf  AcDbPolyline
>    - it should be converted to AcDb2dPolyline
> 
> or, what type of pline is best to use? (plinetype); I want my users not to
> worry with plinetype,
> so a pline manipulation function must behave the same for all type of
> plines...Since I don't know how to
> iterate trough vertices of an AcDbPolyline, I want to use just
> AcDb2dPolyline (or 3d...). I hope I was clear enough...
> 
> Thanks, ing. Vladimir Gora
> 
> 
0 Likes
Message 4 of 7

Anonymous
Not applicable
Already know that, the problem is : if plinetype = 2 (or = 1) => an AcDbPolyline ( I CAN NOT ITERATE TROUGH IT'S VERTICES see AcDbPolyline class) if plinetype = 0 => AcDb2DPolyline (easy to work with) For example RECTANGLE creates an AcDbPolyline, it DOESN'T CARE if plinetype is 0,1 or 2. So, to work with plines, I want my users not to be consurned about plinetype variable, but if they draw an rectangle (for example), my function need to work with that rectangle as it'ld be an AcDb2DPolyline( or 2d) and NOT an AcDbPolyline. "pfluegge" wrote in message news:405fefdd$1_1@newsprd01... >
> Hi Vladimir,
> in older AutoCAD versions there were only 2dplines and old applications
> use them. In a new application i would use lwplines. When you save a
> drawing in 14 or 13 format the plines are saved as 2dplines. When you
> then open it you can decide if you want them created as 2dplines ( set
> plinetype =0) or lwplines ( set plinetype =2).
> Regards, Petra.
>
> Vladimir Gora wrote:
> > I want to convert a pline (type 2 or 1) to a 2dpline (type 0). I didn't
find
> > any sample on that...so what should be open for write...
> > my algorithm is:
> > - select an entity
> > - chech it's type
> > - if  isKindOf  AcDbPolyline
> >    - it should be converted to AcDb2dPolyline
> >
> > or, what type of pline is best to use? (plinetype); I want my users not
to
> > worry with plinetype,
> > so a pline manipulation function must behave the same for all type of
> > plines...Since I don't know how to
> > iterate trough vertices of an AcDbPolyline, I want to use just
> > AcDb2dPolyline (or 3d...). I hope I was clear enough...
> >
> > Thanks, ing. Vladimir Gora
> >
> >
> 
>
0 Likes
Message 5 of 7

Anonymous
Not applicable
Command: convert Enter type of objects to convert [Hatch/Polyline/All] :
0 Likes
Message 6 of 7

Anonymous
Not applicable
:(( dear michael, what sense programing ARX if you use comands?? Try returning to lisp. I was expecting more pertinent answers... "MiChaeL" wrote in message news:40606296_1@newsprd01... > Command: convert > Enter type of objects to convert [Hatch/Polyline/All] : > > >
0 Likes
Message 7 of 7

Anonymous
Not applicable
Iterating through vertices in an AcDbPolyline is pretty straightforward...


AcDbPolyline* pPline == NULL;

//
// Open or create pPline here...
//

AcGePoint3dArray pts;

for (int i = 0; i < pPline->numVerts(); i++)
{
AcGePoint3d pt;
pPline->getPointAt(i, pt);
pts.append(pt);
}


...or maybe I'm not understanding what your gettng at?
Andy F.
0 Likes