2022-01-06 12:41 PM - last edited on 2022-01-11 01:59 AM by Laszlo Nagy
Is There a way to get multiple subtractions to he same polygonusing?
Thx for your attention
ch = INITADDONSCOPE ("PolyOperations", "", "")
PREPAREFUNCTION ch, "CreateContainer", "mySourceContainer", ""
PREPAREFUNCTION ch, "CreateContainer", "myDestinationContainer", ""
PREPAREFUNCTION ch, "SetSourceContainer", "mySourceContainer", ""
PREPAREFUNCTION ch, "SetDestinationContainer", "myDestinationContainer", ""
!!!=== 1th Polygon
dim vertArr1[][]
nVertices1 = 4
ii = 0
FOR i = 1 to vardim2(p1_coord) step 2
ii = 1 + ii
vertArr1[ii][1] = p1_coord[1][i]
vertArr1[ii][2] = p1_coord[1][i+1]
vertArr1[ii][3] = 0
NEXT i
ii = 0
PREPAREFUNCTION ch, "Store", "poly1_1", nVertices1, 1, vertArr1, nVertices1
!================
!!! holes polygons
polyg_hole = 2
FOR iii = 1 to polyg_hole
ii = 0
nVertices2 = N_polyg[iii]
FOR i = 1 to nVertices2*2 step 2
ii = 1 + ii
vertArr[ii][1] = pn_coord[iii][i]
vertArr[ii][2] = pn_coord[iii][i+1]
vertArr[ii][3] = 0
NEXT i
ii = 0
nomepoly2 = "poly2_"+str(iii,1,0)
PREPAREFUNCTION ch, "Store", nomepoly2, nVertices2, 1, vertarr, nVertices2
NEXT iii
!!!! ===== 1th operation
numPoly = CALLFUNCTION (ch, "poly1_1 - poly2_1", "", resPolyIDArray)
!!!! ===== 2th operation
polyXXX = ???????? !!=== result of first operation
numPoly = CALLFUNCTION (ch, "polyXXX - poly2_2", "", resPolyIDArray)
.........
!!! see this example https://gdl.graphisoft.com/reference-guide/polygon-operations-extension
for i = 1 to numPoly
polygonID = resPolyIDArray[i]
gosub 100 ! Get one polygon contour data (without contours)
fill 1
pen 1
if nsp > 0 then
poly2_ nsp/3, 2, get(nsp)
endif
line_property 2
gosub 101 ! Draw one polygon contour lines
next i
2022-01-06 12:44 PM
Note; there is missing some code but, i hope, the question is clear.
2022-01-11 07:24 AM
As far as I now You can execute only one operation at a time. For multiple operations You have to substract from the resulting polygon. I think it is easier to use the Dictionary (StoreDictPolygon -parameter etc.) type because the resulting polygon is ready to use in the next loop. The old way is tricky to use.
You can also define the polygon with holes if all holes are inside the contour.
2022-01-11 10:45 AM
Hi,
An operation always works on the source container, and puts the results in the destination container. The IDs of the resulting polygons are returned from CALLFUNCTION in resPolyIDArray. Re-define source and destination containers between operations (this doesn't change the content of the containers).
Be prepared that each operation can result in many polygons, if you are chaining operations the second operation has to be done on each of the results of the first. You can either keep track of returned polygon IDs from many calls, or disregard them and use GetDestinationPolygons to get the content ids when the container contains all results.