PDA

View Full Version : Simple polygon splitter?



Exception
09-11-2004, 07:41 AM
I do a lot of Elevations and that means I need to split a lot of polygons vertically to make window divisions. Ive been searching flay and trying to thing of a way to have one-click polygon splitting but I can just not find anything!
I can find enough plugins which split based on point selection and such, but I don't want that. I just want a plugin that splits polygons in horizontal or vertical manner and with a numerical box you can say how many splits. I use Bandaw Pro now to do it but you can only do one poly at a time and you have to cut and paste it to disconnect its geometry and so forth...

Does anyone know a plugin or utility that does this?

Dodgy
09-11-2004, 03:21 PM
If you select two adjoined polys along the direction you want to cut, bandsaw pro will extend the cut along this direction until it runs out of quad polys.
I also use jigsaw from FI (look it up on flay) or the new cut tool in LW 8. For these you have to select all the polys you want split.

Red_Oddity
09-11-2004, 05:15 PM
Or, use a stack of polygons that represent the cuts you want to make and use the Drill tool...

Exception
09-12-2004, 03:04 PM
Dodgy:

Well the point is that you never have two adjoining poly's to cut when making windows since they are by definition always at least one poly apart. Also it requires you to cut and paste the poly's since bandsaw just goes on and on and on and doesnt stop. Also the 'auto' direction indicator is hazy and looks to me as if it is random. Still requires a lot of actions to perform a simple cut.
The cut tool is terrible and only works on more than one poly, and poorly at that.
FI_Jigsaw does not work on single poly's either, and makes the same weird cuts as Jigsaw with a triangle on the end.

Here, let me illustrate. I jus twant to go from the first set of poly's to the second with only five two actions. One action to select the poly's which need to be cut in half and then performing the split, then deselecting them, select the one which need to be split in three, split that one and be done.

thekho
09-12-2004, 05:15 PM
I'm not good at writing but that's my pictures (see below) which might help you.

1) Make Plane, use Sore Drill tool.
2) Select big polygon not small.
3) Flip and unselect polygon.
4) Select small polygon.
5) Use Bandsaw Pro or Bandsaw or Bandsaw and also unselect polygon.
6+7) Select big polygon and flip.
8) That's final.

faulknermano
09-13-2004, 01:25 AM
i think you can try this:

(i've posted this somewhere before but i forgot)

(this is my version of Julienne)

(distance spacing does not work yet...)



@warnings
@define LO 1
@define HI 2

main
{
sm = integer(recall("sm",1));
segx = integer(recall("segx",1));
segy = integer(recall("segy",1));
segz = integer(recall("segz",1));
spacingx = number(recall("spacingx",1));
spacingy = number(recall("pacingx",1));
spacingz = number(recall("spacingx",1));

selmode(USER);

polyc = polycount();
if(polyc[1] == 0)
error("<br>No data.");

editbegin();
foreach(x,polygons)
polys += x;

editend();

segmode = integer(recall("segmode",1));
layerfg = lyrfg();
layerempty = lyrempty();

if(layerfg.size() > 1)
error("<br>Select one layer.");

datalayer = layerfg[1];
emptylayer = layerempty[1];


reqbegin("fm Julienne");
c0 = ctlchoice("Select Mode",sm,@"GLOBAL","USER"@);
c1 = ctlchoice("Mode",segmode,@"By Segment","By Spacing"@);
c2a = ctlinteger("Segments X",segx);
c2b = ctlinteger("Segments Y",segy);
c2c = ctlinteger("Segments Z",segz);
c3a = ctldistance("Spacing X",spacingx);
c3b = ctldistance("Spacing Y",spacingy);
c3c = ctldistance("Spacing Z",spacingz);

ctlactive(c1,"c2_active",c2a,c2b,c2c);
ctlactive(c1,"c3_active",c3a,c3b,c3c);

return if(!reqpost());

sm = getvalue(c0);
segmode = getvalue(c1);
segx = getvalue(c2a);
segy = getvalue(c2b);
segz = getvalue(c2c);
spacingx = getvalue(c3a);
spacingy = getvalue(c3b);
spacingz = getvalue(c3c);

store("sm",sm);
store("segx",segx);
store("segy",segy);
store("segz",segz);
store("spacingx",spacingx);
store("spacingy",spacingy);
store("spacingz",spacingz);

reqend();

segxyz = <segx,segy,segz>;

if(sm == 1) // GLOBAL
rep = 1;
if(sm == 2)
rep = polys.size();
selpolygon(CLEAR);
for(k=1;k<=rep;k++)
{
if(rep == 1)
selpolygon(SET,POLYID,polys);
if(rep != 1)
{
selunhide();
selpolygon(CLEAR);
selpolygon(SET,POLYID,polys[k]);
selhide(UNSELECTED);
}
bb = boundingbox(datalayer);
lyrsetfg(emptylayer);

editbegin();

if(segmode == 1) // by segment
{
pc = 0;
bbtot = <(bb[2].x - bb[1].x),(bb[2].y - bb[1].y),(bb[2].z - bb[1].z)>;
spc = <bbtot.x / segxyz.x,bbtot.y / segxyz.y,bbtot.z / segxyz.z>;

for(j=1;j<=3;j++) // per axis
{

if(j == 1)
seg = segx;
if(j == 2)
seg = segy;
if(j == 3)
seg = segz;

if(seg <= 1)
continue;
for(i=1;i<seg;i++)
{
if(j == 1) // X axis
{
a[1] = addpoint(<bb[LO].x + (spc.x * i),bb[LO].y - 0.1,bb[LO].z - 0.1>);
a[2] = addpoint(<bb[LO].x + (spc.x * i),bb[HI].y + 0.1,bb[LO].z - 0.1>);
a[3] = addpoint(<bb[LO].x + (spc.x * i),bb[HI].y + 0.1,bb[HI].z + 0.1>);
a[4] = addpoint(<bb[LO].x + (spc.x * i),bb[LO].y - 0.1,bb[HI].z + 0.1>);
}
if(j == 2) // Y Axis
{
a[1] = addpoint(<bb[LO].x - 0.1,bb[LO].y + (spc.y * i),bb[LO].z - 0.1>);
a[2] = addpoint(<bb[HI].x + 0.1,bb[LO].y + (spc.y * i),bb[LO].z - 0.1>);
a[3] = addpoint(<bb[HI].x + 0.1,bb[LO].y + (spc.y * i),bb[HI].z + 0.1>);
a[4] = addpoint(<bb[LO].x - 0.1,bb[LO].y + (spc.y * i),bb[HI].z + 0.1>);


}
if(j == 3) // Z Axis
{
a[1] = addpoint(<bb[LO].x - 0.1,bb[LO].y - 0.1,bb[LO].z + (spc.z * i)>);
a[2] = addpoint(<bb[HI].x + 0.1,bb[LO].y - 0.1,bb[LO].z + (spc.z * i)>);
a[3] = addpoint(<bb[HI].x + 0.1,bb[HI].y + 0.1,bb[LO].z + (spc.z * i)>);
a[4] = addpoint(<bb[LO].x - 0.1,bb[HI].y + 0.1,bb[LO].z + (spc.z * i)>);
}
p[++pc] = addquad(a);
a = nil;

}
}
editend();
lyrsetfg(datalayer);
lyrsetbg(emptylayer);
soliddrill(SLICE);
lyrsetfg(emptylayer);
delete();
lyrsetfg(datalayer);
selunhide();

}
if(segmode == 2) // by spacing
{
for(j=1;j<=3;j++) // per axis
{
for(i=1;i<seg;i++)
{
if(j == 1) // X axis
{
a[1] = addpoint(<bb[LO].x + (spc.x * i),bb[LO].y - 0.1,bb[LO].z - 0.1>);
a[2] = addpoint(<bb[LO].x + (spc.x * i),bb[HI].y + 0.1,bb[LO].z - 0.1>);
a[3] = addpoint(<bb[LO].x + (spc.x * i),bb[HI].y + 0.1,bb[HI].z + 0.1>);
a[4] = addpoint(<bb[LO].x + (spc.x * i),bb[LO].y - 0.1,bb[HI].z + 0.1>);
}
if(j == 2) // Y Axis
{
a[1] = addpoint(<bb[LO].x - 0.1,bb[LO].y + (spc.y * i),bb[LO].z - 0.1>);
a[2] = addpoint(<bb[HI].x + 0.1,bb[LO].y + (spc.y * i),bb[LO].z - 0.1>);
a[3] = addpoint(<bb[HI].x + 0.1,bb[LO].y + (spc.y * i),bb[HI].z + 0.1>);
a[4] = addpoint(<bb[LO].x - 0.1,bb[LO].y + (spc.y * i),bb[HI].z + 0.1>);


}
if(j == 3) // Z Axis
{
a[1] = addpoint(<bb[LO].x - 0.1,bb[LO].y - 0.1,bb[LO].z + (spc.z * i)>);
a[2] = addpoint(<bb[HI].x + 0.1,bb[LO].y - 0.1,bb[LO].z + (spc.z * i)>);
a[3] = addpoint(<bb[HI].x + 0.1,bb[HI].y + 0.1,bb[LO].z + (spc.z * i)>);
a[4] = addpoint(<bb[LO].x - 0.1,bb[HI].y + 0.1,bb[LO].z + (spc.z * i)>);
}
p[++pc] = addquad(a);
a = nil;

}
}
editend();
lyrsetfg(datalayer);
lyrsetbg(emptylayer);
soliddrill(SLICE);
lyrsetfg(emptylayer);
delete();
lyrsetfg(datalayer);

}
}

}
c2_active: val
{
if(val == 1)
return(true);
else
return(false);
}

c3_active: val
{
if(val == 2)
return(true);
else
return(false);
}

Exception
09-13-2004, 01:52 AM
Theko:

That would be nice, if it worked. I don;t understand how you go from step 7 to step 8. It is by slecting each individual polygon and applying bandsaw to it, correct? That would make it an additional 5 steps to do it. Also, with bandsaw you still have the very annoying 'Direction' problem which is totally ambiguous. Also there is the the problem of the 'one big polygon' most of the time not being one big polygon but being hundreds of poly's... I'm afraid Ive tried everything there is to try with bandsaw, and it won't work in this equation. Thanks a lot for the effort tho, and flipping is certainly more effective than cutting and pasting.

Faulknermano: I get a Bad Magic value in modeler [8] with the script...

So no solution yet.. keep em commin guys! : )

faulknermano
09-13-2004, 07:47 AM
Faulknermano: I get a Bad Magic value in modeler [8] with the script...

)

does the lscript compiler tell you what line the error occurs in?

thekho
09-13-2004, 11:37 AM
I made mistake to wrote it (step 8 were wrong) cos i was very tired last night. Sorry about it.

1) Make Plane, use Sore Drill tool.
2) Select big polygon not small.
3) Flip and unselect polygon.
4) Select small polygon.
5) Use Bandsaw Pro or Bandsaw or Bandsaw and also unselect polygon.
6+7) Select big polygon and flip, but its not finish.
8) Thats final which are similar to your above pic. Select another small polygon each again, repeat step 5 and go on. When you done it and then select big polygon and use flip. Thats all.



Theko:

That would be nice, if it worked. I don;t understand how you go from step 7 to step 8. It is by slecting each individual polygon and applying bandsaw to it, correct? Yes, it is correct.

Exception
09-14-2004, 03:39 AM
Theko:

Well that's pretty much how I do it now... it's a tedious process for lots of windows.

faulk: eh no, it just says "bad magic value on input file d:\..."

faulknermano
09-14-2004, 10:18 AM
faulk: eh no, it just says "bad magic value on input file d:\..."


bad magic value has something to do with lw versioning. but i had someone test this script on lw8 (pc) (script was created using 7.5) and it works. sorry, not sure where the problem lies.

Rory_L
09-14-2004, 10:19 PM
With sincere apologies to Exception for gatecrashing...

Faulknermano: I`ve PM`ed you. Please take a look when you have the time.

Cheers,


R