<?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: Run a script when file is loaded? (C++) in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268286#M2373</link>
    <description>&lt;BLOCKQUOTE&gt;Tomer1 wrote:&lt;BR /&gt;I didn’t check the python api because I know it doesn’t have all the feature that the c++ api provide.&lt;BR /&gt;
I practically really Prefer to only use the c++ api for everything, including what I’m asking here. I have a large and complicated addon with more than 20 classes..&lt;BR /&gt;
Isn’t it possible to do it with the c++ api?&lt;/BLOCKQUOTE&gt;
Yes, it's certainly possible with the C++ API - and has the potential to be  lot better too. I just wanted to be certain the alternatives had been considered.&lt;BR /&gt;
&lt;BR /&gt;
First, what is the intended activation point for your process, i.e. does it need to be triggered by an external application or can it be started within Archicad and then query an external application for the intended process parameters?</description>
    <pubDate>Tue, 04 Aug 2020 15:02:48 GMT</pubDate>
    <dc:creator>Ralph Wessel</dc:creator>
    <dc:date>2020-08-04T15:02:48Z</dc:date>
    <item>
      <title>Run a script when file is loaded? (C++)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268283#M2370</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;My goal is to open a pln file, and to run a script from my addon after my file is loded.&lt;BR /&gt;&lt;BR /&gt;What I want to do is to open bunch of files by an external program, automatically process each on them with my addon.&lt;BR /&gt;&lt;BR /&gt;Thanks a lot!&lt;/DIV&gt;</description>
      <pubDate>Wed, 15 Sep 2021 07:54:58 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268283#M2370</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-15T07:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Run a script when file is loaded? (C++)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268284#M2371</link>
      <description>GS has introduced Python and JSON development features that are primarily supporting external apps driving Archicad. Do you think they might support the actions you intend to perform on the open project?</description>
      <pubDate>Tue, 04 Aug 2020 14:27:48 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268284#M2371</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2020-08-04T14:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: Run a script when file is loaded? (C++)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268285#M2372</link>
      <description>&lt;BLOCKQUOTE&gt;Ralph wrote:&lt;BR /&gt;
GS has introduced Python and JSON development features that are primarily supporting external apps driving Archicad. Do you think they might support the actions you intend to perform on the open project?
&lt;/BLOCKQUOTE&gt;

I didn’t check the python api because I know it doesn’t have all the feature that the c++ api provide.&lt;BR /&gt;
I practically really Prefer to only use the c++ api for everything, including what I’m asking here. I have a large and complicated addon with more than 20 classes..&lt;BR /&gt;
Isn’t it possible to do it with the c++ api?</description>
      <pubDate>Tue, 04 Aug 2020 14:41:53 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268285#M2372</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-04T14:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Run a script when file is loaded? (C++)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268286#M2373</link>
      <description>&lt;BLOCKQUOTE&gt;Tomer1 wrote:&lt;BR /&gt;I didn’t check the python api because I know it doesn’t have all the feature that the c++ api provide.&lt;BR /&gt;
I practically really Prefer to only use the c++ api for everything, including what I’m asking here. I have a large and complicated addon with more than 20 classes..&lt;BR /&gt;
Isn’t it possible to do it with the c++ api?&lt;/BLOCKQUOTE&gt;
Yes, it's certainly possible with the C++ API - and has the potential to be  lot better too. I just wanted to be certain the alternatives had been considered.&lt;BR /&gt;
&lt;BR /&gt;
First, what is the intended activation point for your process, i.e. does it need to be triggered by an external application or can it be started within Archicad and then query an external application for the intended process parameters?</description>
      <pubDate>Tue, 04 Aug 2020 15:02:48 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268286#M2373</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2020-08-04T15:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: Run a script when file is loaded? (C++)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268287#M2374</link>
      <description>&lt;BLOCKQUOTE&gt;Ralph wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;Tomer1 wrote:&lt;BR /&gt;I didn’t check the python api because I know it doesn’t have all the feature that the c++ api provide.&lt;BR /&gt;
I practically really Prefer to only use the c++ api for everything, including what I’m asking here. I have a large and complicated addon with more than 20 classes..&lt;BR /&gt;
Isn’t it possible to do it with the c++ api?&lt;/BLOCKQUOTE&gt;
Yes, it's certainly possible with the C++ API - and has the potential to be  lot better too. I just wanted to be certain the alternatives had been considered.&lt;BR /&gt;
&lt;BR /&gt;
First, what is the intended activation point for your process, i.e. does it need to be triggered by an external application or can it be started within Archicad and then query an external application for the intended process parameters?
&lt;/BLOCKQUOTE&gt;

The activation point is after the file is loaded.&lt;BR /&gt;
Example of the wanted process:&lt;BR /&gt;
1. File.pln is opened on a computer with my addon&lt;BR /&gt;
2. After the file done loading, the addon executes some scripts&lt;BR /&gt;
3. Done &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt;</description>
      <pubDate>Tue, 04 Aug 2020 15:20:54 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268287#M2374</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-04T15:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: Run a script when file is loaded? (C++)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268288#M2375</link>
      <description>&lt;BLOCKQUOTE&gt;Tomer1 wrote:&lt;BR /&gt;The activation point is after the file is loaded.&lt;BR /&gt;
Example of the wanted process:&lt;BR /&gt;
1. File.pln is opened on a computer with my addon&lt;BR /&gt;
2. After the file done loading, the addon executes some scripts&lt;/BLOCKQUOTE&gt;
Assuming that when you say, "File.pln is opened", that means even if the user opens the project:&lt;BR /&gt;
1) When the add-on &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;Initialise&lt;E&gt;&lt;/E&gt; function is called (when it's loaded), call &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;ACAPI_Notify_CatchProjectEvent&lt;E&gt;&lt;/E&gt; so Archicad notifies you when project events occur, e.g. opening/saving/closing etc.&lt;BR /&gt;
&lt;BR /&gt;
2) When Archicad invokes the callback with a project event, check the event type is &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;APINotify_Open&lt;E&gt;&lt;/E&gt;&lt;BR /&gt;
&lt;BR /&gt;
3) You could immediately run whatever process is required on receiving &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;APINotify_Open&lt;E&gt;&lt;/E&gt;, but it's safer to ask Archicad to notify your add-on as soon as it's safe for all kinds of activity (some actions can otherwise cause a crash or be ignored). We do this if we want to display some UI component to the user (e.g. show a palette), validate project content or ensure add-on preferences are loaded/valid.&lt;BR /&gt;
&lt;BR /&gt;
4) To delay processing until an appropriate moment, you can request a callback from Archicad using &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;ACAPI_Command_CallFromEventLoop&lt;E&gt;&lt;/E&gt;. The documentation for this function has a code example you can use. Your callback handler can implement whatever process you need to action on the project. If you intend to modify the project, don't forget to fold your process into &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;ACAPI_CallUndoableCommand&lt;E&gt;&lt;/E&gt;</description>
      <pubDate>Tue, 04 Aug 2020 16:52:15 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268288#M2375</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2020-08-04T16:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Run a script when file is loaded? (C++)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268289#M2376</link>
      <description>&lt;BLOCKQUOTE&gt;Ralph wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;Tomer1 wrote:&lt;BR /&gt;The activation point is after the file is loaded.&lt;BR /&gt;
Example of the wanted process:&lt;BR /&gt;
1. File.pln is opened on a computer with my addon&lt;BR /&gt;
2. After the file done loading, the addon executes some scripts&lt;/BLOCKQUOTE&gt;
Assuming that when you say, "File.pln is opened", that means even if the user opens the project:&lt;BR /&gt;
1) When the add-on &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;Initialise&lt;E&gt;&lt;/E&gt; function is called (when it's loaded), call &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;ACAPI_Notify_CatchProjectEvent&lt;E&gt;&lt;/E&gt; so Archicad notifies you when project events occur, e.g. opening/saving/closing etc.&lt;BR /&gt;
&lt;BR /&gt;
2) When Archicad invokes the callback with a project event, check the event type is &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;APINotify_Open&lt;E&gt;&lt;/E&gt;&lt;BR /&gt;
&lt;BR /&gt;
3) You could immediately run whatever process is required on receiving &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;APINotify_Open&lt;E&gt;&lt;/E&gt;, but it's safer to ask Archicad to notify your add-on as soon as it's safe for all kinds of activity (some actions can otherwise cause a crash or be ignored). We do this if we want to display some UI component to the user (e.g. show a palette), validate project content or ensure add-on preferences are loaded/valid.&lt;BR /&gt;
&lt;BR /&gt;
4) To delay processing until an appropriate moment, you can request a callback from Archicad using &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;ACAPI_Command_CallFromEventLoop&lt;E&gt;&lt;/E&gt;. The documentation for this function has a code example you can use. Your callback handler can implement whatever process you need to action on the project. If you intend to modify the project, don't forget to fold your process into &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;ACAPI_CallUndoableCommand&lt;E&gt;&lt;/E&gt;
&lt;/BLOCKQUOTE&gt;

File.pln is opened means that I opened AC file (Archicad was closed and I double clicked a pln file). Will it work?&lt;BR /&gt;
&lt;BR /&gt;
Edit:&lt;BR /&gt;
Worked after setting the addon to preload&lt;BR /&gt;
Thanks!!</description>
      <pubDate>Wed, 05 Aug 2020 06:23:38 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268289#M2376</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-05T06:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Run a script when file is loaded? (C++)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268290#M2377</link>
      <description>&lt;BLOCKQUOTE&gt;Tomer1 wrote:&lt;BR /&gt;File.pln is opened means that I opened AC file (Archicad was closed and I double clicked a pln file). Will it work?
&lt;/BLOCKQUOTE&gt;
Yes, the notification works for any action that opens a project.</description>
      <pubDate>Wed, 05 Aug 2020 07:31:26 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Run-a-script-when-file-is-loaded-C/m-p/268290#M2377</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2020-08-05T07:31:26Z</dc:date>
    </item>
  </channel>
</rss>

