We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

batch processing workflow inside API

Newbie
Participant

I am not sure is there anyone could provide guideline to create API batch processing for opening multiple .pln projects one by one then do some operations and save as new project file and close the project before open the new one and so on.

6 REPLIES 6
poco2013
Mentor

FYI:

 

Since the C++ AddOn is a internal DLL, at least one pin file would have to be open before  initiating the multiple batch processing  - But which one ? And what type of operations do you need to do? Is the C++ API even capable of doing so?

 

Assuming so, you would need a common AddOn and some external program to control the operation. Such a concept was originally created by Tibor Lorantly, formally of Graphisoft, using a Python program to control the sequence and a AddOn to perform the operation. His program only addressed one file and just printed all layouts in a publisher set periodically, from that point in time. It did require that the pin file be initially open.

 

This concept could be easily (??) extended to launch multiple pin's, using a Python script, a AddOn and with a controlling database - say a excel spreadsheet -  to select/control the operations and their sequence. Of course, the operations could be hard coded into the Python script, assuming that they would never change, but that would be too restrictive. Python does have the capability to open programs and through the the Python API and a AddOn, to initiate operations in a Archicad pin file.

 

Note that Tibor is no longer with Graphisoft, and BTW, it looks like the Python API is not going to be extended or supported for at least a while. So your mostly on your own, but you may want to checkout  Tibor's old GitHub site which is still up and contains the original sample code.  A alternative, is the tAPIr project, which has incorporated Tibor's old code into a grasshopper module. That would require using the grasshopper interface, but might be easier if you are familiar with grasshopper.

 

 

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27

Thanks Gerry for your guidance,

Let say if I create a template PLN file which has a common hotlink module, MVO, and some libraries linked. After open a blank AC project and activate this addon, the addon will allow to select multiple of pln files from any folder then will start batch processing by open the selected pln one by one and apply its setting to be same as template set. After that will save it as new pln file in another folder and close the current selected pln to process to the other.

Not sure, would this could be done thru such addon or not. 

Not Sure?? It definitely depends on how far you want to take it. I am assuming you want to create a template that contains all your favorites, MVO, GO, attributes. properties, etc. and apply that to the new file? After that would you need to create schedules, views, layouts and Publisher sets? I believe that is all possible within the C++ API (not schedules), but the details of configuring each individual feature would be huge. i don't know how many drawings you need updating or the frequency, but i doubt that the necessary programing time would be less expensive or more productive.

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27

Recently focusing hotlink and MVO, for example remove/break hotlink and/or MVO file which not present in the template before save to the new file. My concerning is how API manage such batch processing of multiple selected pln files according to the above idea. Please share your though. 

AFAIK -- the C++ API can not batch process multiple files, you would need a external program to do that, as mentioned above. Also, I am not familiar with the API hotlink functions, so someone else need address that. The API does appear to have  a comprehensive list of hotlink functions, but I have never used them. Can not help with the details and unfortunately there are no examples that i am aware of.

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
MudratDetector
Enthusiast

I, too, have something similar brewing in my thoughts.  I am happy to discuss further, if this brief explanation is helpful.

 

My concept is to generate .pdf sets of selected projects every weekend so that project managers have a current set on Monday morning.

 

I anticipate the execution of this to follow something similar to:
- - Have project managers select desired sets before Friday.  Selection is made by a tool [unwritten, as of yet] that reads folder structure, provides a means to select desired projects from this dynamic list, and write selections to a .txt file.

- - On Saturday night, have a GPO launch ArchiCAD as a specific user and open each of the selected project files included in the .txt file.

- - Execute the Add-on command automatically because ArchiCAD is open [already written] by the specific user.  The Add-on command, run by the specific user,  generates the .pdf set.  All other users never run it.

 

I have the last step figured out and working for other things I want to check automatically because ArchiCAD is opened.  I have this in working order for when ArchiCAD opens and when any file opens.  I am doing this by creating an Add-on I call JHP_AutoLoad.  There is no menu selection option for the included tools and I put the business end of all of this in the 'Initialize' portion of the menu, like so:

 

// -----------------------------------------------------------------------------
// Initialize
//		called after the Add-On has been loaded into memory
// -----------------------------------------------------------------------------

GSErrCode __ACENV_CALL	Initialize (void)
{
	//// look at send/receive data on teamwork projects

	///////////
	//
	// At ArchiCAD OPEN - -
	// Autoload stuff goes here.
	//
	///////////

	// Represents a high_resolution clock with the smallest possible tick period.
	// Specifically, the period is a nanosecond, or ratio<1, 1000000000>
	auto start = steady_clock::now();
	
	HotLinkRegEdit();

	GSErrCode err = ACAPI_Install_MenuHandler(JHP_AUTOLOAD_MENU_STRINGSID, MenuCommandHandler);
	err = ACAPI_Notify_CatchProjectEvent(APINotify_Open, JHP_EventHandler);
	err = ACAPI_Notify_CatchSelectionChange(SelectionChangeHandler);

	auto stop = steady_clock::now();
	
	auto duration = (stop - start) / 1000000000.;

	GS::UniString strElapsedTime = "Time taken by AC24 AutoLoad: ";
	strElapsedTime = strElapsedTime + GS::UniString::Printf("%f", duration) + " seconds\n\n";
	ACAPI_WriteReport("\n...\n...\n... AutoLoad elapsed time:  " + strElapsedTime, false);


	///////////
	//
	// End of Autoload.
	//
	///////////

	return err;
}		
// Initialize

 

 

At each and every File > Open, I am currently checking to see if the open file is a .bpn file.  If a .bpn file is opened, the user gets a large dialog discouraging them not to continue, the user name, file name, and time stamp are written to a log file, and a few of us get an email alerting that the user, mentioned by name, has opened a backup file.

 

I am also making sure the necessary registry hack to generate small hot link module files is set and setting it if not.

Related information 

Hope this helps,

Chris

Chris Gilmer
Intel i9-12950HX CPU @ 2.30GHz, 16 cores
NVIDIA GeForce RTX 3080
48.0 GB RAM
Windows 10 Pro 64-bit