<?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: ACAPI_CallUndoableCommand and menu choice to create a .pdf file in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-CallUndoableCommand-and-menu-choice-to-create-a-pdf-file/m-p/398142#M8584</link>
    <description>&lt;P&gt;Have you tried not wrapping it in a&amp;nbsp;&lt;FONT face="courier new,courier"&gt;ACAPI_CallUndoableCommand&lt;/FONT&gt;? Checking the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Automate_Functions&lt;/FONT&gt; example it doesn't wrap it either, and the documentation states that it doesn't needed.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Sep 2023 14:25:09 GMT</pubDate>
    <dc:creator>Viktor Kovacs</dc:creator>
    <dc:date>2023-09-13T14:25:09Z</dc:date>
    <item>
      <title>ACAPI_CallUndoableCommand and menu choice to create a .pdf file</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-CallUndoableCommand-and-menu-choice-to-create-a-pdf-file/m-p/397867#M8576</link>
      <description>&lt;P&gt;WIN 10 / AC24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a .pdf file of the current layout sheet by using the Do_Save_PdfFile function found in ..\Examples\Automate_Functions.&amp;nbsp; Instead of a .pdf file, I get an APIERR_REFUSEDCMD error.&amp;nbsp; I am trying to figure out how to properly use the code proveded to do this.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my version of the Do_Save_PdfFile function copied from ..\Examples\Automate_Functions:&lt;/P&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;static void		Do_Save_PdfFile(void)
{
	API_FileSavePars	fsp = {};
	GSErrCode			err;

	fsp.fileTypeID = APIFType_PdfFile;

	IO::Location folderLoc;
	API_SpecFolderID specID = API_UserDocumentsFolderID;
	ACAPI_Environment(APIEnv_GetSpecFolderID, &amp;amp;specID, &amp;amp;folderLoc);
	fsp.file = new IO::Location(folderLoc, IO::Name("PDFTest.pdf"));

	err = ACAPI_CallUndoableCommand("Create PDF", [&amp;amp;]() -&amp;gt; GSErrCode {
		return ACAPI_Automate(APIDo_SaveID, &amp;amp;fsp);  // &amp;lt;&amp;lt;&amp;lt;--- ERROR HERE
	});
	ACAPI_Automate(APIDo_SaveID, &amp;amp;fsp);

	if (err != NoError)
		ACAPI_WriteReport("Error in APIDo_SaveID (PDF): %s", true, ErrID_To_Name(err));
	else
		ACAPI_WriteReport("Done.", true);

	//delete fsp.file;

	return;
}		// Do_Save_PdfFile&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my menu call to this function:&lt;/P&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;GSErrCode	__ACENV_CALL	MenuCommandHandler (const API_MenuParams *params)
{
	return ACAPI_CallUndoableCommand("JHP_DrawingUpdate Menu Command", [&amp;amp;]() -&amp;gt; GSErrCode {

		switch (params-&amp;gt;menuItemRef.menuResID)
		{
			case JHP_DRAWINGUPDATE_MENU_STRINGSID: {

				switch (params-&amp;gt;menuItemRef.itemIndex)
				{
					case 1: {
						Do_ListDatabases(APIDb_GetLayoutDatabasesID, "layout");
						break;
					}
					case 2: {
						Do_Save_PdfFile();
						break;
					}
					case 3: {...&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Graphisoft documentation on&amp;nbsp;APIDo_SaveID indicates a few causes for this error.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- - the function is called from the notification level; the command is refused if other addons are running.&lt;/STRONG&gt;&lt;/P&gt;&lt;UL class="lia-list-style-type-circle"&gt;&lt;LI&gt;&lt;EM&gt;Notification level???&amp;nbsp; I'm not even sure what that is and how I would get myself off of or away from the notification level&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;Is an addon that is a constant event listener/reactor part of "other addons are running"?&amp;nbsp; I do have that in place.&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;- - cannot be called in the demo version&lt;/STRONG&gt;&lt;/P&gt;&lt;UL class="lia-list-style-type-circle"&gt;&lt;LI&gt;&lt;EM&gt;I am running a fully licensed version and have been since 19.&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;- -&amp;nbsp;cannot be called neither during undoable operations nor during non-undoable commands&lt;/STRONG&gt;&lt;/P&gt;&lt;UL class="lia-list-style-type-circle"&gt;&lt;LI&gt;&lt;EM&gt;I am wrapping my call in&amp;nbsp;ACAPI_CallUndoableCommand, both at the&amp;nbsp;MenuCommandHandler level and the&amp;nbsp;APIDo_SaveID level.&amp;nbsp; Am I doing this wrong?&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or would an API version of Document &amp;gt; Publish with my PDF publisher set be a better approach?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any insight you can provide,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 11:00:07 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-CallUndoableCommand-and-menu-choice-to-create-a-pdf-file/m-p/397867#M8576</guid>
      <dc:creator>MudratDetector</dc:creator>
      <dc:date>2024-09-17T11:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: ACAPI_CallUndoableCommand and menu choice to create a .pdf file</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-CallUndoableCommand-and-menu-choice-to-create-a-pdf-file/m-p/398142#M8584</link>
      <description>&lt;P&gt;Have you tried not wrapping it in a&amp;nbsp;&lt;FONT face="courier new,courier"&gt;ACAPI_CallUndoableCommand&lt;/FONT&gt;? Checking the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Automate_Functions&lt;/FONT&gt; example it doesn't wrap it either, and the documentation states that it doesn't needed.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 14:25:09 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-CallUndoableCommand-and-menu-choice-to-create-a-pdf-file/m-p/398142#M8584</guid>
      <dc:creator>Viktor Kovacs</dc:creator>
      <dc:date>2023-09-13T14:25:09Z</dc:date>
    </item>
  </channel>
</rss>

