<?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: Fit drawing to Layout(How to change the &amp;quot;bound&amp;quot; in API_DrawingType) in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Fit-drawing-to-Layout-How-to-change-the-quot-bound-quot-in-API/m-p/270212#M2084</link>
    <description>You might also need to adjust the frame polygon in the ElementMemo and cut the drawing with it. The following lines should give you an idea of what to add / change to do this:&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;	ACAPI_ELEMENT_MASK_SET(mask, API_DrawingType, isCutWithFrame);

        //....
	element.drawing.isCutWithFrame = true;

        //....
	if (element.drawing.poly.nCoords != 5
		|| element.drawing.poly.nSubPolys != 1
		|| element.drawing.poly.nArcs != 0) {
		DBPrintf("Can only do rectangular polygons for now!");
		return;
	}

	API_ElementMemo memo;
	err = ACAPI_Element_GetMemo  (element.header.guid, &amp;amp;memo);
	if (err != NoError) {
		DBPrintf ("Couldn't get Element Memo!");
		ACAPI_DisposeElemMemoHdls(&amp;amp;memo);
		return;
	}

	if (memo.coords != nullptr &amp;amp;&amp;amp; memo.pends != nullptr) {
		(*memo.coords)[1].x = element.drawing.bounds.xMin;
		(*memo.coords)[1].y = element.drawing.bounds.yMin;
		(*memo.coords)[2].x = element.drawing.bounds.xMax;
		(*memo.coords)[2].y = element.drawing.bounds.yMin;
		(*memo.coords)[3].x = element.drawing.bounds.xMax;
		(*memo.coords)[3].y = element.drawing.bounds.yMax;
		(*memo.coords)[4].x = element.drawing.bounds.xMin;
		(*memo.coords)[4].y = element.drawing.bounds.yMax;
		(*memo.coords)[5].x = (*memo.coords)[1].x;
		(*memo.coords)[5].y = (*memo.coords)[1].y;
	}

        // Adapt your Element_Change line to this
	err = ACAPI_Element_Change (&amp;amp;element, &amp;amp;mask, &amp;amp;memo, APIMemoMask_All, true);
	ACAPI_DisposeElemMemoHdls(&amp;amp;memo);
&lt;/PRE&gt;</description>
    <pubDate>Mon, 31 May 2021 10:30:25 GMT</pubDate>
    <dc:creator>BerndSchwarzenbacher</dc:creator>
    <dc:date>2021-05-31T10:30:25Z</dc:date>
    <item>
      <title>Fit drawing to Layout(How to change the "bound" in API_DrawingType)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Fit-drawing-to-Layout-How-to-change-the-quot-bound-quot-in-API/m-p/270211#M2083</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;When we place a drawing onto a layout, sometimes the drawing is bigger than the layout so it overlaps.&lt;BR /&gt;What I am trying to achieve is to resize the drawing to fit into the layout? &lt;BR /&gt;&lt;BR /&gt;To achieve this I am trying to chage the ratio ("API_DrawingType.drawing.ratio") but it's not working as expected because can not update the value of the bound("API_DrawingType.bound").
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;GS::Array&amp;lt;API_Guid&amp;gt;  drawingList;
			err = ACAPI_Element_GetElemList(API_DrawingID, &amp;amp;drawingList);
API_Element mask;
				ACAPI_ELEMENT_MASK_CLEAR(mask);
				ACAPI_ELEMENT_MASK_SET(mask, API_DrawingType, nameType);
				ACAPI_ELEMENT_MASK_SET(mask, API_DrawingType, numberingType);
				ACAPI_ELEMENT_MASK_SET(mask, API_DrawingType, name);
				ACAPI_ELEMENT_MASK_SET(mask, API_DrawingType, customNumber);
				ACAPI_ELEMENT_MASK_SET(mask, API_DrawingType, bounds);
				ACAPI_ELEMENT_MASK_SET(mask, API_DrawingType, ratio);

API_Element element = {};
					element.header.guid = drawingGuid;
					err = ACAPI_Element_Get(&amp;amp;element);
					if (err == NoError) {
						element.drawing.nameType = APIName_CustomName;
						element.drawing.numberingType = APINumbering_CustomNum;
						CHCopyC("Test", element.drawing.name);
						CHCopyC("Test", element.drawing.customNumber);
                                                //-----------------------------------------------------------------------------
                                               //Right now doing it manually
                                              //layout size = 392 and drawingSize = 680
                                              //ratio = layout size / drawing size
                                             //          = 392 / 680 = .57647
                                             //---------------------------------------------------------------------------------
						element.drawing.ratio = .57647;
						element.drawing.bounds.xMin = 0.1010;
						element.drawing.bounds.xMax = 0.4929;
						element.drawing.bounds.yMin = 0.0140;
						element.drawing.bounds.yMax = 0.4059;
						err = ACAPI_Element_Change(&amp;amp;element, &amp;amp;mask, nullptr, 0, true);
&lt;/PRE&gt;
Can anyone kindly help me to figure out what's doing wrong and how can I update the bound values here?&lt;BR /&gt;Or is there any other approach to fit the drawing to the layout?&lt;BR /&gt;Thanks in Advance.&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Sep 2021 07:36:52 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Fit-drawing-to-Layout-How-to-change-the-quot-bound-quot-in-API/m-p/270211#M2083</guid>
      <dc:creator>Nayan</dc:creator>
      <dc:date>2021-09-14T07:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Fit drawing to Layout(How to change the "bound" in API_DrawingType)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Fit-drawing-to-Layout-How-to-change-the-quot-bound-quot-in-API/m-p/270212#M2084</link>
      <description>You might also need to adjust the frame polygon in the ElementMemo and cut the drawing with it. The following lines should give you an idea of what to add / change to do this:&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;	ACAPI_ELEMENT_MASK_SET(mask, API_DrawingType, isCutWithFrame);

        //....
	element.drawing.isCutWithFrame = true;

        //....
	if (element.drawing.poly.nCoords != 5
		|| element.drawing.poly.nSubPolys != 1
		|| element.drawing.poly.nArcs != 0) {
		DBPrintf("Can only do rectangular polygons for now!");
		return;
	}

	API_ElementMemo memo;
	err = ACAPI_Element_GetMemo  (element.header.guid, &amp;amp;memo);
	if (err != NoError) {
		DBPrintf ("Couldn't get Element Memo!");
		ACAPI_DisposeElemMemoHdls(&amp;amp;memo);
		return;
	}

	if (memo.coords != nullptr &amp;amp;&amp;amp; memo.pends != nullptr) {
		(*memo.coords)[1].x = element.drawing.bounds.xMin;
		(*memo.coords)[1].y = element.drawing.bounds.yMin;
		(*memo.coords)[2].x = element.drawing.bounds.xMax;
		(*memo.coords)[2].y = element.drawing.bounds.yMin;
		(*memo.coords)[3].x = element.drawing.bounds.xMax;
		(*memo.coords)[3].y = element.drawing.bounds.yMax;
		(*memo.coords)[4].x = element.drawing.bounds.xMin;
		(*memo.coords)[4].y = element.drawing.bounds.yMax;
		(*memo.coords)[5].x = (*memo.coords)[1].x;
		(*memo.coords)[5].y = (*memo.coords)[1].y;
	}

        // Adapt your Element_Change line to this
	err = ACAPI_Element_Change (&amp;amp;element, &amp;amp;mask, &amp;amp;memo, APIMemoMask_All, true);
	ACAPI_DisposeElemMemoHdls(&amp;amp;memo);
&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 May 2021 10:30:25 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Fit-drawing-to-Layout-How-to-change-the-quot-bound-quot-in-API/m-p/270212#M2084</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2021-05-31T10:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Fit drawing to Layout(How to change the "bound" in API_DrawingType)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Fit-drawing-to-Layout-How-to-change-the-quot-bound-quot-in-API/m-p/270213#M2085</link>
      <description>Thanks @bschwb for the reply.&lt;BR /&gt;
If I want to clip/cut the drawing. Let I want to crop / split the drawing to half. In that case should I work with only the memo.coords value?</description>
      <pubDate>Fri, 18 Jun 2021 11:06:21 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Fit-drawing-to-Layout-How-to-change-the-quot-bound-quot-in-API/m-p/270213#M2085</guid>
      <dc:creator>Nayan</dc:creator>
      <dc:date>2021-06-18T11:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Fit drawing to Layout(How to change the "bound" in API_DrawingType)</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Fit-drawing-to-Layout-How-to-change-the-quot-bound-quot-in-API/m-p/270214#M2086</link>
      <description>You should also make sure that element.poly is consistent with the memo.coords values. See &lt;A href="https://archicadapi.graphisoft.com/documentation/api_polygon" target="_blank"&gt;&lt;LINK_TEXT text="https://archicadapi.graphisoft.com/docu ... pi_polygon"&gt;https://archicadapi.graphisoft.com/documentation/api_polygon&lt;/LINK_TEXT&gt;&lt;/A&gt; for more details.&lt;BR /&gt;
&lt;BR /&gt;
I'm unsure what should happen to the element.bounds value if you are clipping the drawing. If I were you I would try two options: 1. keep the element.bounds to the size of the unclipped drawing or 2. also adapt the element.bounds value to the clipped drawing. And then use whichever gives the correct / better results.</description>
      <pubDate>Thu, 01 Jul 2021 08:49:07 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Fit-drawing-to-Layout-How-to-change-the-quot-bound-quot-in-API/m-p/270214#M2086</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2021-07-01T08:49:07Z</dc:date>
    </item>
  </channel>
</rss>

