2012-07-26 02:30 AM - last edited on 2023-08-02 04:22 PM by Doreena Deng
API_Coord clickedPoint; if (!ClickAPoint("Origem", &clickedPoint)) { return; } ACAPI_OpenUndoableSession("Do it!"); API_Element zoneElement; API_ElementMemo zoneElementMemo; BNZeroMemory(&zoneElement, sizeof(API_Element)); BNZeroMemory(&zoneElementMemo, sizeof(API_ElementMemo)); zoneElement.header.typeID = API_ZoneID; ACAPI_Element_GetDefaults(&zoneElement, &zoneElementMemo); zoneElement.zone.manual = true; // Code to create Polygon??? ACAPI_Element_Create(&zoneElement, &zoneElementMemo); ACAPI_CloseUndoableSession();Is that even possible? Any help would be appreciated!
2012-08-08 12:22 PM
Andre wrote:Hello Andre,
Hi,
Is it possible to create a Zone Element through the API? I've tried to create an Element with type API_ZoneID but nothing happens. From what I understand, I would need to create a Polygon for creating the zone, but I can't find any information or example on that. Here's my code:
API_Coord clickedPoint; if (!ClickAPoint("Origem", &clickedPoint)) { return; } ACAPI_OpenUndoableSession("Do it!"); API_Element zoneElement; API_ElementMemo zoneElementMemo; BNZeroMemory(&zoneElement, sizeof(API_Element)); BNZeroMemory(&zoneElementMemo, sizeof(API_ElementMemo)); zoneElement.header.typeID = API_ZoneID; ACAPI_Element_GetDefaults(&zoneElement, &zoneElementMemo); zoneElement.zone.manual = true; // Code to create Polygon??? ACAPI_Element_Create(&zoneElement, &zoneElementMemo); ACAPI_CloseUndoableSession();Is that even possible? Any help would be appreciated!
2012-09-28 05:51 PM
ACAPI_OpenUndoableSession("Do It!"); API_Element zoneElement; API_ElementMemo elementMemo; BNZeroMemory(&zoneElement, sizeof(API_Element)); BNZeroMemory(&elementMemo, sizeof(API_ElementMemo)); zoneElement.header.typeID = API_ZoneID; zoneElement.header.layer = CriarLayer(); ACAPI_Element_GetDefaults(&zoneElement, &elementMemo); zoneElement.zone.manual = true; zoneElement.zone.pos.x = clickedPoint.x; zoneElement.zone.pos.y = clickedPoint.x; zoneElement.zone.refPos.x = clickedPoint.x; zoneElement.zone.refPos.y = clickedPoint.x; zoneElement.zone.poly.nCoords = 5; zoneElement.zone.poly.nSubPolys = 1; zoneElement.zone.poly.nArcs = 0; elementMemo.coords = (API_Coord**) BMAllocateHandle ((zoneElement.zone.poly.nCoords + 1) * sizeof (API_Coord), ALLOCATE_CLEAR, 0); elementMemo.pends = (Int32**) BMAllocateHandle ((zoneElement.zone.poly.nSubPolys + 1) * sizeof (Int32), ALLOCATE_CLEAR, 0); if (elementMemo.coords != NULL && elementMemo.pends != NULL) { (*elementMemo.coords)[1].x = clickedPoint.x - 1.0; (*elementMemo.coords)[1].y = clickedPoint.y; (*elementMemo.coords)[2].x = clickedPoint.x; (*elementMemo.coords)[2].y = clickedPoint.y - 1.0; (*elementMemo.coords)[3].x = clickedPoint.x + 1.0; (*elementMemo.coords)[3].y = clickedPoint.y; (*elementMemo.coords)[4].x = clickedPoint.x; (*elementMemo.coords)[4].y = clickedPoint.y + 1.0; (*elementMemo.coords)[5].x = (*elementMemo.coords)[1].x; (*elementMemo.coords)[5].y = (*elementMemo.coords)[1].y; (*elementMemo.pends)[0] = 0; (*elementMemo.pends)[1] = zoneElement.zone.poly.nCoords; } GSErrCode err = ACAPI_Element_Create(&zoneElement, &elementMemo); if (err != NoError) ErrorBeep ("ACAPI_Element_Create (Zone)", err); ACAPI_DisposeElemMemoHdls (&elementMemo); ACAPI_CloseUndoableSession();