run-time check failure #2 - Point corrupted

run-time check failure #2 - Point corrupted

Anonymous
Not applicable
986 Views
5 Replies
Message 1 of 6

run-time check failure #2 - Point corrupted

Anonymous
Not applicable

I have been trying to figure this out for a few days now and have been having some problems. I tried to do some research Run-Time Check Failure #2 - Stack around the variable 'name'' was corrupted and The "Big Picture" - Interview with Jim Quanci (Autodesk) but neither really helped me too much. The ObjectArx & Dummies seemed to point to the fact that I had a memory leak but if that was the case I am not sure how exactly.

 

void drawCable(){
    AcDbPolyline *pLine = new AcDbPolyline();
    int vertexPoint = 0;
    AcGePoint2d tempPoint;
    int result  = acedGetPoint(NULL,_T("\nSelect the first point:"),asDblArray(tempPoint));
    while(result == RTNORM){
        pLine->addVertexAt(vertexPoint,tempPoint);
        vertexPoint++;
        result  = acedGetPoint(NULL,_T("\nSelect the point:"),asDblArray(tempPoint));
    }
    postToDb(pLine);
    pLine->close();
}

 

Any advice would be greatly appreciated. Thanks in advance like usual.

0 Likes
Accepted solutions (1)
987 Views
5 Replies
Replies (5)
Message 2 of 6

Alexander.Rivilis
Mentor
Mentor
Accepted solution

Change:

AcGePoint2d tempPoint;

 with:

AcGePoint3d tempPoint;

 And change:

pLine->addVertexAt(vertexPoint,tempPoint);

 with:

pLine->addVertexAt(vertexPoint,AcGePoint2d(tempPoint.x, tempPoint.y));

 

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

Message 3 of 6

Anonymous
Not applicable

Excellent it worked like a charm.

 

What exactly was the issue with the way that I was doing it? Was it because when I was only accepting a 2d point when AcedGetPoint is trying to put in a 3d point?

0 Likes
Message 4 of 6

Alexander.Rivilis
Mentor
Mentor

@Anonymous wrote:
...Was it because when I was only accepting a 2d point when AcedGetPoint is trying to put in a 3d point?...

Yes of course! acedGetPoint "thinks" that you pass a pointer to an array of three double, but you pass a pointer to an array of two double. That is why the function wrote third double to invalid location.

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

Anonymous
Not applicable

Excellent thanks,

I was reading up on the poly class and I see that instead of incrementing the vertexPoint that I have in my code I could just do something like this.

 

pLine->addVertexAt(pLine->numVerts(),AcGePoint2d(tempPoint.x,tempPoint.y));

 

I am going to figure that incrementing my number would be the simpler way to go since it would only require a simple increment rather then looking up the value from the polyline?

 

I guess not that I have this figured out I now just need to see how to use this to include the jig class.

0 Likes
Message 6 of 6

Alexander.Rivilis
Mentor
Mentor

Zanzabar wrote:

...I am going to figure that incrementing my number would be the simpler way to go since it would only require a simple increment rather then looking up the value from the polyline?...


I think that AcDbPolyline has a class member with number of vertexes and not very much difference between the use of both ways.


@Anonymous wrote:
...I guess not that I have this figured out I now just need to see how to use this to include the jig class...

I've posted a small sample project which make Polyline with JIG. You can develop it further as you sees fit.

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