<?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: Cancel the open in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Cancel-the-open/m-p/342000#M1521</link>
    <description>&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are two automation functions which might do what you want:&lt;/P&gt;&lt;P&gt;&lt;A href="https://archicadapi.Graphisoft.com/documentation/apido_openid" target="_blank"&gt;APIDo_OpenID&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://archicadapi.Graphisoft.com/documentation/apido_newprojectid" target="_self"&gt;APIDo_NewProjectID&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's also &lt;A href="https://archicadapi.Graphisoft.com/documentation/apido_closeid?s=close%20project" target="_blank"&gt;APIDo_CloseID&lt;/A&gt;, but it has a note that it's not for public usage. So I assume it might not work for us as an external developer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately I don't have time right now to test them properly and check if they work in your situation as well. But please report back if they work or if there are any issues, so maybe we can help further with that additional information.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best,&lt;BR /&gt;Bernd&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jun 2022 07:33:39 GMT</pubDate>
    <dc:creator>BerndSchwarzenbacher</dc:creator>
    <dc:date>2022-06-22T07:33:39Z</dc:date>
    <item>
      <title>Cancel the open</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Cancel-the-open/m-p/341958#M1519</link>
      <description>&lt;P&gt;Archicad 23&amp;nbsp; |&amp;nbsp; Win 10&lt;BR /&gt;&lt;BR /&gt;I am trying to solve a problem of our users opening .bpn files from the recent files list instead of the corresponding .pln file.&amp;nbsp; I have a couple of things in place - one of which reads, at opening, the value of the "FILENAME" parameter from Project Info... and determines if the file is a .bpn file.&amp;nbsp; I do that with&amp;nbsp;ACAPI_Notify_CatchProjectEvent and APINotify_Open in the Initialize() function of the menu load and catch the file extension prior to anything being loaded in the drawing editor.&amp;nbsp; A user defined function is called&amp;nbsp; to determine the file extension and displays a warning dialog.&amp;nbsp; I do that with this code in the function:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MudratDetector_2-1655824847209.png" style="width: 999px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/22699iBEEB2E16617611D2/image-size/large?v=v2&amp;amp;px=999" role="button" title="MudratDetector_2-1655824847209.png" alt="MudratDetector_2-1655824847209.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If a .bpn file is detected, a dialog appears with a warning and the opening of the&amp;nbsp; model stops.&amp;nbsp; The warning dialog will eventually become&amp;nbsp;&lt;SPAN&gt;a much more severe version of this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MudratDetector_0-1655824202280.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/22697iC4B1DCEE19B3A0EF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MudratDetector_0-1655824202280.png" alt="MudratDetector_0-1655824202280.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would&amp;nbsp; like to&amp;nbsp; cancel the opening of the .bpn model completely, once the user presses 'OK' and not have to depend on the user reading or following directions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have searched high and low without success.&amp;nbsp; Can someone point me in the right direction to programmatically cancel [File &amp;gt; Open] ?&amp;nbsp; Or maybe execute [File &amp;gt; Open] to a new, blank file?&amp;nbsp; Is it possible at this particular stage in the open?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx - chris&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 20:02:33 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Cancel-the-open/m-p/341958#M1519</guid>
      <dc:creator>MudratDetector</dc:creator>
      <dc:date>2022-06-21T20:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel the open</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Cancel-the-open/m-p/341971#M1520</link>
      <description>&lt;P&gt;This is so important it should be integrated to Archicad. How many times I worked on files for hours, just to see that colleagues made changes on the bpn instead of the plan.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 21:13:13 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Cancel-the-open/m-p/341971#M1520</guid>
      <dc:creator>zinkh</dc:creator>
      <dc:date>2022-06-21T21:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel the open</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Cancel-the-open/m-p/342000#M1521</link>
      <description>&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are two automation functions which might do what you want:&lt;/P&gt;&lt;P&gt;&lt;A href="https://archicadapi.Graphisoft.com/documentation/apido_openid" target="_blank"&gt;APIDo_OpenID&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://archicadapi.Graphisoft.com/documentation/apido_newprojectid" target="_self"&gt;APIDo_NewProjectID&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's also &lt;A href="https://archicadapi.Graphisoft.com/documentation/apido_closeid?s=close%20project" target="_blank"&gt;APIDo_CloseID&lt;/A&gt;, but it has a note that it's not for public usage. So I assume it might not work for us as an external developer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately I don't have time right now to test them properly and check if they work in your situation as well. But please report back if they work or if there are any issues, so maybe we can help further with that additional information.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best,&lt;BR /&gt;Bernd&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 07:33:39 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Cancel-the-open/m-p/342000#M1521</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2022-06-22T07:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel the open</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Cancel-the-open/m-p/342056#M1522</link>
      <description>&lt;P&gt;Hello again Bernd!&lt;/P&gt;&lt;P&gt;I was starting to look in to the&amp;nbsp;&lt;A href="https://archicadapi.Graphisoft.com/documentation/apido_openid" target="_blank" rel="nofollow noopener noreferrer"&gt;APIDo_OpenID&lt;/A&gt;() function yesterday evening.&amp;nbsp; I was looking at the&amp;nbsp;&lt;A href="https://archicadapi.Graphisoft.com/documentation/apido_newprojectid" target="_self" rel="nofollow noopener noreferrer"&gt;APIDo_CloseID&lt;/A&gt;() function also.&amp;nbsp; I had not stumbled on to the&amp;nbsp;&lt;A href="https://archicadapi.Graphisoft.com/documentation/apido_newprojectid" target="_self" rel="nofollow noopener noreferrer"&gt;APIDo_NewProjectID&lt;/A&gt;() function yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did find this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.Graphisoft.com/t5/Developer-forum/How-to-close-Archicad-file/m-p/132746" target="_blank" rel="noopener"&gt;https://community.Graphisoft.com/t5/Developer-forum/How-to-close-Archicad-file/m-p/132746&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will report back here on how any of this works out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks - chris&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 16:33:52 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Cancel-the-open/m-p/342056#M1522</guid>
      <dc:creator>MudratDetector</dc:creator>
      <dc:date>2022-06-22T16:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel the open</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Cancel-the-open/m-p/342142#M1523</link>
      <description>&lt;P&gt;It is not doable with&amp;nbsp;APIDo_OpenID in the specific needs of my situation.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.Graphisoft.com/t5/Developer-forum/ACAPI-Automate-OpenID/m-p/218492" target="_blank" rel="noopener"&gt;https://community.Graphisoft.com/t5/Developer-forum/ACAPI-Automate-OpenID/m-p/218492&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The same rules apply for&amp;nbsp;APIDo_NewProjectID.&amp;nbsp; The search continues...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can&amp;nbsp; follow my chain reaction from the initial call of&amp;nbsp;ACAPI_Notify_CatchProjectEvent to&amp;nbsp;APIDo_OpenID here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// -----------------------------------------------------------------------------
// Initialize
//	Called after the Add-On has been loaded into memory
//	ACAPI_Notify_CatchProjectEvent monitors for APINotify_Open
//	and runs JHP_EventHandler on detection
// -----------------------------------------------------------------------------

GSErrCode __ACENV_CALL	Initialize (void)
{
	GSErrCode err = ACAPI_Install_MenuHandler (JHP_AUTOLOAD_MENU_STRINGSID, MenuCommandHandler);
	err = ACAPI_Notify_CatchProjectEvent(APINotify_Open, JHP_EventHandler);
	return err;
}
// Initialize

// -----------------------------------------------------------------------------
// JHP_EventHandler
//	Called with ACAPI_Notify_CatchProjectEvent by APINotify_Open event.
//	When APINotify_Open is detected, GetProjectInfo() is run
// -----------------------------------------------------------------------------

static GSErrCode __ACENV_CALL JHP_EventHandler(API_NotifyEventID notifID, Int32 /*param*/)
{
	GSErrCode err = NoError;
	switch (notifID) {
		case APINotify_Open:
		{
			GetProjectInfo();
			break;
		}
//		case APINotify_Close:
//		{
//			break;
//		}
//		case APINotify_Quit:
//		{
//			break;
//		}
//
		default: break;
	}
	return err;
}

//------------------------------------------------------
// Project events handler function
// GetProjectInfo
//	Called by JHP_EventHandler
//	Attempts to open corresponding .pln file with APIDo_OpenID
//------------------------------------------------------

int GetProjectInfo()
{
	char** autoTextIdKeys;
	char** autoTextIdValues;
	GSErrCode err = ACAPI_Goodies(APIAny_GetAutoTextKeysID, &amp;amp;autoTextIdKeys, &amp;amp;autoTextIdValues);
	if (err == NoError)
	{
		Int32 count = BMGetPtrSize(reinterpret_cast&amp;lt;GSPtr&amp;gt;(autoTextIdKeys)) / sizeof(char*);
		for (Int32 i = 0; i &amp;lt; count; i++)
		{
			if (autoTextIdKeys[i] == nullptr)
			{
				BMKillPtr(&amp;amp;autoTextIdValues[i]);
				continue;
			}

			GS::UniString strKey = GS::UniString(autoTextIdKeys[i]);
			GS::UniString strValue = GS::UniString(autoTextIdValues[i]);
			////
			//// Check "FILENAME" for .bpn extension.
			////
			if (strKey == "FILEPATH")
			{
				if (strValue.EndsWith(".bpn"))
				{
					ACAPI_WriteReport(GS::UniString("The file you have opened ends with .bpn\n\nThis is a backup version of your project and is NOT your working file."), true);
					API_FileOpenPars openPars;
					BNZeroMemory(&amp;amp;openPars, sizeof(API_FileOpenPars));

					GS::UniString strPlnPath = strValue.GetSubstring(0,(strValue.FindLast("\\") + 1));
					GS::UniString strPlnFile = strValue.GetSubstring((strValue.FindLast("\\") + 1),((strValue.GetLength() - strValue.FindLast("\\")) - 5)) + ".pln";
					ACAPI_WriteReport(strPlnPath + strPlnFile, true);
					IO::Location strLocation(strPlnPath);;
					//API_SpecFolderID specID = API_ApplicationFolderID;
					//ACAPI_Environment(APIEnv_GetSpecFolderID, &amp;amp;specID, &amp;amp;strLocation);
					//strLocation.AppendToLocal("Archicad Examples");
					//strLocation.AppendToLocal("Residential House");
					openPars.file = new IO::Location(strLocation, IO::Name(strPlnFile.ToCStr()));

					GSErrCode err = ACAPI_Automate(APIDo_OpenID, &amp;amp;openPars, nullptr);
					if (err != NoError)
						ACAPI_WriteReport("Cannot open\n\n" + strPlnPath + strPlnFile, true);

					delete openPars.file;
				}
			}

			BMKillPtr(&amp;amp;autoTextIdKeys[i]);
			BMKillPtr(&amp;amp;autoTextIdValues[i]);
		}
	}
	BMKillPtr(reinterpret_cast&amp;lt;GSPtr*&amp;gt;(&amp;amp;autoTextIdKeys));
	BMKillPtr(reinterpret_cast&amp;lt;GSPtr*&amp;gt;(&amp;amp;autoTextIdValues));

	return err;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 16:34:12 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Cancel-the-open/m-p/342142#M1523</guid>
      <dc:creator>MudratDetector</dc:creator>
      <dc:date>2022-06-23T16:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel the open</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Cancel-the-open/m-p/342353#M1524</link>
      <description>&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;that's unfortunate. I wasn't aware about the restriction regarding the Notification scope. Unfortunately I can't think of another solution via the Archicad API.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Maybe a workaround via a AHK, AutoIt or some other Windows GUI automatisation could work. With those you could maybe detect the dialog and a .bpn string and auto stop the loading of a bpn file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Bernd&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 11:26:48 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Cancel-the-open/m-p/342353#M1524</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2022-06-27T11:26:48Z</dc:date>
    </item>
  </channel>
</rss>

