<?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: Get list of external linked files in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Get-list-of-external-linked-files/m-p/387439#M968</link>
    <description>&lt;P&gt;After a little more research, I realize the part of the code producing the error is not needed for what I want to do, so &amp;lt;Delete&amp;gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to successfully capture the full path of an external linked file for .dwg and .pdf files.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;========================
Number of Drawings:  10
========================
	Y:\2020\2020063\Drawings\Design\20210514-Midtown_Civil Bases.dwg
	Y:\2020\2020063\Drawings\Consult\Interiors\20211130_Permit Backgr...&lt;/LI-CODE&gt;&lt;P&gt;For .jpg files, I am trying the similarly formatted code I used above for .dwg and .pdf files,&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;	//
	// Pictures
	//
	GS::Array&amp;lt;API_Guid&amp;gt;  picList;
	if (ACAPI_Element_GetElemList(API_PictureID, &amp;amp;picList) != NoError) {
		ACAPI_WriteReport("Error in ACAPI_Element_GetElemList ().", true);
		return;
	}
	else
	{
		ACAPI_WriteReport("========================", false);
		ACAPI_WriteReport("Number of Pictures:  " + GS::UniString(itoa(picList.GetSize(), buffer, 10)), false);
		ACAPI_WriteReport("========================", false);
	}

	for (auto&amp;amp; guid : picList.AsConst()) {
		API_Element picElem = {};
		picElem.header.guid = guid;

		err = ACAPI_Element_Get(&amp;amp;picElem);

		if (err != NoError) {
			ACAPI_WriteReport(GS::UniString::Printf("\tDatabaseControl :: Do_ListDrawingLinks :: Cannot get Drawing with GUID %s.\n", APIGuidToString(guid).ToCStr().Get()), false);
			ACAPI_WriteReport("Error in ACAPI_Element_GetElemList ().", true);
			continue;
		}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this code, I am able to get the collection of pictures and the collection of details, as verified by .GetSize() data.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;========================
Number of Pictures:  76
========================

========================
Number of Details:  88
========================&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, with this code, I am not able to get full path of each.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;========================
Number of Pictures:  76
========================
	DatabaseControl :: Do_ListDrawingLinks :: Cannot get link information for Drawing with GUID 275B9808-DB9E-4370-8446-8FF6A8F9A991.

	DatabaseControl :: Do_ListDrawingLinks :: Cannot get li
...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the appropriate member of&amp;nbsp; the API_ElemTypeID structure.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MudratDetector_0-1689273597901.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/40283iC4192862D10320B0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MudratDetector_0-1689273597901.png" alt="MudratDetector_0-1689273597901.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;APIDb_GetDrawingLinkID used for drawings does not translate well to pictures [APIDb_GetPictureLinkID] or details [APIDb_GetDetailLinkID].&lt;BR /&gt;What can I use in the place of&amp;nbsp;APIDb_GetDrawingLinkID to get full paths of pictures and details?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks - chris&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jul 2023 18:53:21 GMT</pubDate>
    <dc:creator>MudratDetector</dc:creator>
    <dc:date>2023-07-13T18:53:21Z</dc:date>
    <item>
      <title>Get list of external linked files</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Get-list-of-external-linked-files/m-p/387063#M967</link>
      <description>&lt;P&gt;WIN 10 | AC24 | VS2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am writing an add-on to scan all links, inspect external file names, and capture instances where a .bpn file has been linked in or a file from another project folder has been linked in.&amp;nbsp; I am starting with something from the&amp;nbsp; ..\Examples\Database_Control folder.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In&amp;nbsp;Database_Control.cpp there is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// -----------------------------------------------------------------------------
// Dump info for drawing links in the current database
// -----------------------------------------------------------------------------

static void		Do_ListDrawingLinks ()
{
...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have modified it slightly to change the&amp;nbsp;DBPrintf() statements to be&amp;nbsp;ACAPI_WriteReport() statements.&amp;nbsp; This function now reads:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;static void	Do_ListDrawingLinks()
{
	GSErrCode	err = NoError;

	GS::IntPtr	store = 1;
	err = ACAPI_Database(APIDb_StoreViewSettingsID, (void *)store);
	if (err != NoError) {
		store = -1;
		err = NoError;
	}

	API_DatabaseInfo	currentDB;
	BNZeroMemory(&amp;amp;currentDB, sizeof(API_DatabaseInfo));
	ACAPI_Database(APIDb_GetCurrentDatabaseID, &amp;amp;currentDB);

	GS::Array&amp;lt;API_Guid&amp;gt;  drawingList;
	if (ACAPI_Element_GetElemList(API_DrawingID, &amp;amp;drawingList) != NoError) {
		ACAPI_WriteReport("Error in ACAPI_Element_GetElemList ().", true);
		return;
	}

	for (auto&amp;amp; guid : drawingList.AsConst()) {
		API_Element		elem = {};
		elem.header.guid = guid;

		err = ACAPI_Element_Get(&amp;amp;elem);
		char buffer[128];

		ACAPI_WriteReport(itoa(err, buffer, 10), true);
		if (err != NoError) {
			//DBPrintf("DatabaseControl :: Do_ListDrawingLinks :: Cannot get Drawing with GUID %s.\n", APIGuidToString(guid).ToCStr().Get());
			ACAPI_WriteReport(GS::UniString::Printf("DatabaseControl :: Do_ListDrawingLinks :: Cannot get Drawing with GUID %s.\n", APIGuidToString(guid).ToCStr().Get()), false);
			ACAPI_WriteReport("Error in ACAPI_Element_GetElemList ().", true);
			continue;
		}

		API_DrawingLinkInfo		drwLinkInfo;
		err = ACAPI_Database(APIDb_GetDrawingLinkID, (void*)(&amp;amp;(elem.header.guid)), &amp;amp;drwLinkInfo);
		ACAPI_WriteReport(itoa(err, buffer, 10), true);
		if (err != NoError) {
			DBPrintf("DatabaseControl :: Do_ListDrawingLinks :: Cannot get link information for Drawing with GUID %s.\n", APIGuidToString(guid).ToCStr().Get());
			ACAPI_WriteReport(GS::UniString::Printf("DatabaseControl :: Do_ListDrawingLinks :: Cannot get link information for Drawing with GUID %s.\n", APIGuidToString(guid).ToCStr().Get()), false);
			if (drwLinkInfo.linkPath != nullptr)
				delete drwLinkInfo.linkPath;
			if (drwLinkInfo.viewPath != nullptr)
				BMKillPtr(&amp;amp;(drwLinkInfo.viewPath));
			continue;
		}

		//DBPrintf("\tlink No. %ld :", elem.drawing.linkUId);
		ACAPI_WriteReport(GS::UniString::Printf("\tLink No. %ld :", elem.drawing.linkUId), false);
		if (drwLinkInfo.linkPath != nullptr) {
			//DBPrintf("\t%s", drwLinkInfo.linkPath-&amp;gt;ToDisplayText().ToCStr().Get());
			ACAPI_WriteReport(GS::UniString::Printf("\t%s", drwLinkInfo.linkPath-&amp;gt;ToDisplayText().ToCStr().Get()), false);
			delete drwLinkInfo.linkPath;
		}
		else
		{
			ACAPI_WriteReport("drwLinkInfo.linkPath == nullptr", false);
		}

		if (drwLinkInfo.viewPath != nullptr)
			BMKillPtr(&amp;amp;(drwLinkInfo.viewPath));

		if (drwLinkInfo.linkTypeID == API_DrawingLink_InternalViewID)
		{
			ACAPI_WriteReport("IS internal link type...", false);
			//DBPrintf("\t (internal %s, guid: %s)", (drwLinkInfo.viewType == API_ViewNodePerspective || drwLinkInfo.viewType == API_ViewNodeAxonometry) ? "3D view" : "view", APIGuidToString(drwLinkInfo.linkGuid).ToCStr().Get());
			ACAPI_WriteReport(GS::UniString::Printf("\t(0) (internal %s, guid: %s)", (drwLinkInfo.viewType == API_ViewNodePerspective || drwLinkInfo.viewType == API_ViewNodeAxonometry) ? "3D view" : "view", APIGuidToString(drwLinkInfo.linkGuid).ToCStr().Get()), false);
		}
		else
		{
			ACAPI_WriteReport("NOT internal link type...", false);
		}

		if (drwLinkInfo.linkTypeID == API_DrawingLink_ExternalViewID)
		{
			//DBPrintf("\t (internal %s, guid: %s)", (drwLinkInfo.viewType == API_ViewNodePerspective || drwLinkInfo.viewType == API_ViewNodeAxonometry) ? "3D view" : "view", APIGuidToString(drwLinkInfo.linkGuid).ToCStr().Get());
			ACAPI_WriteReport(GS::UniString::Printf("\t(1) (external %s, guid: %s)", (drwLinkInfo.viewType == API_ViewNodePerspective || drwLinkInfo.viewType == API_ViewNodeAxonometry) ? "3D view" : "view", APIGuidToString(drwLinkInfo.linkGuid).ToCStr().Get()), false);
		}
		else
		{
			ACAPI_WriteReport("NOT external link type...", false);
		}

		API_DatabaseInfo	dbInfo;
		BNZeroMemory(&amp;amp;dbInfo, sizeof(API_DatabaseInfo));
		dbInfo.typeID = APIWind_DrawingID;
		dbInfo.linkedElement = elem.header.guid;
		err = ACAPI_Database(APIDb_ChangeCurrentDatabaseID, &amp;amp;dbInfo);
		ACAPI_WriteReport(itoa(err, buffer, 10), true);
		if (err == NoError) {
			GS::Array&amp;lt;API_Guid&amp;gt; elemList;
			ACAPI_Element_GetElemList(API_LineID, &amp;amp;elemList);
			//DBPrintf("\t(number of lines = %ld,", elemList.GetSize());
			ACAPI_WriteReport(GS::UniString::Printf("\t(number of lines = %ld,", elemList.GetSize()), false);

			short	visible, onStory, inView;
			visible = onStory = inView = 0;
			for (auto&amp;amp; elemGuid : elemList.AsConst()) {
				if (ACAPI_Element_Filter(elemGuid, APIFilt_OnVisLayer))
					++visible;
				if (ACAPI_Element_Filter(elemGuid, APIFilt_OnActFloor))
					++onStory;
				if (ACAPI_Element_Filter(elemGuid, APIFilt_InCroppedView))
					++inView;
			}
			//DBPrintf("%d visible, %d on the view\'s floor, %d in the cropped view", visible, onStory, inView);
			ACAPI_WriteReport(GS::UniString::Printf("%d visible, %d on the view\'s floor, %d in the cropped view", visible, onStory, inView), false);

			// Switch back to the original database, because APIDb_ChangeCurrentDatabaseID tries to fetch the drawing element
			//	from the layout's database internally
			ACAPI_Database(APIDb_ChangeCurrentDatabaseID, &amp;amp;currentDB);
		}
		else
		{
			ACAPI_WriteReport(itoa(err, buffer, 10), true);
		}

		//DBPrintf("\n");
		ACAPI_WriteReport("\n", false);

		//DBPrintf("\tName: %s", drwLinkInfo.name);
		ACAPI_WriteReport(GS::UniString::Printf("\tName: %s", drwLinkInfo.name), false);
		//DBPrintf("\n");
		DBPrintf("\n", false);
		//DBPrintf("\tNumber %s", drwLinkInfo.number);
		ACAPI_WriteReport(GS::UniString::Printf("\tNumber %s", drwLinkInfo.number), false);
		//DBPrintf("\n");
		ACAPI_WriteReport("\n", false);

		short userId = 0;
		if (ACAPI_Database(APIDb_GetTWOwnerID, &amp;amp;(dbInfo.databaseUnId), &amp;amp;userId) == NoError)
			//DBPrintf("\tTeamWork owner ID: %d\n", userId);
			ACAPI_WriteReport(GS::UniString::Printf("\tTeamWork owner ID: %d\n", userId), false);
	}

	if (store == 1) {
		store = 0;
		ACAPI_Database(APIDb_StoreViewSettingsID, (void *)store);
	}
}// Do_ListDrawingLinks&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is basically as-is, straight from the ..\Examples folder.&lt;/P&gt;&lt;P&gt;However, I am getting an error with&amp;nbsp;&amp;nbsp;the second to last line:&lt;/P&gt;&lt;P&gt;err = ACAPI_Database(APIDb_ChangeCurrentDatabaseID, &amp;amp;dbInfo);&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;		if (drwLinkInfo.linkTypeID == API_DrawingLink_ExternalViewID)
		{
			//DBPrintf("\t (internal %s, guid: %s)", (drwLinkInfo.viewType == API_ViewNodePerspective || drwLinkInfo.viewType == API_ViewNodeAxonometry) ? "3D view" : "view", APIGuidToString(drwLinkInfo.linkGuid).ToCStr().Get());
			ACAPI_WriteReport(GS::UniString::Printf("\t(1) (external %s, guid: %s)", (drwLinkInfo.viewType == API_ViewNodePerspective || drwLinkInfo.viewType == API_ViewNodeAxonometry) ? "3D view" : "view", APIGuidToString(drwLinkInfo.linkGuid).ToCStr().Get()), false);
		}
		else
		{
			ACAPI_WriteReport("NOT external link type...", false);
		}

		API_DatabaseInfo	dbInfo;
		BNZeroMemory(&amp;amp;dbInfo, sizeof(API_DatabaseInfo));
		dbInfo.typeID = APIWind_DrawingID;
		dbInfo.linkedElement = elem.header.guid;
		err = ACAPI_Database(APIDb_ChangeCurrentDatabaseID, &amp;amp;dbInfo);
		ACAPI_WriteReport(itoa(err, buffer, 10), true);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And my [ACAPI_WriteReport(itoa(err, buffer, 10), true);] produces this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MudratDetector_0-1689105172158.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/40151i9FE0478D281D9C01/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MudratDetector_0-1689105172158.png" alt="MudratDetector_0-1689105172158.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;which translates to this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MudratDetector_1-1689105221302.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/40152i7A381FE694B2E1DD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MudratDetector_1-1689105221302.png" alt="MudratDetector_1-1689105221302.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea what I should be looking for?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to all - Chris&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 19:59:40 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Get-list-of-external-linked-files/m-p/387063#M967</guid>
      <dc:creator>MudratDetector</dc:creator>
      <dc:date>2023-07-11T19:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: Get list of external linked files</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Get-list-of-external-linked-files/m-p/387439#M968</link>
      <description>&lt;P&gt;After a little more research, I realize the part of the code producing the error is not needed for what I want to do, so &amp;lt;Delete&amp;gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to successfully capture the full path of an external linked file for .dwg and .pdf files.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;========================
Number of Drawings:  10
========================
	Y:\2020\2020063\Drawings\Design\20210514-Midtown_Civil Bases.dwg
	Y:\2020\2020063\Drawings\Consult\Interiors\20211130_Permit Backgr...&lt;/LI-CODE&gt;&lt;P&gt;For .jpg files, I am trying the similarly formatted code I used above for .dwg and .pdf files,&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;	//
	// Pictures
	//
	GS::Array&amp;lt;API_Guid&amp;gt;  picList;
	if (ACAPI_Element_GetElemList(API_PictureID, &amp;amp;picList) != NoError) {
		ACAPI_WriteReport("Error in ACAPI_Element_GetElemList ().", true);
		return;
	}
	else
	{
		ACAPI_WriteReport("========================", false);
		ACAPI_WriteReport("Number of Pictures:  " + GS::UniString(itoa(picList.GetSize(), buffer, 10)), false);
		ACAPI_WriteReport("========================", false);
	}

	for (auto&amp;amp; guid : picList.AsConst()) {
		API_Element picElem = {};
		picElem.header.guid = guid;

		err = ACAPI_Element_Get(&amp;amp;picElem);

		if (err != NoError) {
			ACAPI_WriteReport(GS::UniString::Printf("\tDatabaseControl :: Do_ListDrawingLinks :: Cannot get Drawing with GUID %s.\n", APIGuidToString(guid).ToCStr().Get()), false);
			ACAPI_WriteReport("Error in ACAPI_Element_GetElemList ().", true);
			continue;
		}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this code, I am able to get the collection of pictures and the collection of details, as verified by .GetSize() data.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;========================
Number of Pictures:  76
========================

========================
Number of Details:  88
========================&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, with this code, I am not able to get full path of each.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;========================
Number of Pictures:  76
========================
	DatabaseControl :: Do_ListDrawingLinks :: Cannot get link information for Drawing with GUID 275B9808-DB9E-4370-8446-8FF6A8F9A991.

	DatabaseControl :: Do_ListDrawingLinks :: Cannot get li
...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the appropriate member of&amp;nbsp; the API_ElemTypeID structure.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MudratDetector_0-1689273597901.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/40283iC4192862D10320B0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MudratDetector_0-1689273597901.png" alt="MudratDetector_0-1689273597901.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;APIDb_GetDrawingLinkID used for drawings does not translate well to pictures [APIDb_GetPictureLinkID] or details [APIDb_GetDetailLinkID].&lt;BR /&gt;What can I use in the place of&amp;nbsp;APIDb_GetDrawingLinkID to get full paths of pictures and details?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks - chris&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 18:53:21 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Get-list-of-external-linked-files/m-p/387439#M968</guid>
      <dc:creator>MudratDetector</dc:creator>
      <dc:date>2023-07-13T18:53:21Z</dc:date>
    </item>
  </channel>
</rss>

