Drawing polyLines
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2005-05-03
12:00 AM
- last edited on
ā2024-09-09
10:44 AM
by
Doreena Deng
ā2005-05-03
12:00 AM
I'm getting the error APIERR_REFUSEDCMD (-2130312312) when I try to create a polyline. The code below is much simplified and with extra comments...Am I missing something?
void DrawPoly(void){ API_ElementMemo memo; API_ElementMemo* pMemo = &memo; API_Element newPoly; API_Element* pNewPoly = &newPoly; GSErrCode err; BNZeroMemory(pNewPoly,sizeof(API_Element)); BNZeroMemory(pMemo,sizeof(API_ElementMemo)); pNewPoly->header.typeID = API_PolyLineID; pNewPoly->header.layer = 1; pNewPoly->header.floorInd = 1; pNewPoly->polyLine.poly.nArcs = 0; //no arcs pNewPoly->polyLine.poly.nSubPolys = 1; //no holes pNewPoly->polyLine.poly.nCoords = 4; //a closed triangle //allocate space for 3points + final point to close shape + space for storing max vertID = 5 pMemo->vertexIDs = (unsigned long **) BMAllocateHandle(sizeof(long) * (5), ALLOCATE_CLEAR, 0); (*pMemo->vertexIDs)[0] = 3; //max vertexID //allocate space for pends. no holes, so the 4th vert is the only endpoint. pMemo->pends = (long **) BMAllocateHandle(sizeof(long) * 2, ALLOCATE_CLEAR, 0); (*pMemo->pends)[0] = 0; //required (*pMemo->pends)[1] = 4; //4th vert closes the shape //allocate space for the coord array. 4 vertices + the dummy coord. pMemo->coords = (API_Coord **) BMAllocateHandle(sizeof(API_Coord) * 5, ALLOCATE_CLEAR, 0); (*pMemo->coords)[0].x = -1.0; //polylines start with a "dummy" coord of -1,0 (*pMemo->coords)[0].y = 0.0; //setup complete....add vertices. //1st point: 1,1 (*pMemo->coords)[1].x = 1; (*pMemo->coords)[1].y = 1; (*pMemo->vertexIDs)[1] = 1; //2nd point: 2,1 (*pMemo->coords)[2].x = 2; (*pMemo->coords)[2].y = 1; (*pMemo->vertexIDs)[2] = 2; //3rd point: 1,2 (*pMemo->coords)[3].x = 1; (*pMemo->coords)[3].y = 2; (*pMemo->vertexIDs)[3] = 3; //4th point. Same as point 1. (*pMemo->coords)[4].x = 1; (*pMemo->coords)[4].y = 1; (*pMemo->vertexIDs)[4] = 1; err = ACAPI_Element_Create(pNewPoly,pMemo); //handle return code... ACAPI_DisposeElemMemoHdls(pMemo); }
2 REPLIES 2
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2005-05-03 04:27 PM
ā2005-05-03
04:27 PM
Found the problem, updating for posterity's sake. 
I was searching my computer for other mentions of that error. The function ACAPI_Element_Link mentioned that the error I got is caused (in that case) by not having an undoable session open. I had used the undoable session in a earlier version of my code, but left it out "temporarily" when I rewrote the function..... Apparently I corrected my other problem(s), just needed that undo session.

I was searching my computer for other mentions of that error. The function ACAPI_Element_Link mentioned that the error I got is caused (in that case) by not having an undoable session open. I had used the undoable session in a earlier version of my code, but left it out "temporarily" when I rewrote the function..... Apparently I corrected my other problem(s), just needed that undo session.
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2006-08-14 12:03 PM
ā2006-08-14
12:03 PM
Hi Ramblin,
thank you for your excellent code!
Yours faithfully,
Pal.
thank you for your excellent code!
Yours faithfully,
Pal.