Model many circles in a rectangle using Blender

Dear friends,
I’m new in Blender, and I have a problem. I want to model many circles in a rectangle (35035) , these circles should not overlap with each other.
I have tried to use Python. The problem is:
1, after I run the script, I can only select all the generated rectangles, not one rectangle;
2.How can I link the vertex of the rectangles and make face for my complex model automatically? I have many different models, here just is one model, that means the circle position and diameters are always different.
Well, the script is:
import Blender
from Blender import NMesh
import math
from math import

me=NMesh.GetRaw()
v=NMesh.Vert(152.555,24.1243,0)
me.verts.append(v)
v=NMesh.Vert(155.959,24.1243,0)
me.verts.append(v)
v=NMesh.Vert(152.555,20.7207,0)
me.verts.append(v)
v=NMesh.Vert(155.959,20.7207,0)
me.verts.append(v)
v=NMesh.Vert(267.692,32.5692,0)
me.verts.append(v)
v=NMesh.Vert(271.836,32.5692,0)
me.verts.append(v)
v=NMesh.Vert(267.692,28.4252,0)
me.verts.append(v)
v=NMesh.Vert(271.836,28.4252,0)
me.verts.append(v)
v=NMesh.Vert(80.8457,20.2476,0)
me.verts.append(v)
v=NMesh.Vert(81.5399,20.2476,0)
me.verts.append(v)
v=NMesh.Vert(80.8457,19.5534,0)
me.verts.append(v)
v=NMesh.Vert(81.5399,19.5534,0)
me.verts.append(v)
v=NMesh.Vert(171.235,20.0197,0)
me.verts.append(v)
v=NMesh.Vert(172.001,20.0197,0)
me.verts.append(v)
v=NMesh.Vert(171.235,19.2541,0)
me.verts.append(v)
v=NMesh.Vert(172.001,19.2541,0)
me.verts.append(v)
v=NMesh.Vert(34.2993,28.8916,0)
me.verts.append(v)
v=NMesh.Vert(40.9825,28.8916,0)
me.verts.append(v)
v=NMesh.Vert(34.2993,22.2084,0)
me.verts.append(v)
v=NMesh.Vert(40.9825,22.2084,0)
me.verts.append(v)
v=NMesh.Vert(149.384,11.2851,0)
me.verts.append(v)
v=NMesh.Vert(152.13,11.2851,0)
me.verts.append(v)
v=NMesh.Vert(149.384,8.53831,0)
me.verts.append(v)
v=NMesh.Vert(152.13,8.53831,0)
me.verts.append(v)
v=NMesh.Vert(236.045,3.09922,0)
me.verts.append(v)
v=NMesh.Vert(236.929,3.09922,0)
me.verts.append(v)
v=NMesh.Vert(236.045,2.21428,0)
me.verts.append(v)
v=NMesh.Vert(236.929,2.21428,0)
me.verts.append(v)
v=NMesh.Vert(148.768,16.892,0)
me.verts.append(v)
v=NMesh.Vert(152.352,16.892,0)
me.verts.append(v)
v=NMesh.Vert(148.768,13.3072,0)
me.verts.append(v)
v=NMesh.Vert(152.352,13.3072,0)
me.verts.append(v)
v=NMesh.Vert(258.497,20.6577,0)
me.verts.append(v)
v=NMesh.Vert(259.985,20.6577,0)
me.verts.append(v)
v=NMesh.Vert(258.497,19.1691,0)
me.verts.append(v)
v=NMesh.Vert(259.985,19.1691,0)
me.verts.append(v)
v=NMesh.Vert(345.794,20.1197,0)
me.verts.append(v)
v=NMesh.Vert(348.138,20.1197,0)
me.verts.append(v)
v=NMesh.Vert(345.794,17.7765,0)
me.verts.append(v)
v=NMesh.Vert(348.138,17.7765,0)
me.verts.append(v)
v=NMesh.Vert(115.974,16.9822,0)
me.verts.append(v)
v=NMesh.Vert(117.59,16.9822,0)
me.verts.append(v)
#wait for continuing…
([email protected])

v=NMesh.Vert(115.974,15.3654,0)
me.verts.append(v)
v=NMesh.Vert(117.59,15.3654,0)
me.verts.append(v)
v=NMesh.Vert(271.402,29.013,0)
me.verts.append(v)
v=NMesh.Vert(272.566,29.013,0)
me.verts.append(v)
v=NMesh.Vert(271.402,27.8484,0)
me.verts.append(v)
v=NMesh.Vert(272.566,27.8484,0)
me.verts.append(v)
v=NMesh.Vert(207.203,4.2401,0)
me.verts.append(v)
v=NMesh.Vert(209.683,4.2401,0)
me.verts.append(v)
v=NMesh.Vert(207.203,1.75944,0)
me.verts.append(v)
v=NMesh.Vert(209.683,1.75944,0)
me.verts.append(v)
v=NMesh.Vert(85.5224,32.1263,0)
me.verts.append(v)
v=NMesh.Vert(87.3386,32.1263,0)
me.verts.append(v)
v=NMesh.Vert(85.5224,30.3101,0)
me.verts.append(v)
v=NMesh.Vert(87.3386,30.3101,0)
me.verts.append(v)
v=NMesh.Vert(219.549,23.3296,0)
me.verts.append(v)
v=NMesh.Vert(220.861,23.3296,0)
me.verts.append(v)
v=NMesh.Vert(219.549,22.0174,0)
me.verts.append(v)
v=NMesh.Vert(220.861,22.0174,0)
me.verts.append(v)
v=NMesh.Vert(116.181,20.5656,0)
me.verts.append(v)
v=NMesh.Vert(117.759,20.5656,0)
me.verts.append(v)
v=NMesh.Vert(116.181,18.9882,0)
me.verts.append(v)
v=NMesh.Vert(117.759,18.9882,0)
me.verts.append(v)
v=NMesh.Vert(298.473,24.916,0)
me.verts.append(v)
v=NMesh.Vert(302.937,24.916,0)
me.verts.append(v)
v=NMesh.Vert(298.473,20.4516,0)
me.verts.append(v)
v=NMesh.Vert(302.937,20.4516,0)
me.verts.append(v)
v=NMesh.Vert(313.271,11.5799,0)
me.verts.append(v)
v=NMesh.Vert(320.703,11.5799,0)
me.verts.append(v)
v=NMesh.Vert(313.271,4.14829,0)
me.verts.append(v)
v=NMesh.Vert(320.703,4.14829,0)
me.verts.append(v)
v=NMesh.Vert(253.69,34.4084,0)
me.verts.append(v)
v=NMesh.Vert(259.688,34.4084,0)
me.verts.append(v)
v=NMesh.Vert(253.69,28.4106,0)
me.verts.append(v)
v=NMesh.Vert(259.688,28.4106,0)
me.verts.append(v)
v=NMesh.Vert(290.611,31.9291,0)
me.verts.append(v)
v=NMesh.Vert(292.947,31.9291,0)
me.verts.append(v)
v=NMesh.Vert(290.611,29.5935,0)
me.verts.append(v)
v=NMesh.Vert(292.947,29.5935,0)
me.verts.append(v)
v=NMesh.Vert(271.061,21.6521,0)
me.verts.append(v)
v=NMesh.Vert(274.633,21.6521,0)
me.verts.append(v)
v=NMesh.Vert(271.061,18.081,0)
me.verts.append(v)
v=NMesh.Vert(274.633,18.081,0)
me.verts.append(v)
v=NMesh.Vert(181.88,19.0508,0)
me.verts.append(v)
v=NMesh.Vert(183.86,19.0508,0)
me.verts.append(v)
v=NMesh.Vert(181.88,17.0698,0)
me.verts.append(v)
v=NMesh.Vert(183.86,17.0698,0)
me.verts.append(v)
v=NMesh.Vert(143.313,27.635,0)
me.verts.append(v)
v=NMesh.Vert(146.193,27.635,0)
me.verts.append(v)
v=NMesh.Vert(143.313,24.7552,0)
me.verts.append(v)
v=NMesh.Vert(146.193,24.7552,0)
me.verts.append(v)
v=NMesh.Vert(45.4074,18.6421,0)
me.verts.append(v)
v=NMesh.Vert(47.574,18.6421,0)
me.verts.append(v)
v=NMesh.Vert(45.4074,16.4755,0)
me.verts.append(v)
v=NMesh.Vert(47.574,16.4755,0)
me.verts.append(v)
v=NMesh.Vert(20.3476,17.7049,0)
me.verts.append(v)
v=NMesh.Vert(22.3848,17.7049,0)
me.verts.append(v)
v=NMesh.Vert(20.3476,15.6677,0)
me.verts.append(v)
v=NMesh.Vert(22.3848,15.6677,0)
me.verts.append(v)
v=NMesh.Vert(108.082,26.9924,0)
me.verts.append(v)
v=NMesh.Vert(110.84,26.9924,0)
me.verts.append(v)
v=NMesh.Vert(108.082,24.2342,0)
me.verts.append(v)
v=NMesh.Vert(110.84,24.2342,0)
me.verts.append(v)
v=NMesh.Vert(312.146,28.7299,0)
me.verts.append(v)
v=NMesh.Vert(313.324,28.7299,0)
me.verts.append(v)
v=NMesh.Vert(312.146,27.5523,0)
me.verts.append(v)
v=NMesh.Vert(313.324,27.5523,0)
me.verts.append(v)
v=NMesh.Vert(336.219,31.6648,0)
me.verts.append(v)
v=NMesh.Vert(337.381,31.6648,0)
me.verts.append(v)
v=NMesh.Vert(336.219,30.502,0)
me.verts.append(v)
v=NMesh.Vert(337.381,30.502,0)
me.verts.append(v)
v=NMesh.Vert(172.613,29.4427,0)
me.verts.append(v)
v=NMesh.Vert(174.887,29.4427,0)
me.verts.append(v)
v=NMesh.Vert(172.613,27.1681,0)
me.verts.append(v)
v=NMesh.Vert(174.887,27.1681,0)
me.verts.append(v)
v=NMesh.Vert(159.917,30.4582,0)
me.verts.append(v)
v=NMesh.Vert(160.343,30.4582,0)
me.verts.append(v)
v=NMesh.Vert(159.917,30.0314,0)
me.verts.append(v)
v=NMesh.Vert(160.343,30.0314,0)
me.verts.append(v)
v=NMesh.Vert(267.358,13.8665,0)
me.verts.append(v)
v=NMesh.Vert(269.246,13.8665,0)
me.verts.append(v)
v=NMesh.Vert(267.358,11.9775,0)
me.verts.append(v)
v=NMesh.Vert(269.246,11.9775,0)
me.verts.append(v)
v=NMesh.Vert(160.43,32.011,0)
me.verts.append(v)
v=NMesh.Vert(164.002,32.011,0)
me.verts.append(v)
v=NMesh.Vert(160.43,28.4398,0)
me.verts.append(v)
v=NMesh.Vert(164.002,28.4398,0)
me.verts.append(v)
v=NMesh.Vert(237.138,7.40719,0)
me.verts.append(v)
v=NMesh.Vert(242.248,7.40719,0)
me.verts.append(v)
v=NMesh.Vert(237.138,2.29813,0)
me.verts.append(v)
v=NMesh.Vert(242.248,2.29813,0)
me.verts.append(v)
v=NMesh.Vert(190.663,9.24962,0)
me.verts.append(v)
v=NMesh.Vert(193.925,9.24962,0)
me.verts.append(v)
v=NMesh.Vert(190.663,5.98806,0)
me.verts.append(v)
v=NMesh.Vert(193.925,5.98806,0)
me.verts.append(v)
v=NMesh.Vert(72.7731,30.9333,0)
me.verts.append(v)
v=NMesh.Vert(73.2033,30.9333,0)
me.verts.append(v)
v=NMesh.Vert(72.7731,30.5031,0)
me.verts.append(v)
v=NMesh.Vert(73.2033,30.5031,0)
me.verts.append(v)
v=NMesh.Vert(211.35,7.54844,0)
me.verts.append(v)
v=NMesh.Vert(215.99,7.54844,0)
me.verts.append(v)
v=NMesh.Vert(211.35,2.90774,0)
me.verts.append(v)
v=NMesh.Vert(215.99,2.90774,0)
me.verts.append(v)
v=NMesh.Vert(250.386,12.3497,0)
me.verts.append(v)
v=NMesh.Vert(251.758,12.3497,0)
me.verts.append(v)
v=NMesh.Vert(250.386,10.9783,0)
me.verts.append(v)
v=NMesh.Vert(251.758,10.9783,0)
me.verts.append(v)
v=NMesh.Vert(81.7594,28.7684,0)
me.verts.append(v)
v=NMesh.Vert(86.284,28.7684,0)
me.verts.append(v)
v=NMesh.Vert(81.7594,24.2438,0)
me.verts.append(v)
v=NMesh.Vert(86.284,24.2438,0)
me.verts.append(v)
v=NMesh.Vert(86.0227,15.4269,0)
me.verts.append(v)
v=NMesh.Vert(88.3491,15.4269,0)
me.verts.append(v)
v=NMesh.Vert(86.0227,13.1005,0)
me.verts.append(v)
v=NMesh.Vert(88.3491,13.1005,0)
me.verts.append(v)
v=NMesh.Vert(32.9199,17.8929,0)
me.verts.append(v)
v=NMesh.Vert(41.3727,17.8929,0)
me.verts.append(v)
v=NMesh.Vert(32.9199,9.44013,0)
me.verts.append(v)
v=NMesh.Vert(41.3727,9.44013,0)
me.verts.append(v)
v=NMesh.Vert(205.26,5.34521,0)
me.verts.append(v)
v=NMesh.Vert(206.09,5.34521,0)
me.verts.append(v)
v=NMesh.Vert(205.26,4.51491,0)
me.verts.append(v)
v=NMesh.Vert(206.09,4.51491,0)
me.verts.append(v)
v=NMesh.Vert(66.3538,33.5048,0)
me.verts.append(v)
v=NMesh.Vert(70.3623,33.5048,0)
me.verts.append(v)
v=NMesh.Vert(66.3538,29.4964,0)
me.verts.append(v)
v=NMesh.Vert(70.3623,29.4964,0)
me.verts.append(v)
v=NMesh.Vert(207.331,21.5442,0)
me.verts.append(v)
v=NMesh.Vert(209.353,21.5442,0)
me.verts.append(v)
v=NMesh.Vert(207.331,19.5228,0)
me.verts.append(v)
v=NMesh.Vert(209.353,19.5228,0)
me.verts.append(v)
v=NMesh.Vert(124.588,26.7362,0)
me.verts.append(v)
v=NMesh.Vert(131.362,26.7362,0)
me.verts.append(v)
v=NMesh.Vert(124.588,19.9626,0)
me.verts.append(v)
v=NMesh.Vert(131.362,19.9626,0)
me.verts.append(v)
v=NMesh.Vert(144.08,11.243,0)
me.verts.append(v)
v=NMesh.Vert(144.746,11.243,0)
me.verts.append(v)
v=NMesh.Vert(144.08,10.577,0)
me.verts.append(v)
v=NMesh.Vert(144.746,10.577,0)
me.verts.append(v)
v=NMesh.Vert(288.061,14.961,0)
me.verts.append(v)
v=NMesh.Vert(289.663,14.961,0)
me.verts.append(v)
v=NMesh.Vert(288.061,13.3598,0)
me.verts.append(v)
v=NMesh.Vert(289.663,13.3598,0)
me.verts.append(v)
v=NMesh.Vert(90.7371,7.44744,0)
me.verts.append(v)
v=NMesh.Vert(96.7417,7.44744,0)
me.verts.append(v)
v=NMesh.Vert(90.7371,1.44291,0)
me.verts.append(v)
v=NMesh.Vert(96.7417,1.44291,0)
me.verts.append(v)
v=NMesh.Vert(132.036,9.65626,0)
me.verts.append(v)
v=NMesh.Vert(134.19,9.65626,0)
me.verts.append(v)
v=NMesh.Vert(132.036,7.50157,0)
me.verts.append(v)
v=NMesh.Vert(134.19,7.50157,0)
me.verts.append(v)
v=NMesh.Vert(183.188,13.6073,0)
me.verts.append(v)
v=NMesh.Vert(184.673,13.6073,0)
me.verts.append(v)
v=NMesh.Vert(183.188,12.1223,0)
me.verts.append(v)
v=NMesh.Vert(184.673,12.1223,0)
me.verts.append(v)
v=NMesh.Vert(184.103,14.5615,0)
me.verts.append(v)
v=NMesh.Vert(184.911,14.5615,0)
me.verts.append(v)
v=NMesh.Vert(184.103,13.7545,0)
me.verts.append(v)
v=NMesh.Vert(184.911,13.7545,0)
me.verts.append(v)
v=NMesh.Vert(344.045,17.2246,0)
me.verts.append(v)
v=NMesh.Vert(344.695,17.2246,0)
me.verts.append(v)
v=NMesh.Vert(344.045,16.5756,0)
me.verts.append(v)
v=NMesh.Vert(344.695,16.5756,0)
me.verts.append(v)
v=NMesh.Vert(150.444,19.8617,0)
me.verts.append(v)
v=NMesh.Vert(152.574,19.8617,0)
me.verts.append(v)
v=NMesh.Vert(150.444,17.7313,0)
me.verts.append(v)
v=NMesh.Vert(152.574,17.7313,0)
me.verts.append(v)
v=NMesh.Vert(169.367,10.5882,0)
me.verts.append(v)
v=NMesh.Vert(170.569,10.5882,0)
me.verts.append(v)
v=NMesh.Vert(169.367,9.38674,0)
me.verts.append(v)
v=NMesh.Vert(170.569,9.38674,0)
me.verts.append(v)
v=NMesh.Vert(213.772,21.012,0)
me.verts.append(v)
v=NMesh.Vert(217.976,21.012,0)
me.verts.append(v)
v=NMesh.Vert(213.772,16.8078,0)
me.verts.append(v)
v=NMesh.Vert(217.976,16.8078,0)
me.verts.append(v)
v=NMesh.Vert(328.818,8.69845,0)
me.verts.append(v)
v=NMesh.Vert(329.486,8.69845,0)
me.verts.append(v)
v=NMesh.Vert(328.818,8.02963,0)
me.verts.append(v)
v=NMesh.Vert(329.486,8.02963,0)
me.verts.append(v)
v=NMesh.Vert(220.213,28.1367,0)
me.verts.append(v)
v=NMesh.Vert(222.077,28.1367,0)
me.verts.append(v)
v=NMesh.Vert(220.213,26.2729,0)
me.verts.append(v)
v=NMesh.Vert(222.077,26.2729,0)
me.verts.append(v)
v=NMesh.Vert(152.743,2.10078,0)
me.verts.append(v)
v=NMesh.Vert(153.943,2.10078,0)
me.verts.append(v)
v=NMesh.Vert(152.743,0.900225,0)
me.verts.append(v)
v=NMesh.Vert(153.943,0.900225,0)
me.verts.append(v)
v=NMesh.Vert(346.236,9.44955,0)
me.verts.append(v)

v=NMesh.Vert(346.8,9.44955,0)
me.verts.append(v)
v=NMesh.Vert(346.236,8.88523,0)
me.verts.append(v)
v=NMesh.Vert(346.8,8.88523,0)
me.verts.append(v)
v=NMesh.Vert(209.194,6.57906,0)
me.verts.append(v)
v=NMesh.Vert(209.76,6.57906,0)
me.verts.append(v)
v=NMesh.Vert(209.194,6.01274,0)
me.verts.append(v)
v=NMesh.Vert(209.76,6.01274,0)
me.verts.append(v)
v=NMesh.Vert(49.6419,4.34804,0)
me.verts.append(v)
v=NMesh.Vert(52.4281,4.34804,0)
me.verts.append(v)
v=NMesh.Vert(49.6419,1.56194,0)
me.verts.append(v)
v=NMesh.Vert(52.4281,1.56194,0)
me.verts.append(v)
v=NMesh.Vert(339.724,23.4705,0)
me.verts.append(v)
v=NMesh.Vert(340.312,23.4705,0)
me.verts.append(v)
v=NMesh.Vert(339.724,22.8819,0)
me.verts.append(v)
v=NMesh.Vert(340.312,22.8819,0)
me.verts.append(v)
v=NMesh.Vert(2.24495,27.1212,0)
me.verts.append(v)
v=NMesh.Vert(2.81699,27.1212,0)
me.verts.append(v)
v=NMesh.Vert(2.24495,26.5492,0)
me.verts.append(v)
v=NMesh.Vert(2.81699,26.5492,0)
me.verts.append(v)
v=NMesh.Vert(242.422,19.768,0)
me.verts.append(v)
v=NMesh.Vert(243.042,19.768,0)
me.verts.append(v)
v=NMesh.Vert(242.422,19.1472,0)
me.verts.append(v)
v=NMesh.Vert(243.042,19.1472,0)
me.verts.append(v)
v=NMesh.Vert(101.411,17.1297,0)
me.verts.append(v)
v=NMesh.Vert(103.089,17.1297,0)
me.verts.append(v)
v=NMesh.Vert(101.411,15.4525,0)
me.verts.append(v)
v=NMesh.Vert(103.089,15.4525,0)
me.verts.append(v)
v=NMesh.Vert(30.9044,11.6417,0)
me.verts.append(v)
v=NMesh.Vert(33.513,11.6417,0)
me.verts.append(v)
v=NMesh.Vert(30.9044,9.03309,0)
me.verts.append(v)

wait for continue…

v=NMesh.Vert(33.513,9.03309,0)
me.verts.append(v)
v=NMesh.Vert(230.132,15.6338,0)
me.verts.append(v)
v=NMesh.Vert(231.91,15.6338,0)
me.verts.append(v)
v=NMesh.Vert(230.132,13.8564,0)
me.verts.append(v)
v=NMesh.Vert(231.91,13.8564,0)
me.verts.append(v)
v=NMesh.Vert(342.511,28.6601,0)
me.verts.append(v)
v=NMesh.Vert(343.117,28.6601,0)
me.verts.append(v)
v=NMesh.Vert(342.511,28.0539,0)
me.verts.append(v)
v=NMesh.Vert(343.117,28.0539,0)
me.verts.append(v)
v=NMesh.Vert(156.924,24,0)
me.verts.append(v)
v=NMesh.Vert(159.356,24,0)
me.verts.append(v)
v=NMesh.Vert(156.924,21.5678,0)
me.verts.append(v)
v=NMesh.Vert(159.356,21.5678,0)
me.verts.append(v)
v=NMesh.Vert(242.963,14.9486,0)
me.verts.append(v)
v=NMesh.Vert(245.987,14.9486,0)
me.verts.append(v)
v=NMesh.Vert(242.963,11.924,0)
me.verts.append(v)
v=NMesh.Vert(245.987,11.924,0)
me.verts.append(v)
v=NMesh.Vert(245.1,31.826,0)
me.verts.append(v)
v=NMesh.Vert(245.512,31.826,0)
me.verts.append(v)
v=NMesh.Vert(245.1,31.414,0)
me.verts.append(v)
v=NMesh.Vert(245.512,31.414,0)
me.verts.append(v)
v=NMesh.Vert(324.436,8.22193,0)
me.verts.append(v)
v=NMesh.Vert(325.088,8.22193,0)
me.verts.append(v)
v=NMesh.Vert(324.436,7.56995,0)
me.verts.append(v)
v=NMesh.Vert(325.088,7.56995,0)
me.verts.append(v)
v=NMesh.Vert(17.7038,2.83799,0)
me.verts.append(v)
v=NMesh.Vert(20.0826,2.83799,0)
me.verts.append(v)
v=NMesh.Vert(17.7038,0.459225,0)
me.verts.append(v)
v=NMesh.Vert(20.0826,0.459225,0)
me.verts.append(v)
v=NMesh.Vert(32.7911,32.9762,0)
me.verts.append(v)
v=NMesh.Vert(34.1735,32.9762,0)
me.verts.append(v)
v=NMesh.Vert(32.7911,31.5938,0)
me.verts.append(v)
v=NMesh.Vert(34.1735,31.5938,0)
me.verts.append(v)
v=NMesh.Vert(77.0491,26.3816,0)
me.verts.append(v)
v=NMesh.Vert(78.2919,26.3816,0)
me.verts.append(v)
v=NMesh.Vert(77.0491,25.1388,0)
me.verts.append(v)
v=NMesh.Vert(78.2919,25.1388,0)
me.verts.append(v)
v=NMesh.Vert(252.961,30.9644,0)
me.verts.append(v)
v=NMesh.Vert(253.765,30.9644,0)
me.verts.append(v)
v=NMesh.Vert(252.961,30.161,0)
me.verts.append(v)
v=NMesh.Vert(253.765,30.161,0)
me.verts.append(v)
v=NMesh.Vert(187.92,8.423,0)
me.verts.append(v)
v=NMesh.Vert(189.538,8.423,0)
me.verts.append(v)
v=NMesh.Vert(187.92,6.80402,0)
me.verts.append(v)
v=NMesh.Vert(189.538,6.80402,0)
me.verts.append(v)
v=NMesh.Vert(31.5671,2.13911,0)
me.verts.append(v)
v=NMesh.Vert(32.5825,2.13911,0)
me.verts.append(v)
v=NMesh.Vert(31.5671,1.12369,0)
me.verts.append(v)
v=NMesh.Vert(32.5825,1.12369,0)
me.verts.append(v)
v=NMesh.Vert(286.779,27.5881,0)
me.verts.append(v)
v=NMesh.Vert(288.189,27.5881,0)
me.verts.append(v)
v=NMesh.Vert(286.779,26.1781,0)
me.verts.append(v)
v=NMesh.Vert(288.189,26.1781,0)
me.verts.append(v)
v=NMesh.Vert(131.147,32.5938,0)
me.verts.append(v)
v=NMesh.Vert(131.927,32.5938,0)
me.verts.append(v)
v=NMesh.Vert(131.147,31.8142,0)
me.verts.append(v)
v=NMesh.Vert(131.927,31.8142,0)
me.verts.append(v)
v=NMesh.Vert(51.1907,27.3084,0)
me.verts.append(v)
v=NMesh.Vert(52.1037,27.3084,0)
me.verts.append(v)
v=NMesh.Vert(51.1907,26.3954,0)
me.verts.append(v)
v=NMesh.Vert(52.1037,26.3954,0)
me.verts.append(v)
v=NMesh.Vert(227.836,27.2362,0)
me.verts.append(v)
v=NMesh.Vert(228.518,27.2362,0)
me.verts.append(v)
v=NMesh.Vert(227.836,26.5534,0)
me.verts.append(v)
v=NMesh.Vert(228.518,26.5534,0)
me.verts.append(v)
v=NMesh.Vert(165.488,32.0492,0)
me.verts.append(v)
v=NMesh.Vert(166.994,32.0492,0)
me.verts.append(v)
v=NMesh.Vert(165.488,30.5434,0)
me.verts.append(v)
v=NMesh.Vert(166.994,30.5434,0)
me.verts.append(v)
v=NMesh.Vert(109.707,19.7637,0)
me.verts.append(v)
v=NMesh.Vert(110.753,19.7637,0)
me.verts.append(v)
v=NMesh.Vert(109.707,18.7177,0)
me.verts.append(v)
v=NMesh.Vert(110.753,18.7177,0)
me.verts.append(v)
v=NMesh.Vert(322.212,22.0381,0)
me.verts.append(v)
v=NMesh.Vert(323.876,22.0381,0)
me.verts.append(v)
v=NMesh.Vert(322.212,20.3745,0)
me.verts.append(v)
v=NMesh.Vert(323.876,20.3745,0)
me.verts.append(v)
v=NMesh.Vert(48.6407,12.5311,0)
me.verts.append(v)
v=NMesh.Vert(54.2299,12.5311,0)
me.verts.append(v)
v=NMesh.Vert(48.6407,6.94191,0)
me.verts.append(v)
v=NMesh.Vert(54.2299,6.94191,0)
me.verts.append(v)
v=NMesh.Vert(75.4255,20.8301,0)
me.verts.append(v)
v=NMesh.Vert(77.5501,20.8301,0)
me.verts.append(v)
v=NMesh.Vert(75.4255,18.7055,0)
me.verts.append(v)
v=NMesh.Vert(77.5501,18.7055,0)
me.verts.append(v)
v=NMesh.Vert(87.6662,30.4795,0)
me.verts.append(v)
v=NMesh.Vert(89.2274,30.4795,0)
me.verts.append(v)
v=NMesh.Vert(87.6662,28.9183,0)
me.verts.append(v)
v=NMesh.Vert(89.2274,28.9183,0)
me.verts.append(v)
v=NMesh.Vert(105.252,8.15833,0)
me.verts.append(v)
v=NMesh.Vert(105.724,8.15833,0)
me.verts.append(v)
v=NMesh.Vert(105.252,7.68639,0)
me.verts.append(v)
v=NMesh.Vert(105.724,7.68639,0)
me.verts.append(v)
v=NMesh.Vert(238.632,11.4409,0)
me.verts.append(v)
v=NMesh.Vert(239.424,11.4409,0)
me.verts.append(v)
v=NMesh.Vert(238.632,10.6495,0)
me.verts.append(v)
v=NMesh.Vert(239.424,10.6495,0)
me.verts.append(v)
v=NMesh.Vert(107.682,4.61157,0)
me.verts.append(v)
v=NMesh.Vert(108.67,4.61157,0)
me.verts.append(v)
v=NMesh.Vert(107.682,3.62439,0)
me.verts.append(v)
v=NMesh.Vert(108.67,3.62439,0)
me.verts.append(v)
v=NMesh.Vert(12.5622,32.1395,0)
me.verts.append(v)
v=NMesh.Vert(17.5088,32.1395,0)
me.verts.append(v)
v=NMesh.Vert(12.5622,27.1929,0)
me.verts.append(v)
v=NMesh.Vert(17.5088,27.1929,0)
me.verts.append(v)
v=NMesh.Vert(267.343,23.0843,0)
me.verts.append(v)
v=NMesh.Vert(268.189,23.0843,0)
me.verts.append(v)
v=NMesh.Vert(267.343,22.2379,0)
me.verts.append(v)
v=NMesh.Vert(268.189,22.2379,0)
me.verts.append(v)
v=NMesh.Vert(160.517,24.1536,0)
me.verts.append(v)
v=NMesh.Vert(168.515,24.1536,0)
me.verts.append(v)
v=NMesh.Vert(160.517,16.1558,0)
me.verts.append(v)
v=NMesh.Vert(168.515,16.1558,0)
me.verts.append(v)
v=NMesh.Vert(266.79,18.4186,0)
me.verts.append(v)
v=NMesh.Vert(268.804,18.4186,0)
me.verts.append(v)
v=NMesh.Vert(266.79,16.4048,0)
me.verts.append(v)
v=NMesh.Vert(268.804,16.4048,0)
me.verts.append(v)
v=NMesh.Vert(198.103,10.21,0)
me.verts.append(v)
v=NMesh.Vert(200.575,10.21,0)
me.verts.append(v)
v=NMesh.Vert(198.103,7.73847,0)
me.verts.append(v)
v=NMesh.Vert(200.575,7.73847,0)
me.verts.append(v)
v=NMesh.Vert(211.042,18.5695,0)
me.verts.append(v)
v=NMesh.Vert(212.23,18.5695,0)
me.verts.append(v)
v=NMesh.Vert(211.042,17.3809,0)
me.verts.append(v)
v=NMesh.Vert(212.23,17.3809,0)
me.verts.append(v)
v=NMesh.Vert(232.562,20.1428,0)
me.verts.append(v)
v=NMesh.Vert(236.53,20.1428,0)
me.verts.append(v)
v=NMesh.Vert(232.562,16.1756,0)
me.verts.append(v)
v=NMesh.Vert(236.53,16.1756,0)
me.verts.append(v)
v=NMesh.Vert(48.4679,18.6631,0)
me.verts.append(v)
v=NMesh.Vert(49.9139,18.6631,0)
me.verts.append(v)
v=NMesh.Vert(48.4679,17.2171,0)
me.verts.append(v)
v=NMesh.Vert(49.9139,17.2171,0)
me.verts.append(v)
v=NMesh.Vert(78.6899,16.4353,0)
me.verts.append(v)
v=NMesh.Vert(79.7973,16.4353,0)
me.verts.append(v)
v=NMesh.Vert(78.6899,15.3279,0)
me.verts.append(v)
v=NMesh.Vert(79.7973,15.3279,0)
me.verts.append(v)
v=NMesh.Vert(212.597,15.7733,0)
me.verts.append(v)
v=NMesh.Vert(213.215,15.7733,0)
me.verts.append(v)
v=NMesh.Vert(212.597,15.1561,0)
me.verts.append(v)
v=NMesh.Vert(213.215,15.1561,0)
me.verts.append(v)
v=NMesh.Vert(183.711,24.3584,0)
me.verts.append(v)
v=NMesh.Vert(188.411,24.3584,0)
me.verts.append(v)
v=NMesh.Vert(183.711,19.6592,0)
me.verts.append(v)
v=NMesh.Vert(188.411,19.6592,0)
me.verts.append(v)
v=NMesh.Vert(242.072,27.3853,0)
me.verts.append(v)
v=NMesh.Vert(249.296,27.3853,0)
me.verts.append(v)
v=NMesh.Vert(242.072,20.1609,0)
me.verts.append(v)
v=NMesh.Vert(249.296,20.1609,0)
me.verts.append(v)
v=NMesh.Vert(138.1,30.722,0)
me.verts.append(v)
v=NMesh.Vert(140.01,30.722,0)
me.verts.append(v)
v=NMesh.Vert(138.1,28.8128,0)
me.verts.append(v)
v=NMesh.Vert(140.01,28.8128,0)
me.verts.append(v)
v=NMesh.Vert(284.12,26.5148,0)
me.verts.append(v)
v=NMesh.Vert(286.788,26.5148,0)
me.verts.append(v)

v=NMesh.Vert(284.12,23.846,0)
me.verts.append(v)
v=NMesh.Vert(286.788,23.846,0)
me.verts.append(v)
v=NMesh.Vert(72.8163,14.9788,0)
me.verts.append(v)
v=NMesh.Vert(75.4613,14.9788,0)
me.verts.append(v)
v=NMesh.Vert(72.8163,12.3338,0)
me.verts.append(v)
v=NMesh.Vert(75.4613,12.3338,0)
me.verts.append(v)
v=NMesh.Vert(143.615,22.4944,0)
me.verts.append(v)
v=NMesh.Vert(147.663,22.4944,0)
me.verts.append(v)
v=NMesh.Vert(143.615,18.4466,0)
me.verts.append(v)
v=NMesh.Vert(147.663,18.4466,0)
me.verts.append(v)
v=NMesh.Vert(228.681,33.7137,0)
me.verts.append(v)
v=NMesh.Vert(229.491,33.7137,0)
me.verts.append(v)
v=NMesh.Vert(228.681,32.9027,0)
me.verts.append(v)
v=NMesh.Vert(229.491,32.9027,0)
me.verts.append(v)
v=NMesh.Vert(178.454,30.1539,0)
me.verts.append(v)
v=NMesh.Vert(180.194,30.1539,0)
me.verts.append(v)
v=NMesh.Vert(178.454,28.4131,0)
me.verts.append(v)
v=NMesh.Vert(180.194,28.4131,0)
me.verts.append(v)
v=NMesh.Vert(11.9892,26.6364,0)
me.verts.append(v)
v=NMesh.Vert(13.1678,26.6364,0)
me.verts.append(v)
v=NMesh.Vert(11.9892,25.4578,0)
me.verts.append(v)
v=NMesh.Vert(13.1678,25.4578,0)
me.verts.append(v)
v=NMesh.Vert(5.73066,34.7567,0)
me.verts.append(v)
v=NMesh.Vert(7.73584,34.7567,0)
me.verts.append(v)
v=NMesh.Vert(5.73066,32.7515,0)
me.verts.append(v)
v=NMesh.Vert(7.73584,32.7515,0)
me.verts.append(v)
v=NMesh.Vert(263.756,33.8072,0)
me.verts.append(v)
v=NMesh.Vert(264.904,33.8072,0)
me.verts.append(v)
v=NMesh.Vert(263.756,32.6582,0)
me.verts.append(v)
v=NMesh.Vert(264.904,32.6582,0)
me.verts.append(v)
v=NMesh.Vert(270.169,8.79608,0)
me.verts.append(v)
v=NMesh.Vert(270.575,8.79608,0)
me.verts.append(v)
v=NMesh.Vert(270.169,8.38998,0)
me.verts.append(v)
v=NMesh.Vert(270.575,8.38998,0)
me.verts.append(v)
v=NMesh.Vert(331.344,13.8009,0)
me.verts.append(v)
v=NMesh.Vert(332.734,13.8009,0)
me.verts.append(v)
v=NMesh.Vert(331.344,12.4107,0)
me.verts.append(v)
v=NMesh.Vert(332.734,12.4107,0)
me.verts.append(v)
v=NMesh.Vert(0.49228,15.5239,0)
me.verts.append(v)
v=NMesh.Vert(3.48602,15.5239,0)
me.verts.append(v)
v=NMesh.Vert(0.49228,12.5301,0)
me.verts.append(v)
v=NMesh.Vert(3.48602,12.5301,0)
me.verts.append(v)
v=NMesh.Vert(115.285,12.0586,0)
me.verts.append(v)
v=NMesh.Vert(122.681,12.0586,0)
me.verts.append(v)
v=NMesh.Vert(115.285,4.66348,0)
me.verts.append(v)
v=NMesh.Vert(122.681,4.66348,0)
me.verts.append(v)
v=NMesh.Vert(343.479,0.863112,0)
me.verts.append(v)
v=NMesh.Vert(344.051,0.863112,0)
me.verts.append(v)
v=NMesh.Vert(343.479,0.291079,0)
me.verts.append(v)
v=NMesh.Vert(344.051,0.291079,0)
me.verts.append(v)
v=NMesh.Vert(14.5314,4.87286,0)
me.verts.append(v)
v=NMesh.Vert(15.647,4.87286,0)
me.verts.append(v)
v=NMesh.Vert(14.5314,3.75734,0)
me.verts.append(v)
v=NMesh.Vert(15.647,3.75734,0)
me.verts.append(v)
v=NMesh.Vert(155.001,25.5053,0)
me.verts.append(v)
v=NMesh.Vert(156.983,25.5053,0)
me.verts.append(v)
v=NMesh.Vert(155.001,23.5229,0)
me.verts.append(v)
v=NMesh.Vert(156.983,23.5229,0)
me.verts.append(v)
v=NMesh.Vert(124.336,26.9466,0)
me.verts.append(v)
v=NMesh.Vert(125.422,26.9466,0)
me.verts.append(v)
v=NMesh.Vert(124.336,25.8608,0)
me.verts.append(v)
v=NMesh.Vert(125.422,25.8608,0)
me.verts.append(v)
v=NMesh.Vert(136.458,22.5886,0)
me.verts.append(v)
v=NMesh.Vert(141.3,22.5886,0)
me.verts.append(v)
v=NMesh.Vert(136.458,17.7464,0)
me.verts.append(v)
v=NMesh.Vert(141.3,17.7464,0)
me.verts.append(v)
v=NMesh.Vert(153.368,8.47594,0)
me.verts.append(v)
v=NMesh.Vert(154.334,8.47594,0)
me.verts.append(v)
v=NMesh.Vert(153.368,7.51038,0)
me.verts.append(v)
v=NMesh.Vert(154.334,7.51038,0)
me.verts.append(v)
v=NMesh.Vert(137.714,34.6879,0)
me.verts.append(v)
v=NMesh.Vert(139.064,34.6879,0)
me.verts.append(v)
v=NMesh.Vert(137.714,33.3389,0)
me.verts.append(v)
v=NMesh.Vert(139.064,33.3389,0)
me.verts.append(v)
v=NMesh.Vert(112.954,5.51736,0)
me.verts.append(v)
v=NMesh.Vert(114.342,5.51736,0)
me.verts.append(v)
v=NMesh.Vert(112.954,4.12842,0)
me.verts.append(v)
v=NMesh.Vert(114.342,4.12842,0)
me.verts.append(v)
v=NMesh.Vert(65.082,13.1303,0)
me.verts.append(v)
v=NMesh.Vert(68.2002,13.1303,0)
me.verts.append(v)
v=NMesh.Vert(65.082,10.0121,0)
me.verts.append(v)
v=NMesh.Vert(68.2002,10.0121,0)
me.verts.append(v)
v=NMesh.Vert(331.836,20.7719,0)
me.verts.append(v)
v=NMesh.Vert(332.944,20.7719,0)
me.verts.append(v)
v=NMesh.Vert(331.836,19.6643,0)
me.verts.append(v)
v=NMesh.Vert(332.944,19.6643,0)
me.verts.append(v)
v=NMesh.Vert(182.308,7.13792,0)
me.verts.append(v)
v=NMesh.Vert(188.798,7.13792,0)
me.verts.append(v)
v=NMesh.Vert(182.308,0.64708,0)
me.verts.append(v)
v=NMesh.Vert(188.798,0.64708,0)
me.verts.append(v)
v=NMesh.Vert(242.992,11.5485,0)
me.verts.append(v)
v=NMesh.Vert(243.992,11.5485,0)
me.verts.append(v)
v=NMesh.Vert(242.992,10.5475,0)
me.verts.append(v)
v=NMesh.Vert(243.992,10.5475,0)
me.verts.append(v)
v=NMesh.Vert(321.633,28.7604,0)
me.verts.append(v)
v=NMesh.Vert(327.819,28.7604,0)
me.verts.append(v)
v=NMesh.Vert(321.633,22.5746,0)
me.verts.append(v)
v=NMesh.Vert(327.819,22.5746,0)
me.verts.append(v)
v=NMesh.Vert(340.792,14.0755,0)
me.verts.append(v)
v=NMesh.Vert(341.422,14.0755,0)
me.verts.append(v)
v=NMesh.Vert(340.792,13.4456,0)
me.verts.append(v)
v=NMesh.Vert(341.422,13.4456,0)
me.verts.append(v)
v=NMesh.Vert(192.598,24.8489,0)
me.verts.append(v)
v=NMesh.Vert(193.716,24.8489,0)
me.verts.append(v)
v=NMesh.Vert(192.598,23.7307,0)
me.verts.append(v)
v=NMesh.Vert(193.716,23.7307,0)
me.verts.append(v)
v=NMesh.Vert(168.207,32.4505,0)
me.verts.append(v)
v=NMesh.Vert(169.345,32.4505,0)
me.verts.append(v)
v=NMesh.Vert(168.207,31.3129,0)
me.verts.append(v)
v=NMesh.Vert(169.345,31.3129,0)
me.verts.append(v)
v=NMesh.Vert(171.57,23.0138,0)
me.verts.append(v)
v=NMesh.Vert(172.838,23.0138,0)
me.verts.append(v)
v=NMesh.Vert(171.57,21.7464,0)
me.verts.append(v)
v=NMesh.Vert(172.838,21.7464,0)
me.verts.append(v)
v=NMesh.Vert(34.7811,22.2202,0)
me.verts.append(v)
v=NMesh.Vert(35.6377,22.2202,0)
me.verts.append(v)
v=NMesh.Vert(34.7811,21.3636,0)
me.verts.append(v)
v=NMesh.Vert(35.6377,21.3636,0)
me.verts.append(v)
v=NMesh.Vert(212.332,13.0445,0)
me.verts.append(v)
v=NMesh.Vert(214.494,13.0445,0)
me.verts.append(v)
v=NMesh.Vert(212.332,10.8821,0)
me.verts.append(v)
v=NMesh.Vert(214.494,10.8821,0)
me.verts.append(v)
v=NMesh.Vert(212.378,28.0584,0)
me.verts.append(v)
v=NMesh.Vert(214.922,28.0584,0)
me.verts.append(v)
v=NMesh.Vert(212.378,25.5154,0)
me.verts.append(v)
v=NMesh.Vert(214.922,25.5154,0)
me.verts.append(v)
v=NMesh.Vert(246.987,32.8781,0)
me.verts.append(v)
v=NMesh.Vert(247.555,32.8781,0)
me.verts.append(v)
v=NMesh.Vert(246.987,32.3099,0)
me.verts.append(v)
v=NMesh.Vert(247.555,32.3099,0)
me.verts.append(v)
v=NMesh.Vert(317.651,14.9545,0)
me.verts.append(v)
v=NMesh.Vert(318.363,14.9545,0)
me.verts.append(v)
v=NMesh.Vert(317.651,14.2435,0)
me.verts.append(v)
v=NMesh.Vert(318.363,14.2435,0)
me.verts.append(v)
v=NMesh.Vert(186.92,33.8432,0)
me.verts.append(v)
v=NMesh.Vert(192,33.8432,0)
me.verts.append(v)
v=NMesh.Vert(186.92,28.7638,0)
me.verts.append(v)
v=NMesh.Vert(192,28.7638,0)
me.verts.append(v)
v=NMesh.Vert(275.795,6.12657,0)
me.verts.append(v)
v=NMesh.Vert(279.579,6.12657,0)
me.verts.append(v)
v=NMesh.Vert(275.795,2.34326,0)
me.verts.append(v)
v=NMesh.Vert(279.579,2.34326,0)
me.verts.append(v)
v=NMesh.Vert(335.465,17.1661,0)
me.verts.append(v)
v=NMesh.Vert(337.851,17.1661,0)
me.verts.append(v)
v=NMesh.Vert(335.465,14.7811,0)
me.verts.append(v)
v=NMesh.Vert(337.851,14.7811,0)
me.verts.append(v)
v=NMesh.Vert(248.809,9.19149,0)
me.verts.append(v)
v=NMesh.Vert(249.765,9.19149,0)
me.verts.append(v)
v=NMesh.Vert(248.809,8.23631,0)
me.verts.append(v)
v=NMesh.Vert(249.765,8.23631,0)
me.verts.append(v)
v=NMesh.Vert(320.001,16.0073,0)
me.verts.append(v)
v=NMesh.Vert(321.403,16.0073,0)
me.verts.append(v)
v=NMesh.Vert(320.001,14.6047,0)
me.verts.append(v)
v=NMesh.Vert(321.403,14.6047,0)
me.verts.append(v)
v=NMesh.Vert(333.13,19.2916,0)
me.verts.append(v)
v=NMesh.Vert(335.478,19.2916,0)
me.verts.append(v)
v=NMesh.Vert(333.13,16.9438,0)
me.verts.append(v)
v=NMesh.Vert(335.478,16.9438,0)
me.verts.append(v)
v=NMesh.Vert(241.284,34.746,0)
me.verts.append(v)
v=NMesh.Vert(241.91,34.746,0)
me.verts.append(v)
v=NMesh.Vert(241.284,34.1206,0)
me.verts.append(v)
v=NMesh.Vert(241.91,34.1206,0)
me.verts.append(v)
v=NMesh.Vert(69.4166,13.3567,0)
me.verts.append(v)
v=NMesh.Vert(70.3844,13.3567,0)
me.verts.append(v)
v=NMesh.Vert(69.4166,12.3889,0)
me.verts.append(v)
v=NMesh.Vert(70.3844,12.3889,0)
me.verts.append(v)
v=NMesh.Vert(285.054,9.80886,0)
me.verts.append(v)
v=NMesh.Vert(292.256,9.80886,0)
me.verts.append(v)
v=NMesh.Vert(285.054,2.60732,0)
me.verts.append(v)
v=NMesh.Vert(292.256,2.60732,0)
me.verts.append(v)
number=146

0 1

center

2 3

for i in range(0,number-1,1):
f=NMesh.Face()
f.v.append(me.verts[i*4])
f.v.append(me.verts[i*4+1])
f.v.append(me.verts[i*4+3])
f.v.append(me.verts[i*4+2])
me.faces.append(f)
NMesh.PutRaw(me,“plane”,1)
Blender.Redraw()

This is the end of the script

Best regards,
Zhou Bin

your aim seems to be near from a packing algoritm. You should try to do some research about that it could help you. :slight_smile:

Dear pierre_cu,
I appreciate your immediate reply. As I’m new and I do not know more about “packing algorithm”, could you give any clues.
By the way, if it is possible. could you use above 8 points for a simply try? This is very important for me.
Best regards,
zhou bin

umm… I don’t know how you generated your large number of NMesh.Vert statements, but this is not a good way to write a Python script. You should store them in a text file and then do something like this:

points.txt

152.555 24.1243
155.959 24.1243
152.555 20.7207
155.959 20.7207


Python script


lines = open(“points.txt”).readlines()
data = [[float(aa) for aa in a.split()] for a in lines]
for x,y in data:
v = NMesh.Vert(x,y,0)
me.verts.append(v)

If your rectangles are all the same size (and they seem to be) you could also store just the center of the rectangles in the text file and calculate the four corners in Python.

I suggest you also post or describe a bit how you generated the points because it is very confusing…

Here are a couple of algorithms I just invented. They are pretty trivial though.

First one:

  1. Generate a rectangle.
  2. Generate a circle inside the rectangle. (I assume that it will be created inside but you may need to check for it depending on how you create it.)
  3. Check if the new circle overlaps with any existing circle. If it does, do not add it to the rectangle. Else add it.
  4. Go back to 2. unless there are enough circles.

Another way would be to generate a circle and then generate another circle so that they share a point on their circumferences. Then generate another circle the same way but remember to check for overlapping. Do this till you have enough circles.

Third way would be to “drop” circles from up of rectangle and check where they fall (check for overlapping again).

Yet another way to do this would be just to create a rectangle and a bunch of circles without caring about overlapping issue. After you have done that, remove circles so that there are no longer overlapping ones remaining.

You might want to check out basic rules of trigonometry. They could help you in your task. For instance you can generate a circle easily by getting suitable values of sine and cosine. There may be some hints on how to handle overlapping too.

What about the circles pushing each other away? Modify step 3 “if it does, do not add it” with “if it does, calculate the push forces and move all circles until they fit or you have tried for a long time”
You could tap into Blender’s physics engine or use an energy minimization algorithm or whatever. This (untested) code snippet illustrates the idea:

radius = 30
circles = [[10.0, 20.0, -12.0], [23.0,18.0, -6.0], …]
for trials in range(1000):
<tab>ok = True
<tab> for circle1 in circles:
<tab> <tab>for circle2 in circles:
<tab> <tab> <tab>if circle1 is circle2: continue
<tab> <tab> <tab>diff = circle1 - circle2
<tab> <tab> <tab>dist = sqrt(diff.x2+diff.y2+diff.z**2)
<tab> <tab> <tab>if dist < radius:
<tab> <tab> <tab> <tab>ok = False
<tab> <tab> <tab> <tab>force = (radius-dist) * diff
<tab> <tab> <tab> <tab>circle1 += force
<tab> <tab> <tab> <tab>circle2 -= force
<tab> if ok == True: break
if ok == False: print “no more circles can be added”

<and add some code to confine the circles within the rectangle>
<add a lot of extra tests and optimizations…>

Dear Sjoerd and BeBraw,
I use C++ to generate a large number of circles which are what I needed. Now I have a lot of coordinates (2-D) and diammeters.
I want to generate a model— a rectangle with holes (this is the above mentioned circles) inside.
The picture after I model manually is:
http://openfoam.cfd-online.com/cgi-bin/forum/discus.cgi
By the way, I’d like to express Mr. Doug here for introducing this powerful software.
Zhou Bin
Politecnico di Torino

Dear Sjoerd and BeBraw,
After clicking the above email, click: OpenFOAM, then click: Preprocessing / FoamX, then please click: Modelling with many circles in a rectangle .
Now you can see the picture we generate manually.
Since it is time-consuming for my geometry, I ask for help here.
Of course, I’ll try my best to catch up with you.
Best regards,
Zhou Bin

Hi,

After looking at your posts on the OpenFOAM message board, I think I’m right in saying that you’re trying to generate the geometry from a pre-existing list with coordinates.
I’ve written a script for you to do just that. Download the following two files:
[.blend-file] & [txt-file]

Now open the .blend-file and execute (ALT+P) the script it contains. Then it asks you to locate the txt file with the information about the geometry, this is the second file you downloaded. Select it and press “Load file”. The final thing to decide is the resolution, this is the number of vertices per circle. You’re done.

Some additional information: the first line of the text file contains the coordinates of the square. The other lines contain the coordinates and diameters of the circles. So you can create any additional geometry you’d like.

Yours friendly,
Bart

Dear Bart,
Really appreciate you immediate respond, I tried your script, and it is ok.
I find the mesh is not good, because some place has no mesh. And the mesh around the circle is not fine.
I’d like to show you the mesh from GAMBIT (commecial software), and I don’t know if I could use BLENDER to mesh in this way?
Well, it is hard for me to copy the picture. No problem, anyway, I just show you how we can solve the problem about meshing in Blender.
Thank you :slight_smile:
Zhou Bin

Perhaps another way to get better mesh would be to do the modeling operation using Blender’s curves? Curves have implicit support for booleans. After you have created suitable curve object, you can convert it to mesh. Here’s an example image of what I mean: http://bebraw.googlepages.com/curvetest.png
. All of those objects have been created using basic curve tools and options.

Dear BeDraw,
I open the picture you made, and it looks ok. By the way, could you explain it to me in detail how you could make this picture using script?
My problem is a rectangle with many circles inside (2-D problem)
Thank you.
Best regards,
Zhou Bin

I have not used the curve API itself much. If you go that route, start out with simple tasks (create rectangle, create circle based on location and radius etc.). You can find the API at http://www.blender.org/documentation/245PythonDoc/Curve-module.html .

Dear friends,
The geometry is really challenging, and I would like to show the geometry after meshing using GAMBIT to you, and I would like to ask for help how can I mesh this geometry in Blender?
I do not know how to upload files,please wait…
http://www.savefile.com/files/1159333

Dear friends,
Here I would like to thank you for your help.
by the way, dear Bart, your script encourages me a lot, but the mesh is not very reasonable, there are a lot of long lines bunched together, then very large space in other areas.
I will use this model for fluid simulation, and maybe this mesh is not reasonable.
Would you please see attached file, and if I could use Blender to this way? Thank you.
Best regards,
zhou bin

I don’t think curve to mesh can produce that kind of mesh. It would take a special algorithm to make it like that.

Dear BeDraw,
Thank you for your kindness. I think this is really difficult for me, and I will go ahead.
Best regards,
Zhou Bin