<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Save as IFC after file is opened in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Save-as-IFC-after-file-is-opened/m-p/629215#M9773</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm afraid you cannot call ifc save function during the file opening operation. I'd suggest you to try APINotify_AllInputFinished.&lt;/P&gt;
&lt;P&gt;HTH.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Aug 2024 02:14:53 GMT</pubDate>
    <dc:creator>Hiromichi Shinkawa</dc:creator>
    <dc:date>2024-08-30T02:14:53Z</dc:date>
    <item>
      <title>Save as IFC after file is opened</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Save-as-IFC-after-file-is-opened/m-p/629083#M9772</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a&amp;nbsp;process want to do:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. Open File.pln.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. Check File.pln is opened and save as IFC by "Do_Save_IfcFile".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3. Quit Archicad.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have followed this topic below and try to save as ifc file inside "APINotify_Open" event.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But "Do_Save_IfcFile" throws error seems the file is not fully opened. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am using Archicad 26. Any ways I can save as ifc after file is fully opened? Thanks a lot.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268283" target="_blank" rel="noopener"&gt;https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268283&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rubbcs_0-1724904696260.png" style="width: 999px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/75708i15A1BAABC9D3CBEE/image-size/large?v=v2&amp;amp;px=999" role="button" title="rubbcs_0-1724904696260.png" alt="rubbcs_0-1724904696260.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2024 11:08:26 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Save-as-IFC-after-file-is-opened/m-p/629083#M9772</guid>
      <dc:creator>rubbcs</dc:creator>
      <dc:date>2024-09-05T11:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Save as IFC after file is opened</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Save-as-IFC-after-file-is-opened/m-p/629215#M9773</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm afraid you cannot call ifc save function during the file opening operation. I'd suggest you to try APINotify_AllInputFinished.&lt;/P&gt;
&lt;P&gt;HTH.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 02:14:53 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Save-as-IFC-after-file-is-opened/m-p/629215#M9773</guid>
      <dc:creator>Hiromichi Shinkawa</dc:creator>
      <dc:date>2024-08-30T02:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: Save as IFC after file is opened</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Save-as-IFC-after-file-is-opened/m-p/629272#M9780</link>
      <description>&lt;P&gt;Thanks for your suggestion. I have tried "APINotify_AllInputFinished" but still fail with "APIERR_BADWINDOW" message.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rubbcs_0-1725010252559.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/75773iF4CC40EC89CCBFA3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rubbcs_0-1725010252559.png" alt="rubbcs_0-1725010252559.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 09:32:42 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Save-as-IFC-after-file-is-opened/m-p/629272#M9780</guid>
      <dc:creator>rubbcs</dc:creator>
      <dc:date>2024-08-30T09:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Save as IFC after file is opened</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Save-as-IFC-after-file-is-opened/m-p/629403#M9781</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please try the following code to see whether you can save as ifc file:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#include	"SaveAndRestoreVariable.hpp"

#include	"ResourceIDs.h"

#define SAVEIFC			'SIFC'

// =============================================================================
//
// Main functions
//
// =============================================================================

GSErrCode __ACENV_CALL SaveIFCFunction(GSHandle /* params */, GSPtr /* resultData */, bool /* silentMode */)
{
	GSErrCode	lastErr = NoError;

	ACAPI_KeepInMemory(true);

	API_ProjectInfo		projectInfo = {};
	lastErr = ACAPI_Environment(APIEnv_ProjectID, &amp;amp;projectInfo);
	if (lastErr != NoError || projectInfo.untitled)
		return APIERR_NOPLAN;

	// Set the output IFC file's locations (it's beside the plan file)
	IO::Name	llName;
	projectInfo.location-&amp;gt;GetLastLocalName(&amp;amp;llName);
	llName.DeleteExtension();
	llName.AppendExtension("ifc");
	projectInfo.location-&amp;gt;SetLastLocalName(llName);

	// Get a suitable translator
	API_IFCTranslatorIdentifier firstTranslator;
	GS::Array&amp;lt;API_IFCTranslatorIdentifier&amp;gt; ifcExportTranslators;
	lastErr = ACAPI_IFC_GetIFCExportTranslatorsList (ifcExportTranslators);
	if (lastErr != NoError) {
		return APIERR_GENERAL;
	}
	else {
		if (DBVERIFY(!ifcExportTranslators.IsEmpty()))
			firstTranslator = ifcExportTranslators.GetFirst();
	}

	// Set the output parameters
	API_FileSavePars fileSave = {};
	fileSave.fileTypeID = APIFType_IfcFile;
	fileSave.file = projectInfo.location;

	// Set the output parameters for IFC
	API_SavePars_Ifc ifcPars = {};
	ifcPars.subType = API_IFC;

	ifcPars.elementsToIfcExport = API_EntireProject;
	ifcPars.translatorIdentifier = firstTranslator;
	ifcPars.elementsSet = nullptr;

	lastErr = ACAPI_Automate(APIDo_SaveID, &amp;amp;fileSave, &amp;amp;ifcPars);

	return lastErr;
}


static GSErrCode AllInputNotificationHandler(API_NotifyEventID notifID, Int32 /*param*/)
{
	if (notifID == APINotify_AllInputFinished) {
		API_ModulID mdid = {};
		mdid.developerID	= MDID_DEVELOPER_ID;
		mdid.localID		= MDID_LOCAL_ID;
		ACAPI_Command_CallFromEventLoop(&amp;amp;mdid, SAVEIFC, 1L, nullptr, false, nullptr);
	}

	ACAPI_KeepInMemory(true);

	return NoError;
}

// =============================================================================
//
// Required functions
//
// =============================================================================

// -----------------------------------------------------------------------------
// Dependency definitions
// -----------------------------------------------------------------------------

API_AddonType	__ACENV_CALL	CheckEnvironment (API_EnvirParams* envir)
{
	RSGetIndString (&amp;amp;envir-&amp;gt;addOnInfo.name, ID_ADDON_INFO, 1, ACAPI_GetOwnResModule());
	RSGetIndString (&amp;amp;envir-&amp;gt;addOnInfo.description, ID_ADDON_INFO, 2, ACAPI_GetOwnResModule());

	return APIAddon_Preload;
}		// CheckEnvironment


// -----------------------------------------------------------------------------
// Interface definitions
// -----------------------------------------------------------------------------

GSErrCode	__ACENV_CALL	RegisterInterface (void)
{
	GSErrCode err = ACAPI_Register_SupportedService(SAVEIFC, 1L);

	return err;
}		// RegisterInterface


// -----------------------------------------------------------------------------
// Called when the Add-On has been loaded into memory
// to perform an operation
// -----------------------------------------------------------------------------

GSErrCode	__ACENV_CALL Initialize	(void)
{
	GSErrCode 	err = ACAPI_Install_ModulCommandHandler(SAVEIFC, 1L, SaveIFCFunction);
	err |= ACAPI_Notify_CatchProjectEvent(APINotify_AllInputFinished, AllInputNotificationHandler);

	return err;
}		// Initialize


// -----------------------------------------------------------------------------
// FreeData
//		called when the Add-On is going to be unloaded
// -----------------------------------------------------------------------------

GSErrCode __ACENV_CALL	FreeData (void)
{
	return NoError;
}		// FreeData
&lt;/LI-CODE&gt;
&lt;P&gt;HTH.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 02:24:02 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Save-as-IFC-after-file-is-opened/m-p/629403#M9781</guid>
      <dc:creator>Hiromichi Shinkawa</dc:creator>
      <dc:date>2024-09-02T02:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Save as IFC after file is opened</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Save-as-IFC-after-file-is-opened/m-p/629790#M9791</link>
      <description>&lt;P&gt;It's work. Thank you so much.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 10:13:25 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Save-as-IFC-after-file-is-opened/m-p/629790#M9791</guid>
      <dc:creator>rubbcs</dc:creator>
      <dc:date>2024-09-04T10:13:25Z</dc:date>
    </item>
  </channel>
</rss>

