#### Kryslin

##### Well-known member

Code:

```
@script modeler
@warnings
@name SubD Corners
//Author : Steven Pettit
//Date : 21 July 2013
//Version : 1.0
main
{
selmode(USER);
ofs = 0.001;
p_inf = polycount();
p_cnt = p_inf[1];
if (p_cnt < 1) error("Select some Polygons!");
reqbegin("Make Hold Geometry");
reqsize(300,105);
c1 = ctldistance("Hold Distance",ofs);
ctlposition(c1,11,15,279,19);
return if !reqpost();
ofs = getvalue(c1);
reqend();
editbegin();
orig = polygons;
editend();
wrk = orig;
tmp = nil;
unweld();
for(q=1;q<=wrk.count();q++)
{
tmp = wrk[q];
selpolygon(CLEAR);
selpolygon(SET,POLYID,tmp);
editbegin();
p1 = polygons;
v1 = points;
v2 = nil;
v3 = nil;
vcnt = v1.count();
for(i=1;i<=vcnt;i++)
{
j = i + 1;
if (j > vcnt) j = 1;
ov = (pointinfo(v1[j]) - pointinfo(v1[i]));
v2 += ofs * normalize(ov);
}
for(i=1;i<=vcnt; i++)
{
j = i - 1;
if (j < 1) j = vcnt;
op = pointinfo(v1[i]);
v3 += op;
v3 += op + v2[i];
v3 += op + v2[i] - v2[j];
v3 += op - v2[j];
}
lim = vcnt * 4;
for(i=0;i<vcnt;i++)
{
//make the easy polygons
tv = nil;
for(j=0;j<4;j++)
{
bo = ((i * 4) + j) + 1;
tv += addpoint(v3[bo]);
}
tp += addpolygon(tv,"Default");
}
//Slightly Harder Polygons...
for(i=0;i<vcnt;i++)
{
tv = nil;
bo = i * 4;
b0 = bo + 2;
b1 = bo + 8; if (b1 > lim) b1 -= lim;
b2 = bo + 7; if (b2 > lim) b2 -= lim;
b3 = bo + 3; if (b3 > lim) b3 -= lim;
tv += addpoint(v3[b0]);
tv += addpoint(v3[b1]);
tv += addpoint(v3[b2]);
tv += addpoint(v3[b3]);
tp += addpolygon(tv,"Default");
}
//Last Internal Polygon
tv = nil;
for(i=0;i<vcnt;i++)
{
tv += addpoint(v3[(i*4)+3]);
}
tp += addpolygon(tv,"Default");
editend();
}
selpolygon(CLEAR);
selpolygon(SET,POLYID,orig);
removepols();
selpolygon(CLEAR);
selpolygon(SET,POLYID,tp);
mergepoints();
selpolygon(CLEAR);
}
```

Surprisingly, It works well. And if I have a problem with adding hold geometry, perhaps someone else will find it useful, too.

Unsurprisingly, my code is a mess. Any help cleaning it up would be appreciated.

What it does is add hold geometry at the corners of each polygon, based on a distance given by the user, which defaults to 1mm.

I've tested it on n-gons, single quads, multiple quads, and triangles. What it doesn't do is split n-gons into quads, or not put hold geometry on shared edges.

I'm going to be working on a Hold Geometry friendly inset in the near future as well.