<?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: Clip Polyline behaviour in multiple cuts in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253468#M2885</link>
    <description>Ok, let's talk about code.&lt;BR /&gt;
&lt;BR /&gt;
This works in AC24. I didn't code regularization, but the input is as it should be. I tried it with another walkaround and the result was the same, so probably it isn't the cause. Maybe you forgot to increment the index in the result ID array when getting the results?&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;poChannel = initaddonscope ("PolyOperations", "", "")
preparefunction poChannel, "CreateContainer",         "inputContainer", ""
preparefunction poChannel, "SetSourceContainer",      "inputContainer", ""
preparefunction poChannel, "CreateContainer",         "resultContainer", ""
preparefunction poChannel, "SetDestinationContainer", "resultContainer", ""

dict polygon
polygon.isClosed = 1
polygon.useEdgeInfo = 0


i = 1
polygon.contour.edges&lt;I&gt;.type		= 0	
polygon.contour.edges&lt;I&gt;.begPoint.x	= 0.0
polygon.contour.edges&lt;I&gt;.begPoint.y	= 0.0

i = i + 1
polygon.contour.edges&lt;I&gt;.type		= 0	
polygon.contour.edges&lt;I&gt;.begPoint.x	= 3.0
polygon.contour.edges&lt;I&gt;.begPoint.y	= 0.0

i = i + 1
polygon.contour.edges&lt;I&gt;.type		= 0	
polygon.contour.edges&lt;I&gt;.begPoint.x	= 3.0
polygon.contour.edges&lt;I&gt;.begPoint.y	= 3.0

i = i + 1
polygon.contour.edges&lt;I&gt;.type		= 0	
polygon.contour.edges&lt;I&gt;.begPoint.x	= 0.0
polygon.contour.edges&lt;I&gt;.begPoint.y	= 3.0

i = 1
polygon.holes[1].edges&lt;I&gt;.type		= 0	
polygon.holes[1].edges&lt;I&gt;.begPoint.x	= 1.0
polygon.holes[1].edges&lt;I&gt;.begPoint.y	= 1.0

i = i + 1
polygon.holes[1].edges&lt;I&gt;.type		= 0	
polygon.holes[1].edges&lt;I&gt;.begPoint.x	= 1.0
polygon.holes[1].edges&lt;I&gt;.begPoint.y	= 2.0

i = i + 1
polygon.holes[1].edges&lt;I&gt;.type		= 0	
polygon.holes[1].edges&lt;I&gt;.begPoint.x	= 2.0
polygon.holes[1].edges&lt;I&gt;.begPoint.y	= 2.0

i = i + 1
polygon.holes[1].edges&lt;I&gt;.type		= 0	
polygon.holes[1].edges&lt;I&gt;.begPoint.x	= 2.0
polygon.holes[1].edges&lt;I&gt;.begPoint.y	= 1.0

preparefunction poChannel, "StoreDictPolygon", "polygon", polygon

iPen = 1
gosub "drawPolyOpPolygon"


dict polyline
polyline.isClosed = 0
polyline.useEdgeInfo = 0

i = 1
polyline.contour.edges&lt;I&gt;.type		= 0	
polyline.contour.edges&lt;I&gt;.begPoint.x	= 0.0
polyline.contour.edges&lt;I&gt;.begPoint.y	= -1.0

i = i + 1
polyline.contour.edges&lt;I&gt;.type		= 0	
polyline.contour.edges&lt;I&gt;.begPoint.x	= 2.5
polyline.contour.edges&lt;I&gt;.begPoint.y	= 2.0

i = i + 1
polyline.contour.edges&lt;I&gt;.type		= 0	
polyline.contour.edges&lt;I&gt;.begPoint.x	= 4.0
polyline.contour.edges&lt;I&gt;.begPoint.y	= 1.0

i = i + 1
polyline.contour.edges&lt;I&gt;.type		= 0	
polyline.contour.edges&lt;I&gt;.begPoint.x	= 6.0
polyline.contour.edges&lt;I&gt;.begPoint.y	= 4.0

iPen = 3
dict polygon : polygon = polyline
gosub "drawPolyOpPolygon"

preparefunction poChannel, "StoreDictPolyline", "polyline", polyline

dim resultIDs[]
nResult = CALLFUNCTION (poChannel, "ClipPolyline", "polyline polygon", resultIDs)

add2 0, 0.01
gosub "drawResultPlines"
del 1
closeaddonscope poChannel
 
end

"drawResultPlines":
	for iResult = 1 to nResult
	 
		dict polygon
		nVertices = callfunction(poChannel, "GetDestinationDictPolyline", resultIDs[iResult], polygon)
		iPen = iPen + 1
		gosub "drawPolyOpPolygon"
	 
	next iResult
return
 
"drawPolyOpPolygon":
	! conversion to status-coded polygon 
	dim outflat[]                   ! declare returned array
	polygon.hasClosingPoint = 0     ! always given without repeating the first point 
	call "ProfileConverter" parameters  bProfileToPolyOp 	   = 0,
						bPolyOpDict        = 1,
						PolyOpPolygon      = polygon,
						returned_parameters	nOut,
									outflat
	
	! put results
	for i = 1 to nOut	           ! without closing point
	
		k = (i - 1) * 3
		put	outflat[k + 1],         ! x
			outflat[k + 2],         ! y
			outflat[k + 3] + 1      ! status
	
	next i
	
	! draw polygon
	pen iPen
	poly2_b NSP / 3, 1 + 2,
		iPen, 0,
		get(NSP)
	
return
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 13 Apr 2021 07:36:37 GMT</pubDate>
    <dc:creator>Peter Baksa</dc:creator>
    <dc:date>2021-04-13T07:36:37Z</dc:date>
    <item>
      <title>Clip Polyline behaviour in multiple cuts</title>
      <link>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253463#M2880</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi GS&lt;BR /&gt;I found that the GDL ClipPolyline operation returns the right amount of cut polylines, but they are all the same ones. Have I missed something or is it a bug? I certainly wish this operation returned all cut polylines.&lt;BR /&gt;-You can move the polyline hotspots and see the results as offset lines compared to the original polyline,&lt;BR /&gt;&lt;BR /&gt;My clip Polyline object&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Sep 2021 07:44:39 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253463#M2880</guid>
      <dc:creator>Pertti Paasky</dc:creator>
      <dc:date>2021-09-14T07:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Clip Polyline behaviour in multiple cuts</title>
      <link>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253464#M2881</link>
      <description>Hi Pertti,&lt;BR /&gt;
&lt;BR /&gt;
I didn't check your code, but the image shows that the hole walkaround is also counterclockwise.&lt;BR /&gt;
Correct results are only guaranteed for &lt;A href="http://gdl.graphisoft.com/reference-guide/polygon-operations-extension#Regularize" target="_blank"&gt;regular polygons&lt;/A&gt;. Regular polygons should have each hole in a clockwise order.&lt;BR /&gt;
Do you have the same issue when it is reversed?&lt;BR /&gt;
Best practice is to regularize polygons before any operation if they depend on parameters.</description>
      <pubDate>Tue, 06 Apr 2021 07:37:49 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253464#M2881</guid>
      <dc:creator>Peter Baksa</dc:creator>
      <dc:date>2021-04-06T07:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Clip Polyline behaviour in multiple cuts</title>
      <link>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253465#M2882</link>
      <description>Ok, Peter. I have never noticed this clockwise rule. What I have seen is that the regularization takes place in some example pbjects. &lt;BR /&gt;
Well, i'll try turning the clocks.&lt;BR /&gt;
Thanks for the answer.</description>
      <pubDate>Tue, 06 Apr 2021 11:42:28 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253465#M2882</guid>
      <dc:creator>Pertti Paasky</dc:creator>
      <dc:date>2021-04-06T11:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Clip Polyline behaviour in multiple cuts</title>
      <link>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253466#M2883</link>
      <description>Hi, I just drew the polylines clockwise, but the result is the same.</description>
      <pubDate>Tue, 06 Apr 2021 11:57:27 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253466#M2883</guid>
      <dc:creator>Pertti Paasky</dc:creator>
      <dc:date>2021-04-06T11:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Clip Polyline behaviour in multiple cuts</title>
      <link>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253467#M2884</link>
      <description>Hi Peter!&lt;BR /&gt;
 You wrote:&lt;BR /&gt;
"Regular polygons should have each hole in a clockwise order."&lt;BR /&gt;
Ok, I tried to regularize the polygon with the dict.option output. It gave me only the outline, not the holes. Should it not do that?&lt;BR /&gt;
As a result, the regularized outlines returned counterclockwise ( the red one) in both directions&lt;BR /&gt;
I also  changed the direction of the hole with no change in results.&lt;BR /&gt;
So please check this function, or is there something I should knowhave not noticed?&lt;BR /&gt;
BR Pertti</description>
      <pubDate>Thu, 08 Apr 2021 20:32:34 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253467#M2884</guid>
      <dc:creator>Pertti Paasky</dc:creator>
      <dc:date>2021-04-08T20:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Clip Polyline behaviour in multiple cuts</title>
      <link>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253468#M2885</link>
      <description>Ok, let's talk about code.&lt;BR /&gt;
&lt;BR /&gt;
This works in AC24. I didn't code regularization, but the input is as it should be. I tried it with another walkaround and the result was the same, so probably it isn't the cause. Maybe you forgot to increment the index in the result ID array when getting the results?&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;poChannel = initaddonscope ("PolyOperations", "", "")
preparefunction poChannel, "CreateContainer",         "inputContainer", ""
preparefunction poChannel, "SetSourceContainer",      "inputContainer", ""
preparefunction poChannel, "CreateContainer",         "resultContainer", ""
preparefunction poChannel, "SetDestinationContainer", "resultContainer", ""

dict polygon
polygon.isClosed = 1
polygon.useEdgeInfo = 0


i = 1
polygon.contour.edges&lt;I&gt;.type		= 0	
polygon.contour.edges&lt;I&gt;.begPoint.x	= 0.0
polygon.contour.edges&lt;I&gt;.begPoint.y	= 0.0

i = i + 1
polygon.contour.edges&lt;I&gt;.type		= 0	
polygon.contour.edges&lt;I&gt;.begPoint.x	= 3.0
polygon.contour.edges&lt;I&gt;.begPoint.y	= 0.0

i = i + 1
polygon.contour.edges&lt;I&gt;.type		= 0	
polygon.contour.edges&lt;I&gt;.begPoint.x	= 3.0
polygon.contour.edges&lt;I&gt;.begPoint.y	= 3.0

i = i + 1
polygon.contour.edges&lt;I&gt;.type		= 0	
polygon.contour.edges&lt;I&gt;.begPoint.x	= 0.0
polygon.contour.edges&lt;I&gt;.begPoint.y	= 3.0

i = 1
polygon.holes[1].edges&lt;I&gt;.type		= 0	
polygon.holes[1].edges&lt;I&gt;.begPoint.x	= 1.0
polygon.holes[1].edges&lt;I&gt;.begPoint.y	= 1.0

i = i + 1
polygon.holes[1].edges&lt;I&gt;.type		= 0	
polygon.holes[1].edges&lt;I&gt;.begPoint.x	= 1.0
polygon.holes[1].edges&lt;I&gt;.begPoint.y	= 2.0

i = i + 1
polygon.holes[1].edges&lt;I&gt;.type		= 0	
polygon.holes[1].edges&lt;I&gt;.begPoint.x	= 2.0
polygon.holes[1].edges&lt;I&gt;.begPoint.y	= 2.0

i = i + 1
polygon.holes[1].edges&lt;I&gt;.type		= 0	
polygon.holes[1].edges&lt;I&gt;.begPoint.x	= 2.0
polygon.holes[1].edges&lt;I&gt;.begPoint.y	= 1.0

preparefunction poChannel, "StoreDictPolygon", "polygon", polygon

iPen = 1
gosub "drawPolyOpPolygon"


dict polyline
polyline.isClosed = 0
polyline.useEdgeInfo = 0

i = 1
polyline.contour.edges&lt;I&gt;.type		= 0	
polyline.contour.edges&lt;I&gt;.begPoint.x	= 0.0
polyline.contour.edges&lt;I&gt;.begPoint.y	= -1.0

i = i + 1
polyline.contour.edges&lt;I&gt;.type		= 0	
polyline.contour.edges&lt;I&gt;.begPoint.x	= 2.5
polyline.contour.edges&lt;I&gt;.begPoint.y	= 2.0

i = i + 1
polyline.contour.edges&lt;I&gt;.type		= 0	
polyline.contour.edges&lt;I&gt;.begPoint.x	= 4.0
polyline.contour.edges&lt;I&gt;.begPoint.y	= 1.0

i = i + 1
polyline.contour.edges&lt;I&gt;.type		= 0	
polyline.contour.edges&lt;I&gt;.begPoint.x	= 6.0
polyline.contour.edges&lt;I&gt;.begPoint.y	= 4.0

iPen = 3
dict polygon : polygon = polyline
gosub "drawPolyOpPolygon"

preparefunction poChannel, "StoreDictPolyline", "polyline", polyline

dim resultIDs[]
nResult = CALLFUNCTION (poChannel, "ClipPolyline", "polyline polygon", resultIDs)

add2 0, 0.01
gosub "drawResultPlines"
del 1
closeaddonscope poChannel
 
end

"drawResultPlines":
	for iResult = 1 to nResult
	 
		dict polygon
		nVertices = callfunction(poChannel, "GetDestinationDictPolyline", resultIDs[iResult], polygon)
		iPen = iPen + 1
		gosub "drawPolyOpPolygon"
	 
	next iResult
return
 
"drawPolyOpPolygon":
	! conversion to status-coded polygon 
	dim outflat[]                   ! declare returned array
	polygon.hasClosingPoint = 0     ! always given without repeating the first point 
	call "ProfileConverter" parameters  bProfileToPolyOp 	   = 0,
						bPolyOpDict        = 1,
						PolyOpPolygon      = polygon,
						returned_parameters	nOut,
									outflat
	
	! put results
	for i = 1 to nOut	           ! without closing point
	
		k = (i - 1) * 3
		put	outflat[k + 1],         ! x
			outflat[k + 2],         ! y
			outflat[k + 3] + 1      ! status
	
	next i
	
	! draw polygon
	pen iPen
	poly2_b NSP / 3, 1 + 2,
		iPen, 0,
		get(NSP)
	
return
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Apr 2021 07:36:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253468#M2885</guid>
      <dc:creator>Peter Baksa</dc:creator>
      <dc:date>2021-04-13T07:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Clip Polyline behaviour in multiple cuts</title>
      <link>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253469#M2886</link>
      <description>Peter, thanks for solving the problem.  The index in the result ID array was the reason as You mentioned.&lt;BR /&gt;
I will carefully study Your code. These operations are not a peace of cake  but I hope to master them.</description>
      <pubDate>Tue, 13 Apr 2021 15:39:43 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253469#M2886</guid>
      <dc:creator>Pertti Paasky</dc:creator>
      <dc:date>2021-04-13T15:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: Clip Polyline behaviour in multiple cuts</title>
      <link>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253470#M2887</link>
      <description>I noticed that in Peter´s code there were defined 4 outline points and 4 hole points in the "StoreDictPolygon" -definition while in the older "Store" definition it is supposed to give 5 points, the first and the last are the same.&lt;BR /&gt;
It seems to work  when You add the first point as the last point in the "StoreDictPolygon" -definition as well. Of course it is more convenient not to add the first point.</description>
      <pubDate>Tue, 13 Apr 2021 17:17:41 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Clip-Polyline-behaviour-in-multiple-cuts/m-p/253470#M2887</guid>
      <dc:creator>Pertti Paasky</dc:creator>
      <dc:date>2021-04-13T17:17:41Z</dc:date>
    </item>
  </channel>
</rss>

