<?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: [LibPart] Placing on scene from plugin in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/LibPart-Placing-on-scene-from-plugin/m-p/103634#M6395</link>
    <description>&lt;BLOCKQUOTE&gt;bamboos wrote:&lt;BR /&gt;I haven't found any function in ACAPI_LibPart_* to place it on scene and pass parameters to it (like: A, B, alfa);&lt;/BLOCKQUOTE&gt;
You've looked up the definition of a library part, but now you want to place an instance of it. They are completely different things.&lt;BR /&gt;
&lt;BR /&gt;
To place an object in the plan, for example, you need to populate an element data structure, in this case the 'object' member of API_Element (which is of type API_ObjectType), and writing it to the element database with ACAPI_Element_Create.&lt;BR /&gt;
&lt;BR /&gt;
Take a look at APIAny_OpenParametersID (and associated functions) for setting parameter values.</description>
    <pubDate>Wed, 12 Dec 2007 14:27:20 GMT</pubDate>
    <dc:creator>Ralph Wessel</dc:creator>
    <dc:date>2007-12-12T14:27:20Z</dc:date>
    <item>
      <title>[LibPart] Placing on scene from plugin</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/LibPart-Placing-on-scene-from-plugin/m-p/103633#M6394</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hello, &lt;BR /&gt;&lt;BR /&gt;I need to place LibPart using API functions from plugin. Simple Example: &lt;BR /&gt;I've defined box.gsm:
&lt;PRE&gt;XFORM 1, cos(alfa), 0, 0,    
	0, 1, 0, 0,    
	0, 0, 1, 0    
BLOCK A, B, 1&lt;/PRE&gt;
&lt;BR /&gt;&lt;BR /&gt;I've added path to it in plugin:
&lt;PRE&gt;IO::Location rab("D:/GDLobjects/");    
if(!rab.IsValid())    
	throw ElementException("bad location");    
if(ACAPI_Environment (APIEnv_AddLibrariesID, reinterpret_cast&amp;lt;void *&amp;gt;(&amp;amp;rab), NULL) == NoError)    
	_interface-&amp;gt;GetReporter().Report("folder added");    
else    
	throw ElementException("registering location failed");&lt;/PRE&gt;
&lt;BR /&gt;&lt;BR /&gt;And successfully founded and loaded it to memory:
&lt;PRE&gt;API_LibPart part;    
GSErrCode err;    
BNZeroMemory(&amp;amp;part, sizeof(API_LibPart));    
CHANSI2Unicode("box.gsm", strlen("box.gsm"), part.file_UName, API_UniLongNameLen);    
if((err = ACAPI_LibPart_Search(&amp;amp;part, false)) == NoError)    
{    
	if((err = ACAPI_LibPart_Get(&amp;amp;part)) == NoError)    
	{    
		// place on specified location    
	}    
	else    
		_interface-&amp;gt;GetReporter().Report(err);    
}    
else    
	_interface-&amp;gt;GetReporter().Report(err);&lt;/PRE&gt;
&lt;BR /&gt;&lt;BR /&gt;BUT!!! &lt;BR /&gt;&lt;BR /&gt;I haven't found any function in ACAPI_LibPart_* to place it on scene and pass parameters to it (like: A, B, alfa); &lt;BR /&gt;&lt;BR /&gt;Do anyone have examples how to do it... &lt;BR /&gt;&lt;BR /&gt;Thanks for help, I need it badly &lt;BR /&gt;&lt;BR /&gt;-edit- &lt;BR /&gt;&lt;BR /&gt;I found ACAPI_LibPart_ShapePrims, but i have no idea how to use it &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 04 Aug 2023 14:13:10 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/LibPart-Placing-on-scene-from-plugin/m-p/103633#M6394</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-04T14:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: [LibPart] Placing on scene from plugin</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/LibPart-Placing-on-scene-from-plugin/m-p/103634#M6395</link>
      <description>&lt;BLOCKQUOTE&gt;bamboos wrote:&lt;BR /&gt;I haven't found any function in ACAPI_LibPart_* to place it on scene and pass parameters to it (like: A, B, alfa);&lt;/BLOCKQUOTE&gt;
You've looked up the definition of a library part, but now you want to place an instance of it. They are completely different things.&lt;BR /&gt;
&lt;BR /&gt;
To place an object in the plan, for example, you need to populate an element data structure, in this case the 'object' member of API_Element (which is of type API_ObjectType), and writing it to the element database with ACAPI_Element_Create.&lt;BR /&gt;
&lt;BR /&gt;
Take a look at APIAny_OpenParametersID (and associated functions) for setting parameter values.</description>
      <pubDate>Wed, 12 Dec 2007 14:27:20 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/LibPart-Placing-on-scene-from-plugin/m-p/103634#M6395</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2007-12-12T14:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: [LibPart] Placing on scene from plugin</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/LibPart-Placing-on-scene-from-plugin/m-p/103635#M6396</link>
      <description>Helped a LOT!!!&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;

&lt;PRE&gt;API_Element element;
API_ElementMemo memo;
BNZeroMemory(&amp;amp;element, sizeof(API_Element));
BNZeroMemory(&amp;amp;memo, sizeof(API_ElementMemo));
double A = 0;
double B = 0;
long parCount = 0;
//----
element.header.typeID = API_ObjectID;
ACAPI_Element_GetDefaults(&amp;amp;element, &amp;amp;memo);
ACAPI_LibPart_GetParams(part.index, &amp;amp;A, &amp;amp;B, &amp;amp;parCount, &amp;amp;memo.params);
element.object.angle = 0;
element.object.pos.x = 0 + i;
element.object.pos.y = 0 + ii;
element.object.xRatio = A;
element.object.yRatio = B;
element.object.libInd = part.index;
					
ACAPI_Element_Create(&amp;amp;element, &amp;amp;memo);&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Dec 2007 16:44:33 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/LibPart-Placing-on-scene-from-plugin/m-p/103635#M6396</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-12-12T16:44:33Z</dc:date>
    </item>
  </channel>
</rss>

