<?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 How export API_LibPart GSM on computer in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/660431#M10296</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I successfully create a GSM object in Archicad Library, but I don't find a way to export it (or directly create it) on my computer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently, I set the API_LibPart.location in the embeddedLibrary. I tried to set the location on a computer folder and it doesn't work (I get an error -2130312314), I suppose I need to create it in Archicad before exporting it, am I correct?&lt;/P&gt;</description>
    <pubDate>Thu, 24 Apr 2025 06:15:23 GMT</pubDate>
    <dc:creator>LVirone Greisch</dc:creator>
    <dc:date>2025-04-24T06:15:23Z</dc:date>
    <item>
      <title>How export API_LibPart GSM on computer</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/660431#M10296</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I successfully create a GSM object in Archicad Library, but I don't find a way to export it (or directly create it) on my computer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently, I set the API_LibPart.location in the embeddedLibrary. I tried to set the location on a computer folder and it doesn't work (I get an error -2130312314), I suppose I need to create it in Archicad before exporting it, am I correct?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 06:15:23 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/660431#M10296</guid>
      <dc:creator>LVirone Greisch</dc:creator>
      <dc:date>2025-04-24T06:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: How export API_LibPart GSM on computer</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/660511#M10301</link>
      <description>&lt;P&gt;I dont understood your issue exactly, so just a reply about the error code.&lt;BR /&gt;&lt;BR /&gt;See ErrorCodes page of API documentation.&lt;BR /&gt;Error&amp;nbsp;&lt;SPAN&gt;-2130312314 means&amp;nbsp;APIERR_NESTING "The API function is not reentrant. Nesting occurred."&lt;BR /&gt;&lt;BR /&gt;I think it is not location issue.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 13:16:10 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/660511#M10301</guid>
      <dc:creator>Oleg</dc:creator>
      <dc:date>2025-04-24T13:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: How export API_LibPart GSM on computer</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/660618#M10302</link>
      <description>&lt;P&gt;Hello and thanks for the reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've the error -2130313215 the first time I execute my code, then -2130312314 all the next time in the same Archicad instance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The base of my code come from Speckle connector for Archicad, their methods GetLocation() and CreateSubFolder() work fine to create a library part in the embedded library, it failed when I try to set a Windows path. Source code: &lt;A href="https://github.com/specklesystems/speckle-archicad/blob/release/3.0.0/AddOns/Speckle/Sources/AddOn/Converter/SpeckleToHost/LibpartBuilder.cpp" target="_blank" rel="noopener"&gt;https://github.com/specklesystems/speckle-archicad/blob/release/3.0.0/AddOns/Speckle/Sources/AddOn/Converter/SpeckleToHost/LibpartBuilder.cpp&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code I tried:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;API_LibPart libPart;
BNClear(libPart);
BNZeroMemory(&amp;amp;libPart, sizeof(API_LibPart));
libPart.typeID = APILib_ObjectID;
libPart.isTemplate = false;
libPart.isPlaceable = true;

//Location part
IO::Location* loc = new IO::Location();
loc-&amp;gt;Set(GS::UniString("D:\\Test")); //The path I want
libPart.location = loc;

CHCopyC("{57B7C584-5C0D-11D6-A0D8-036F034B6791}-{00000000-0000-0000-0000-000000000000}", libPart.parentUnID); // General Stair subtype
GS::ucscpy(libPart.docu_UName, L("Test LibPart")); //library part name

ACAPI_LibraryPart_Create(&amp;amp;libPart); //This method return the error&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 26 Apr 2025 00:21:39 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/660618#M10302</guid>
      <dc:creator>LVirone Greisch</dc:creator>
      <dc:date>2025-04-26T00:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: How export API_LibPart GSM on computer</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/660656#M10303</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;&lt;BR /&gt;Is this all your code for test ?&lt;BR /&gt;&lt;BR /&gt;PS:&amp;nbsp;&lt;BR /&gt;LibPart creation is a building process, starts by&amp;nbsp;&lt;SPAN&gt;ACAPI_LibraryPart_Create and ends by&amp;nbsp;ACAPI_LibraryPart_Save.&lt;BR /&gt;&lt;/SPAN&gt;LibPart's s&lt;SPAN&gt;ections are created between them&lt;/SPAN&gt;.&lt;BR /&gt;Like in Sparcle's&amp;nbsp;LibpartBuilder::CreateLibPart method.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Apr 2025 16:16:22 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/660656#M10303</guid>
      <dc:creator>Oleg</dc:creator>
      <dc:date>2025-04-25T16:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: How export API_LibPart GSM on computer</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/660664#M10304</link>
      <description>&lt;P&gt;Tried the your code above.&amp;nbsp;&lt;BR /&gt;But added&amp;nbsp;&lt;SPAN&gt;ACAPI_LibraryPart_Save to avoid&amp;nbsp;-2130312314 error.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;It works for me (&lt;SPAN class="aNeGP0gI0B9AV8JaHPyH" data-src-align="0:4"&gt;although&lt;/SPAN&gt; &lt;SPAN class="aNeGP0gI0B9AV8JaHPyH" data-src-align="5:3"&gt;it&lt;/SPAN&gt; &lt;SPAN class="aNeGP0gI0B9AV8JaHPyH" data-src-align="9:3"&gt;wasn&lt;/SPAN&gt;&lt;SPAN class="aNeGP0gI0B9AV8JaHPyH" data-src-align="13:2"&gt;'t&lt;/SPAN&gt;&amp;nbsp;AC&lt;SPAN class="aNeGP0gI0B9AV8JaHPyH" data-src-align="16:2"&gt;28).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="aNeGP0gI0B9AV8JaHPyH" data-src-align="16:2"&gt;If I change drive letter to non-existent on my PC, I got&amp;nbsp;-2130313215 error.&lt;BR /&gt;May be you dont have "D" drive.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Apr 2025 17:37:15 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/660664#M10304</guid>
      <dc:creator>Oleg</dc:creator>
      <dc:date>2025-04-25T17:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: How export API_LibPart GSM on computer</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/661450#M10321</link>
      <description>&lt;P&gt;Hello and thank you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the D on my computer, and yes my full code is longer. For now I'm testing to create a simple box with a custom parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Everything works when I create it in the embedded library, but when I try to set the path I always got the "-2130313215" error at "ACAPI_LibraryPart_Save(&amp;amp;libPart);".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created a folder "C:\Test" on my computer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note I have the error "-2130312310" when tried with path "C://", I suppose I cannot write directly on C.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;My full code :&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;---------------------------------------------------&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;void CreateGSM()
{
API_LibPart libPart;
BNClear(libPart);
BNZeroMemory(&amp;amp;libPart, sizeof(API_LibPart));
libPart.typeID = APILib_ObjectID;
libPart.isTemplate = false;
libPart.isPlaceable = true;
IO::Location* loc = new IO::Location();
loc-&amp;gt;Set(GS::UniString("C:\\Test")); //or "C:\\Test\\"
libPart.location = loc;
CHCopyC("{57B7C584-5C0D-11D6-A0D8-036F034B6791}-{00000000-0000-0000-0000-000000000000}", libPart.parentUnID); // General Stair subtype
GS::ucscpy(libPart.docu_UName, L("Test LibPart"));
CHECK_ERROR(ACAPI_LibraryPart_Create(&amp;amp;libPart));
API_LibPartSection section;
GS::String line;

// Copyright section
BNZeroMemory(&amp;amp;section, sizeof(API_LibPartSection));
section.sectType = API_SectCopyright;
CHECK_ERROR(ACAPI_LibraryPart_NewSection(&amp;amp;section));
line = "Test Author"; // Author
CHECK_ERROR(ACAPI_LibraryPart_WriteSection(line.GetLength(), line.ToCStr()));
CHECK_ERROR(ACAPI_LibraryPart_EndSection());

// 3D script section
BNZeroMemory(&amp;amp;section, sizeof(API_LibPartSection));
section.sectType = API_Sect3DScript;
CHECK_ERROR(ACAPI_LibraryPart_NewSection(&amp;amp;section));
line = "block 1,1,1";
CHECK_ERROR(ACAPI_LibraryPart_WriteSection(line.GetLength(), line.ToCStr()));
CHECK_ERROR(ACAPI_LibraryPart_EndSection());

// Parameter script section
BNZeroMemory(&amp;amp;section, sizeof(API_LibPartSection));
section.sectType = API_SectVLScript;
ACAPI_LibraryPart_NewSection(&amp;amp;section);
ACAPI_LibraryPart_EndSection();

//Parameters script
BNZeroMemory(&amp;amp;section, sizeof(API_LibPartSection));
section.sectType = API_SectParamDef;
short nPars = 2;
API_AddParType** addPars = reinterpret_cast&amp;lt;API_AddParType**&amp;gt;(BMAllocateHandle(nPars * sizeof(API_AddParType), ALLOCATE_CLEAR, 0));
if (addPars != nullptr)
{
API_AddParType* pAddPar = &amp;amp;(*addPars)[0];
pAddPar-&amp;gt;typeID = APIParT_RealNum;
pAddPar-&amp;gt;typeMod = 0;
CHTruncate("SklTestParameter", pAddPar-&amp;gt;name, sizeof(pAddPar-&amp;gt;name));
GS::ucscpy(pAddPar-&amp;gt;uDescname, L("Test Parameter"));
pAddPar-&amp;gt;value.real = 1;
double aa = 1.0;
double bb = 1.0;
GSHandle sectionHdl = nullptr;
ACAPI_LibraryPart_GetSect_ParamDef(&amp;amp;libPart, addPars, &amp;amp;aa, &amp;amp;bb, nullptr, &amp;amp;sectionHdl);
API_LibPartDetails details;
BNZeroMemory(&amp;amp;details, sizeof(API_LibPartDetails));
details.object.autoHotspot = false;
details.object.fixSize = true;
ACAPI_LibraryPart_SetDetails_ParamDef(&amp;amp;libPart, sectionHdl, &amp;amp;details);
ACAPI_LibraryPart_AddSection(&amp;amp;section, sectionHdl, nullptr);
BMKillHandle(reinterpret_cast&amp;lt;GSHandle*&amp;gt;(&amp;amp;addPars));
BMKillHandle(&amp;amp;sectionHdl);
}
else
{
ACAPI_WriteReport("Failed to allocate memory for LibPart parameter.", true);
return;
}

// Save the constructed library part
CHECK_ERROR(ACAPI_LibraryPart_Save(&amp;amp;libPart));
}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;STRONG&gt;---------------------------------------------------&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;In a different .h file:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;---------------------------------------------------&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;#pragma once
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#ifndef CHECK_ERROR
#define CHECK_ERROR(f)\
{\
GSErrCode err = (f);\
if (err != NoError)\
{\
GS::UniString message = "Error in: " + GS::UniString(TOSTRING(f)) + ", Code: " + GS::ValueToUniString(err); \
ACAPI_WriteReport(message, true);\
}\
}
#endif&lt;/LI-CODE&gt;
&lt;P&gt;&lt;STRONG&gt;---------------------------------------------------&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 07 May 2025 12:58:26 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/661450#M10321</guid>
      <dc:creator>LVirone Greisch</dc:creator>
      <dc:date>2025-05-07T12:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: How export API_LibPart GSM on computer</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/661472#M10322</link>
      <description>&lt;P&gt;I dont know a reason, sorry.&lt;BR /&gt;&lt;BR /&gt;Just a last guess.&lt;/P&gt;
&lt;P&gt;May be you run the test on demo archicad and may be the&amp;nbsp;&lt;SPAN&gt;ACAPI_LibraryPart_Save has limitation.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 08:54:47 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/661472#M10322</guid>
      <dc:creator>Oleg</dc:creator>
      <dc:date>2025-05-05T08:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: How export API_LibPart GSM on computer</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/661475#M10323</link>
      <description>&lt;P&gt;Ok no problem, no I'm not on demo because I was afraid of the same thing, I have a full licence and my AddOn has a valid MDID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe its just obsolete in Archicad 28.4001 ? There is this message in the Documentation : &lt;EM&gt;Legacy function - to be deleted in future versions, use ACAPI::LM::GSMObject setters instead&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A href="https://graphisoft.github.io/archicad-api-devkit/group___library_part.html#ga9d6ed5258ccb9669ce890e73f3ff22bb" target="_blank"&gt;https://graphisoft.github.io/archicad-api-devkit/group___library_part.html#ga9d6ed5258ccb9669ce890e73f3ff22bb&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll try again and send the result here if I found something.&lt;/P&gt;&lt;P&gt;Thanks again for all your answers.&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 09:00:22 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/661475#M10323</guid>
      <dc:creator>LVirone Greisch</dc:creator>
      <dc:date>2025-05-05T09:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: How export API_LibPart GSM on computer</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/662345#M10339</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found a solution from the LibPart_Test:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;GS::Array&amp;lt;API_LibraryInfo&amp;gt; libInfo;
ACAPI_LibraryManagement_GetLibraries(&amp;amp;libInfo);

IO::Location folderLoc;

/*API_SpecFolderID specID = API_UserDocumentsFolderID;
ACAPI_ProjectSettings_GetSpecFolder(&amp;amp;specID, &amp;amp;folderLoc);*/

folderLoc = *(new IO::Location());
folderLoc.Set(GS::UniString("D:\\"));

folderLoc.AppendToLocal(IO::Name("LibPart_Test Library"));
IO::Folder destFolder(folderLoc, IO::Folder::Create);

libPart.location = new IO::Location(folderLoc);

bool vari = true;
for (UInt32 ii = 0; ii &amp;lt; libInfo.GetSize(); ii++) {
if (folderLoc == libInfo[ii].location)
vari = false;
}

if(vari)
{
API_LibraryInfo li;
li.location = folderLoc;

libInfo.Push(li);

ACAPI_LibraryManagement_SetLibraries(&amp;amp;libInfo);
}

const GS::UnID unID = BL::BuiltInLibraryMainGuidContainer::GetInstance().GetUnIDWithNullRevGuid(BL::BuiltInLibPartID::ModelElementLibPartID);

CHCopyC(unID.ToUniString().ToCStr(), libPart.parentUnID); // Model Element subtype

GSTimeRecord timeRecord;
TIGetTimeRecord(0, &amp;amp;timeRecord, TI_CURRENT_TIME);
UInt32 fraction = TIGetTicks() % TIGetTicksPerSec();
GS::snuprintf(libPart.docu_UName, sizeof(libPart.docu_UName) / sizeof(GS::uchar_t), L("LPTest_%d-%02d-%02d_%02d%02d%02d_%d"),
timeRecord.year, timeRecord.month, timeRecord.day, timeRecord.hour, timeRecord.minute, timeRecord.second, fraction);



ACAPI_LibraryPart_Create(&amp;amp;libPart);

//Create the libPart here, like in the code in my previous message on this thread

ACAPI_LibraryPart_Save(&amp;amp;libPart);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect the problem come from using GS::ucscpy instead of GS::snuprintf, or maybe using API_LibraryInfo to set the library created.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it works so I'm happy with it ! I get a GSM file at "D:\LibPart_Test Library".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again for your help &lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/12284"&gt;@Oleg&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 May 2025 11:51:12 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-export-API-LibPart-GSM-on-computer/m-p/662345#M10339</guid>
      <dc:creator>LVirone Greisch</dc:creator>
      <dc:date>2025-05-14T11:51:12Z</dc:date>
    </item>
  </channel>
</rss>

