Combining points in Vex.

   Views 2402   Replies 2   Subscribers 1
User Avatar
Member
3 posts
Joined: 4月 2017
Online
Hello,

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");  
}
This seemed to work fine (attachment result 1). The red points would be deleted later.

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!

Attachments:
singlepoint.jpg (186.4 KB)

User Avatar
Member
419 posts
Joined: 4月 2018
Offline
Why don't you just place the corner of a block at the point you choose?
User Avatar
Member
9 posts
Joined: 12月 2015
Offline
I've been also stuck with this problem myself for weeks. Unfortunately, I have no knowledge of VEX, but I need a solution that is almost identical in construction. I need a solution like in picture 3 from @BcM to place my Lego bricks within a grid according to size. 2x4 bricks, 2x2 and 1x1. I just despair....
  • Quick Links