2021-04-27 03:13 AM - last edited on 2021-09-14 09:39 AM by Noemi Balogh
void Do_CreateLine(API_Guid guid) { API_Coord c; API_GetLineType clickInfo; API_Element element; GSErrCode err; // input the coordinates BNZeroMemory(&clickInfo, sizeof(API_GetLineType)); if (!ClickAPoint("Click the line start point", &c)) return; CHCopyC("Click the line end point", clickInfo.prompt); clickInfo.startCoord.x = c.x; clickInfo.startCoord.y = c.y; err = ACAPI_Interface(APIIo_GetLineID, &clickInfo, nullptr); if (err != NoError) { ErrorBeep("APIIo_GetLineID", err); return; } // real work BNZeroMemory(&element, sizeof(API_Element)); element.header.typeID = API_LineID; ACAPI_Element_GetDefaults(&element, nullptr); if (err != NoError) { ErrorBeep("ACAPI_Element_GetDefaults (Line)", err); return; } element.header.renovationStatus = API_DemolishedStatus; element.line.begC.x = clickInfo.startCoord.x; element.line.begC.y = clickInfo.startCoord.y; element.line.endC.x = clickInfo.pos.x; element.line.endC.y = clickInfo.pos.y; err = ACAPI_Element_Create(&element, nullptr); if (err != NoError) { ErrorBeep("ACAPI_Element_Create (Line)", err); ACAPI_WriteReport("Create Error = %s", true, ErrID_To_Name(err)); return; } else ACAPI_WriteReport("Create Success - %s", true, "No Error"); ACAPI_WriteReport("GUID of the Line: %s", true, APIGuidToString(element.header.guid).ToCStr().Get()); guid = element.header.guid; // store it for later use ACAPI_KeepInMemory(true); return; } // Do_CreateLine
Solved! Go to Solution.
2021-04-27 04:18 PM
2021-04-27 09:05 AM
2021-04-27 12:40 PM
static GSErrCode MenuCommandHandler (const API_MenuParams *menuParams) { GS::ErrCode err; return ACAPI_CallUndoableCommand("Element Test API Function", [&]() -> GSErrCode { switch (menuParams->menuItemRef.menuResID) { case AddOnMenuID: switch (menuParams->menuItemRef.itemIndex) { case 1: { err = Do_PlaceKeySymbol("part"); } break; case 2: { Do_CreateLabel(); } break; case 3: { Do_CreateLine(APINULLGuid); } break; default: break; } } return err; }); }Note that the first function that just creates a library Part works OK.
2021-04-27 04:18 PM