PDA

View Full Version : dividing polygon edge by verts.


cyfer
08-29-2006, 11:45 AM
hi , i'm so noob to scripting ..

and i'm looking for a script that divides an edge " in poly object " by a vertex or 2 or 3 ...

this function was infact in the meshtools script , which stoped to work since version 7
author says it works with 8 , and there is a thread here about meshtools , yeah it works with alot of bugs ....
on the other hand i don't really need the whole meshtoos , i just need the code that divides
the edges only , and i can't ectract it from meshtools because it doesn't work

is there a simple way to do that function , with simple code that a noob like me can understand ?

HalfVector
08-29-2006, 01:03 PM
I don't know MeshTools and I don't know if this is the best way to do that, but...

try ( destroyDialog roDivideEdge ) catch ()

rollout roDivideEdge "Divide Edge" (
spinner spnDivs "Divide by " range:[2,1000,2] type:#integer
button btnDivide "Divide"

fn divideEdge poly edge divs = (
local nVerts = divs - 1
for div = 1 to nVerts do (
local frac = 1.0 / (divs as Float)
local newVert = polyOp.divideEdge poly edge frac
local edges = (polyOp.getEdgesUsingVert poly newVert) as Array
if edges[1] == edge then edge = edges[2] else edge = edges[1]
divs -= 1

)
)

on btnDivide pressed do (
if selection.count == 1 do (
if (classOf selection[1]) == Editable_Poly do (
local edgeSel = polyOp.getEdgeSelection selection[1] as Array
if edgeSel.count > 0 do (
for edge in edgeSel do (
divideEdge selection[1] edge spnDivs.value
)
)
)
)
)
)

createDialog roDivideEdge

It divides an edge (or a selection of edges) a specified number of times. The vertices are spaced evenly along the edge. The most important thing in this script is the funcion divideEdge.

I didn't test it much so could have errors!.

Hope that helps.

cyfer
08-29-2006, 01:27 PM
thanks a lot

that was quick !!

i'm gonna test it to see what it brings out

thanks

CGTalk Moderation
08-29-2006, 01:27 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.