Skip to content

Instantly share code, notes, and snippets.

@yone80
Created September 3, 2017 09:30
Show Gist options
  • Save yone80/b2ec35130e813f31b3ca0e7c61ba9735 to your computer and use it in GitHub Desktop.
Save yone80/b2ec35130e813f31b3ca0e7c61ba9735 to your computer and use it in GitHub Desktop.
VEXpression
string edgegrp = chs('edge_group');
string newgrpname = chs('new_polyline_group_name');
int edges[] = expandedgegroup(0, edgegrp);
int prevpt = -1;
int curprim = -1;
for(int i=0; i<len(edges); i+=2)
{
if(edges[i] == prevpt)
{
addvertex(0, curprim, edges[i+1]);
prevpt = edges[i+1];
}
else if(edges[i+1] == prevpt)
{
addvertex(0, curprim, edges[i]);
prevpt = edges[i];
}
else
{
if(edges[i] == edges[i+2] || edges[i] == edges[i+3])
{
curprim = addprim(0, 'polyline', edges[i+1], edges[i]);
prevpt = edges[i];
}
else
{
curprim = addprim(0, 'polyline', edges[i], edges[i+1]);
prevpt = edges[i+1];
}
setprimgroup(0, newgrpname, curprim, 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment