# Edge divide in vex?

## Recommended Posts

Is there any way to split a polygon down the middle using vex and something like an attribwrangle in the same way that an edgedivide SOP works?

Thanks.

edgeDivideInVex.hip

##### Share on other sites

i thought about this recently, as well. i am probably boring you, but basically cutting a polygon in two is nothing different than redrawing two polygons and deleting the old one.

in a four-sided polygon this would mean to create two new points inbetween existing points, and drawing vertices while creating prims. i don't know how to access specific point positions in vex, but at least some functions in my example might be useful.

```// CALCULATE AVERAGE POSITIONS

vector avpos_0 = ((point_0 + point_1) /2);
vector avpos_1 = ((point_2 + point_3) /2);

// CREATE INBETWEEN POINTS

// CREATE FIRST PRIMITIVE

// CREATE SECOND PRIMITIVE

// DELETE ORIGINAL PRIM

removeprim(int geoself(), prim0, int andpoints); ```

Edited by konstantin magnus

##### Share on other sites

half-edges might be useful in a more complex situation:

http://www.sidefx.com/docs/houdini13.0/vex/halfedges

##### Share on other sites

Yes, it gets more complicated quickly. For example, splitting a polygon that has a shared edge with one (or more) other polygons. Then you also have to consider the case where you want attributes interpolated along the edges into the new points.

##### Share on other sites

Does this mean we won't see this feature in VEX? It does seem a lot of work to do it by hand each time. Houdini can already do this in the HDK, right?

##### Share on other sites

Yes, it can of course be done in the HDK but I don't think that was the original question.

• 1

##### Share on other sites

Yes, it can of course be done in the HDK but I don't think that was the original question.

Thanks Edward. I mentioned that because if it's in the hdk, you guys can expose this function to VEX saving us the trouble of doing it manually.

• 1

##### Share on other sites

this (russian) tutorial explains how to cut edges in vex:

• 1

## Create an account

Register a new account