AcdbHatch::getLoopAt Problem ...

AcdbHatch::getLoopAt Problem ...

Anonymous
Not applicable
2,587 Views
11 Replies
Message 1 of 12

AcdbHatch::getLoopAt Problem ...

Anonymous
Not applicable

try to get hatch boundry vertex by using " getLoopAt " method but Autocad shows some "Assertion Failed" error..

 

Code::

 

AcDbHatch* aHac = AcDbHatch::cast(aEnt);

if (aHac->loopTypeAt(ind) & AcDbHatch::kPolyline)
{

Adesk::Int32 loopType;

AcGePoint2dArray vertices;
AcGeDoubleArray bulges;

aHac->getLoopAt(ind,loopType,vertices,bulges);
int nver = vertices.length();
acutPrintf(_T("\n%d"),nver);
}

0 Likes
2,588 Views
11 Replies
Replies (11)
Message 2 of 12

Alexander.Rivilis
Mentor
Mentor

It is look like value of ind   is not setting before aHac->loopTypeAt(ind)  calling.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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 12

Anonymous
Not applicable

 

thanks for replay..but i have already given "ind (index) " value ...

 

int numVer = aHac->numLoops();
acutPrintf(_T("\n%d"), numVer);
for (int ind = 0; ind < numVer; ind++)
{
//acutPrintf(_T("\npolyline"));

if (aHac->loopTypeAt(ind) & AcDbHatch::kPolyline)
{

int32_t loopType;

AcGePoint2dArray vertices;
AcGeDoubleArray bulges;

aHac->getLoopAt(ind,loopType,vertices,bulges);
int nver = vertices.length();
acutPrintf(_T("\n%d"),nver);
}
}

0 Likes
Message 4 of 12

Alexander.Rivilis
Mentor
Mentor

1. AutoCAD version?

2. Visual Studio version and updates?

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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 5 of 12

Anonymous
Not applicable

Autocad 2018

Visual Studio 2015..

0 Likes
Message 6 of 12

Alexander.Rivilis
Mentor
Mentor

@Anonymous написал (-а):

Autocad 2018

Visual Studio 2015..


Visual Studio 2015 or Visual Studio 2015 with Update 3 ???

 

P.S.: Try this sample code: http://adndevblog.typepad.com/autocad/2012/04/perimeter-of-a-hatch-using-objectarx-and-autocad-net-a...

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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 7 of 12

Anonymous
Not applicable

thanks Sir ...i already see this example ...

is their any other method to get the vertices of the Hatch..(Polyline)..

0 Likes
Message 8 of 12

Anonymous
Not applicable

  code::

 

 

 if (aHac->loopTypeAt(ind) & AcDbHatch::kExternal)
{
acutPrintf(_T("\nexternal hatch"));


AcGeVoidPointerArray vert;
vert.setPhysicalLength(50);

AcGeIntArray bulges;

Adesk::Int32 loopType;

aHac->getLoopAt(ind,loopType, vert, bulges);
acutPrintf(_T("\n%d"), vert.length());

for (int i=0;i<vert.length()+1;i++)
{
if (i == vert.length())
{
break;
}

}

}

 

i'll try to get the "Acdb::kexternal" Hatch vertices ...but autocad get crash ...

 

please help..

0 Likes
Message 9 of 12

Alexander.Rivilis
Mentor
Mentor

@Anonymous

 

If you expect help, then attach an example of the ObjectARX project (in zip) and an example of a dwg-file for testing.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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 10 of 12

Anonymous
Not applicable

code and dwg file

0 Likes
Message 11 of 12

Alexander.Rivilis
Mentor
Mentor

@Anonymous написал (-а):

code and dwg file


This is not what I asked for.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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 12 of 12

autodaug
Autodesk
Autodesk

The assert message appears to be coming from MSVC's debug lib and is saying there's a heap corruption. There may be a mismatch between the app's c-runtime lib and acad'. E.g., if one is the debug lib and the other is the release lib, or maybe they are from different MSVC versions. The heap corruption can happen when memory is allocated from one runtime heap and then deleted onto another heap.

 

To work around this, you might try "pre-allocating" your arrays' buffers before calling the API. That way, acad will not need to grow your array, and so all allocation and de-allocation of your array buffers will be happening on your app's heap and none on acad's.  E.g.:

 

AcGePoint2dArray vertices;
vertices.setPhysicalLength(1000);    // pre-allocate array so acad won't grow it
AcGeDoubleArray bulges;
bulges.setPhysicalLength(1000);     // use a size guaranteed to be big enuff

aHac->getLoopAt(ind,loopType,vertices,bulges);
assert(vertices.length() < 1000);      // make sure we're pre-allocating enough

This is kind of kludgy, but it's worth a try. If you google around for setPhysicalLength(), you can find other discussions of this workaround. However, if there is a runtime heap mismatch going on, then I would think you may run into stability problems in other areas too..

 

 

0 Likes