<?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: Getting the directory of the current ARCHICAD file? in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243031#M3829</link>
    <description>This is quite straight forward. You just use ACAPI_Enviroment function. API_SpecFolderID is a struct with different key locations to choose form. I'm not sure how it works in Teamwork but I assume that It might be the same since IO:: Location handles both local and net locations.&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;	IO::Location folderLoc;
	API_SpecFolderID specID = API_ApplicationFolderID;
	ACAPI_Environment(APIEnv_GetSpecFolderID, &amp;amp;specID, &amp;amp;folderLoc);
&lt;/PRE&gt;</description>
    <pubDate>Thu, 25 Jul 2019 10:32:37 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-07-25T10:32:37Z</dc:date>
    <item>
      <title>Getting the directory of the current Archicad file?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243028#M3826</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hello &lt;IMG style="display: inline;" src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" border="0" /&gt;&lt;BR /&gt;&lt;BR /&gt;Is there a way to get the directory of the current Archicad file we are working on?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!&lt;/DIV&gt;</description>
      <pubDate>Wed, 05 Oct 2022 11:23:05 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243028#M3826</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-05T11:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the directory of the current ARCHICAD file?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243029#M3827</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
Are you talking about a teamwork project and its libraries ?&lt;BR /&gt;
What's your aim ?</description>
      <pubDate>Thu, 25 Jul 2019 09:42:58 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243029#M3827</guid>
      <dc:creator>Christophe Fortineau</dc:creator>
      <dc:date>2019-07-25T09:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the directory of the current ARCHICAD file?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243030#M3828</link>
      <description>You can use APIEnv_ProjectID method to get the current project info.
&lt;PRE&gt;API_ProjectInfo projectInfo = {};
GSErrCode err = ACAPI_Environment (APIEnv_ProjectID, &amp;amp;projectInfo);
if (err != NoError)
	return GS::EmptyUniString;

if (projectInfo.untitled) // not saved yet
	return GS::EmptyUniString;

if (!projectInfo.teamwork) {
	GS::UniString directoryOfTheProjectStr;
	IO::Location projectLocation = *projectInfo.location;
	projectLocation.DeleteLastLocalName ();
	projectLocation.ToPath (&amp;amp;directoryOfTheProjectStr);

	return directoryOfTheProjectStr;
}&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2019 10:31:56 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243030#M3828</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2019-07-25T10:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the directory of the current ARCHICAD file?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243031#M3829</link>
      <description>This is quite straight forward. You just use ACAPI_Enviroment function. API_SpecFolderID is a struct with different key locations to choose form. I'm not sure how it works in Teamwork but I assume that It might be the same since IO:: Location handles both local and net locations.&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;	IO::Location folderLoc;
	API_SpecFolderID specID = API_ApplicationFolderID;
	ACAPI_Environment(APIEnv_GetSpecFolderID, &amp;amp;specID, &amp;amp;folderLoc);
&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2019 10:32:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243031#M3829</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-25T10:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the directory of the current ARCHICAD file?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243032#M3830</link>
      <description>&lt;BLOCKQUOTE&gt;Tibor wrote:&lt;BR /&gt;
You can use APIEnv_ProjectID method to get the current project info.
&lt;PRE&gt;API_ProjectInfo projectInfo = {};
GSErrCode err = ACAPI_Environment (APIEnv_ProjectID, &amp;amp;projectInfo);
if (err != NoError)
	return GS::EmptyUniString;

if (projectInfo.untitled) // not saved yet
	return GS::EmptyUniString;

if (!projectInfo.teamwork) {
	GS::UniString directoryOfTheProjectStr;
	IO::Location projectLocation = *projectInfo.location;
	projectLocation.DeleteLastLocalName ();
	projectLocation.ToPath (&amp;amp;directoryOfTheProjectStr);

	return directoryOfTheProjectStr;
}&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;

Tried, it gave a bunch of numbers instead of path..&lt;BR /&gt;
I think that projectinfo.projectpath should do it for me maybe?&lt;BR /&gt;
&lt;BR /&gt;
Update:&lt;BR /&gt;
I am unable to get projectpath from some reason. It doesn’t print it and I don’t know how to cast it to string.&lt;BR /&gt;
My aim is to get the path of the current ARCHICAD file I’m working on as a string..&lt;BR /&gt;
&lt;BR /&gt;
My code (seems not to work):
&lt;PRE&gt;GS::UniString GetCurDir(){
API_ProjectInfo pj={};
ACAPI_Environment(APIEnv_ProjectID, &amp;amp;pj);
GS::UniString p=*pj.projectPath;
ACAPI_WriteReport(“%s”,true,p);
return p;
}&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2019 12:32:16 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243032#M3830</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-25T12:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the directory of the current ARCHICAD file?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243033#M3831</link>
      <description>I don't have a working code sample to hand, but something roughly along the following lines should work;&lt;PRE&gt;API_ProjectInfo projectInfo;
ACAPI_Environment(APIEnv_ProjectID, &amp;amp;projectInfo, 0);
if (projectInfo.location != nullptr) {
	IO::Path path;
	projectInfo.location-&amp;gt;ToPath(&amp;amp;path);
}&lt;/PRE&gt;
The variable &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;path&lt;E&gt;&lt;/E&gt; will hold the whole pathname.</description>
      <pubDate>Thu, 25 Jul 2019 21:21:48 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243033#M3831</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2019-07-25T21:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the directory of the current ARCHICAD file?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243034#M3832</link>
      <description>&lt;BLOCKQUOTE&gt;Tomer1 wrote:&lt;BR /&gt;. It doesn’t print it&lt;/BLOCKQUOTE&gt;

Your code is fine. What probably caused a problem is ACAPI_WriteReport. You can print GS::String and UniString directly without %s&lt;BR /&gt;

&lt;PRE&gt;		API_ProjectInfo pj = {};
		ACAPI_Environment(APIEnv_ProjectID, &amp;amp;pj);
		GS::UniString p = *pj.projectPath;
		GS::UniString n = *pj.projectName;

		ACAPI_WriteReport(p, true);
		ACAPI_WriteReport(n, true);&lt;/PRE&gt;

&lt;BLOCKQUOTE&gt;Ralph wrote:&lt;BR /&gt; working code sample&lt;/BLOCKQUOTE&gt;
Tested. This code works. &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;</description>
      <pubDate>Fri, 26 Jul 2019 08:27:12 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243034#M3832</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-26T08:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the directory of the current ARCHICAD file?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243035#M3833</link>
      <description>It’s just doesn’t print, I use the same code as you do.&lt;BR /&gt;
Windows 10, ARCHICAD 21.&lt;BR /&gt;
&lt;BR /&gt;
Update:&lt;BR /&gt;
It finally worked with Ralph’s great code!&lt;BR /&gt;
But I’m unable to get a sub string with substr (want to remove the name of the file)&lt;BR /&gt;
&lt;BR /&gt;
Update 2: succeed to remove the name when using the projectName from location (getlaslocalname).&lt;BR /&gt;
Thanks everyone! &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt;</description>
      <pubDate>Sun, 28 Jul 2019 07:24:56 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Getting-the-directory-of-the-current-Archicad-file/m-p/243035#M3833</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-28T07:24:56Z</dc:date>
    </item>
  </channel>
</rss>

