Problem Loop Pline vertex!

Problem Loop Pline vertex!

D_D_K
Advocate Advocate
658 Views
2 Replies
Message 1 of 3

Problem Loop Pline vertex!

D_D_K
Advocate
Advocate

Hi,  I am trying to loop each vertex in pline by using this code but when i try converting Acdbobject to acdbpolyline2D like .Net  pPline = (PLINE2D*)obj ; however ObjectIterator did not seem to work, so I was unable to loop though objectIterator.

Where did I go wrong, please help

Here is the code I use:

 

extern void Loopvertex()
{
ADSN adsEnt; ADSPT adspt;
acedEntSel(_T("Let select pline"), adsEnt, adspt);
ID plineid;
acdbGetObjectId(plineid, adsEnt);
PLINE2D
pPline; Objectobj; acdbOpenObject(objplineId, fR); //Read pline return Acdbobject pPline = (PLINE2D*)obj; //Convert Acdbobject to Acdb2dPline ObjectIpVertIter = pPline->vertexIterator(); // get ObjectIterator but failed
'continue code
}

Thanks in advance!

 

 

 

 

 

0 Likes
Accepted solutions (1)
659 Views
2 Replies
Replies (2)
Message 2 of 3

Alexander.Rivilis
Mentor
Mentor
Accepted solution

@D_D_K wrote:

Hi,  I am trying to loop each vertex in pline by using this code but when i try converting Acdbobject to acdbpolyline2D like .Net  pPline = (PLINE2D*)obj ; however ObjectIterator did not seem to work, so I was unable to loop though objectIterator.

Where did I go wrong, please help

Here is the code I use:

 

extern void Loopvertex()
{
ADSN adsEnt; ADSPT adspt;
acedEntSel(_T("Let select pline"), adsEnt, adspt);
ID plineid;
acdbGetObjectId(plineid, adsEnt);
PLINE2D
pPline; Objectobj; acdbOpenObject(objplineId, fR); //Read pline return Acdbobject pPline = (PLINE2D*)obj; //Convert Acdbobject to Acdb2dPline ObjectIpVertIter = pPline->vertexIterator(); // get ObjectIterator but failed
'continue code
}

Thanks in advance!

 

 

 

 

 


If you will using standard names of ObjectARX classes/structures - It will be easier to help you.

AcDb2dPolyline *pline = AcDb2dPolyline::cast(obj);
if (pline) {
  AcDbObjectIterator* vi = pline->vertexIterator();
  if (vi) {
   // iterate vertexies and after delete iterator
   for (vi->start(); !vi->done(); vi->step()) {
    // getting  vertex
   }
   delete vi;
  }
}

P.S.: Are you sure your's polyline is AcDb2dPolyline and not AcDbPolyline ???

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 3 of 3

D_D_K
Advocate
Advocate

Hi, sorry I couldn't distinguish pline and pline2d. I tried drawing a pline on the screen and using this code and it seems to be pline because when I changed using getpointat () method now the code works.
Thanks so much for the help.

 

0 Likes