Macro for generating converging holes in a box

Hi Everybody,

I am built a macro for making a box and make hexagonal holes in it with user specified dimensions in mm (for the box size, the hole size and the thickness of the wall in between the holes). And, both the box and the holes if extended would converge at a point. This results in a tapered box with decreasing hole size and also the wall thickness in the direction of the convergence. Something similar to the box in the figure below. I achieved this by making the box first, generating sketches for each of the holes and then loft cutting the corresponding sketches with a point (origin in my case, which is acting as point of convergence) as the second contour. The dimensions on plane 1 are the length and width of the box. The dimension in the converging direction is the depth of the box. I assumed that convergence is taking place at origin and specified this distance of plane 1 as "box distance" in the code. Hole diameter is the diameter of the inscribed circle.

However, I am having few problems with the code and am unable to figure out how to fix them.

1. As the hole size decreases, I am getting a box with overlapping holes. Especially the holes close to (0,0) point on Plane 1 as shown in the figure below.

or no holes are created at all, just the sketches as shown in the figure below. Further, no sketches are created close to the center of the box. This is weird since the holes are supposed to start at the center and move towards edges.

2. My aim is to make a box about 0.5m i.e., 500mm in length with minimum of 2mm size holes and 0.15 mm thick walls. When I try to run the code with these dimensions I am unable to run it to completion. Last time I tried it took 40 minutes and SW froze after that without generating any holes.

Any suggestions as to why this might be happening or if there is a better way to achieve what I am trying to make would be greatly appreciated. Thank you.

My code is added an attachment.

SolidworksApi macros