Archicad C++ API
About Archicad add-on development using the C++ API.

Problem with ACAPI_Automate in ARCHICAD 13

Anonymous
Not applicable
Hi,

I have a Save&Exit button in one of our ArchiCAD menu. By pressing this button my function SaveandExitDrawing() will insert the date stamp then save and exit the ArchiCAD. this function works fine in ArchiCAD 9.

But, with ArchiCAD 13 Drawing is Saving and Exiting without Date stamp.

I found that ACAPI_Automate function is working on the database before the button press event. I am using ACAPI_Automate function few times (saving, publishing) where I found this function working on drawing state before the button press.

Is there anyway ACAPAI_Automate function works on current drawing state?

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);
}
0 REPLIES 0