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

ACAPI_Automate(APIDo_SaveID...) not saving file

Anonymous
Not applicable
I'm using AC13 and when I call

err = ACAPI_Automate(APIDo_SaveID, NULL, NULL, NULL);
from my menu handler with a new plan open from a template and it returns NoError but the file is not saved.

How can I save the current file please?
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Anonymous
Not applicable
n.mihaylov wrote:
I have problems saving to a solo project. There's no error when I save using the example in Automate_Functions example. But when I try to add file destination I get APIERR_GENERAL:
API_FileSavePars fsp;
	API_SavePars_PlanDump pars;
	GSErrCode err;

	BNZeroMemory (&fsp, sizeof (API_FileSavePars));
	
	IO::Location folderLoc;
	API_SpecFolderID specID = API_UserDocumentsFolderID;
	ACAPI_Environment (APIEnv_GetSpecFolderID, &specID, &folderLoc);
	fsp.file = new IO::Location (folderLoc);
	fsp.fileTypeID = APIFType_PlanFile;

	BNZeroMemory (&pars, sizeof (API_SavePars_PlanDump));

	err = ACAPI_Automate (APIDo_SaveID, &fsp, &pars);
Can someone help me?

P.S. I also havе troubles with IO::Location::AppendToLocal - what type of argument does it take so I can add the filename to the path?
Fsp.file should have the file name in it. Make sure the path you put into fsp.file has it (for example: c:\temp\file.pln is a good path)

View solution in original post

7 REPLIES 7
Ralph Wessel
Mentor
GDefina wrote:
err = ACAPI_Automate(APIDo_SaveID, NULL, NULL, NULL);
from my menu handler with a new plan open from a template and it returns NoError but the file is not saved.
Because the file is constructed from a template, it isn't associated with any existing file (the link with the template file is severed to prevent users from saving over it). If you want to save to a file with a specific name/location, you need to fill in the API_FileSavePars structure passed to the function.
Ralph Wessel BArch
Anonymous
Not applicable
Thanks Ralph.

How can I determine the FileTypeId of the current file?
It's not part of ProjectInfo.
Or can I use APIFType_None?
Ralph Wessel
Mentor
GDefina wrote:
How can I determine the FileTypeId of the current file?
It's not part of ProjectInfo. Or can I use APIFType_None?
I'm assuming you want to save the project as an ArchiCAD solo project file, in which case you would use APIFType_PlanFile.
Ralph Wessel BArch
Anonymous
Not applicable
Thanks.
Anonymous
Not applicable
I have problems saving to a solo project. There's no error when I save using the example in Automate_Functions example. But when I try to add file destination I get APIERR_GENERAL:
API_FileSavePars fsp;
	API_SavePars_PlanDump pars;
	GSErrCode err;

	BNZeroMemory (&fsp, sizeof (API_FileSavePars));
	
	IO::Location folderLoc;
	API_SpecFolderID specID = API_UserDocumentsFolderID;
	ACAPI_Environment (APIEnv_GetSpecFolderID, &specID, &folderLoc);
	fsp.file = new IO::Location (folderLoc);
	fsp.fileTypeID = APIFType_PlanFile;

	BNZeroMemory (&pars, sizeof (API_SavePars_PlanDump));

	err = ACAPI_Automate (APIDo_SaveID, &fsp, &pars);
Can someone help me?

P.S. I also havе troubles with IO::Location::AppendToLocal - what type of argument does it take so I can add the filename to the path?
Solution
Anonymous
Not applicable
n.mihaylov wrote:
I have problems saving to a solo project. There's no error when I save using the example in Automate_Functions example. But when I try to add file destination I get APIERR_GENERAL:
API_FileSavePars fsp;
	API_SavePars_PlanDump pars;
	GSErrCode err;

	BNZeroMemory (&fsp, sizeof (API_FileSavePars));
	
	IO::Location folderLoc;
	API_SpecFolderID specID = API_UserDocumentsFolderID;
	ACAPI_Environment (APIEnv_GetSpecFolderID, &specID, &folderLoc);
	fsp.file = new IO::Location (folderLoc);
	fsp.fileTypeID = APIFType_PlanFile;

	BNZeroMemory (&pars, sizeof (API_SavePars_PlanDump));

	err = ACAPI_Automate (APIDo_SaveID, &fsp, &pars);
Can someone help me?

P.S. I also havе troubles with IO::Location::AppendToLocal - what type of argument does it take so I can add the filename to the path?
Fsp.file should have the file name in it. Make sure the path you put into fsp.file has it (for example: c:\temp\file.pln is a good path)
Anonymous
Not applicable
Thank you! It works now!