A few days ago I was realized how extremely easy it was to turn your object into Lego. Add a points from volume, and copy to points some Lego blocks.
Immediately I thought how simple it would be to write a script that checks for points near, and replaces it with another point in the middle to place 4x2 cubes where possible.
After typing the following vex code. And testing it on one point (0)
int pt1[] = nearpoints(0, "oneblock", @P + {0, 0, 0.1}, 0.01); int pt2[] = nearpoints(0, "oneblock", @P + {0, 0, 0.2}, 0.01); int pt3[] = nearpoints(0, "oneblock", @P + {0, 0, 0.3}, 0.01); int pt4[] = nearpoints(0, "oneblock", @P + {0.1, 0, 0}, 0.01); int pt5[] = nearpoints(0, "oneblock", @P + {0.1, 0, 0.1}, 0.01); int pt6[] = nearpoints(0, "oneblock", @P + {0.1, 0, 0.2}, 0.01); int pt7[] = nearpoints(0, "oneblock", @P + {0.1, 0, 0.3}, 0.01); int pts[]; append(pts, @ptnum); append(pts, pt1); append(pts, pt2); append(pts, pt3); append(pts, pt4); append(pts, pt5); append(pts, pt6); append(pts, pt7); if(len(pts)==8){ foreach(int pt;pts){ setpointattrib(0, "Cd", pt, set(1, 0 , 0), "set"); setpointgroup(0, "oneblock", pt, 0, "set"); setpointgroup(0, "blast", pt, 1, "set"); //removepoint(0, pt); } int newpt = addpoint(0, (@P + {0.05, 0, 0.15})); setpointgroup(0, "fourblock", newpt, 1, "set"); }
Of course this did not work because the code doesnt't work with updated information about which group to search in. So I decided to put the wrangle in “detail (only once)” mode, and loop the points.
for (int i = 0; i < @numpt; i++) { }
From what I've seen this did not work either. And I get result 2 from both modes.
What I need is result 3. Where only a few blocks are added (5) and the rest will be filled by 1x1 blocks later.
How can I get this to work? It is driving me crazy.
Thanks!