2011-03-15 02:35 PM - last edited on 2023-08-03 10:18 AM by Doreena Deng
void SaveandExitDrawing() { InsertDateStamp(); OSErr err = ACAPI_Automate(APIDo_SaveID, NULL, NULL); if(err != noErr) GiveMsg("ERROR: Problem saving document."); else TerminateArchiCAD(); } void TerminateArchiCAD() { DWORD dwID; GetWindowThreadProcessId(ACAPI_GetMainWindow(), &dwID); HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, dwID); TerminateProcess(hProc, 0); } void InsertDateStamp() { API_Element element; API_ElementMemo memo; char stamp[500], ts[256], hState; // Make the stamp string sprintf(stamp, "ref: %c%c Date: %s %s", GetUser()[0], GetUser()[strlen(GetUser()) - 1], GetCurrentDateAsString(ts), GetDrawingName()); memset(&element, 0, sizeof(API_Element)); element.header.floorInd = 0; element.header.layer = tbLaerStore->BarcodeLayer; element.header.typeID = API_TextID; element.text.anchor = APIAnc_RM; element.text.angle = 0; element.text.faceBits = APIFace_Plan; element.text.font = FindFont("Arial Western"); element.text.height = 2.0 element.text.just = APIJust_Right; element.text.nLine =1; element.text.nonBreaking = true; element.text.pen = 5; element.text.size = 2.0; element.text.spacing = 0.0; element.text.width = 100.0; element.text.loc.x = 47.55; element.text.loc.y = 34.43; memset(&memo, 0 sizeof(API_ElementMemo)); memo.textContent = BMAllocateHandle((unsigned int)strlen(stamp) + 1, ALLOCATE_CLEAR, NULL); hState = BMModifyHandleState((GSHandle) memo.textContent, HANDLE_STSTE_LOCK, 0); strcpy(memo.textContent[0], stamp); BMModifyHandleState((GSHandle) memo.textContent, HANDLE_STATE_SET, hState); OSErr err = ACAPI_ElementCreate(&element, &memo); if(err != noErr) GiveMsg_Err("ERROR: Unable to insert date settings. Problem creating element.\n", err); else GiveUserDate(element, 'MISC'); ACAPI_DisposeElemMemoHdls(&memo); }