ScriptSpot

Forum topic · Scripts Wanted

Divide Evenly?

By cmjohncheng · 2012-05-10

Description

Divide Evenly? like attachment show, one box with a width, editpoly, connect, chamfer, each part cant get even width...any method or script can simple click and get the even part?or like i input a number of part, and yellow color's width, then get the correct result?

Attachments
Comments (4)

harumscarum · 2012-05-11

how to paste code here btw?

use tag <code> ...your code... </code>

barigazy · 2012-05-11

like this
and one suggestion
if you don't use else statement ei *if-then-else*
then simply type *if-do*
macroScript ConnectEdgesByDistance
category:"AnyCategory"
(
On IsVisible Return Filters.Is_EPolySpecifyLevel #{3}
On IsEnabled Return Filters.Is_EPoly()
On Execute Do
(
rollout igorznag_ced "Connect Edges by Distance" width:220 height:40
(
button btn_connect "Connect" pos:[150,10]
spinner sp_distance "Distance:" range:[0,3.40E38,1] pos:[15,10] scale:1.0 fieldwidth:60 type:#worldunits
on btn_connect pressed do
(
undo on
(
if (classof $==Editable_Poly) then
(
$.convertSelection #edge #vertex; $.convertSelection #vertex #face requireAll:true;
fs=(polyop.getFaceSelection $) as array; es=polyop.getEdgeSelection $;
for i=1 to fs.count do
(
fe = (polyOp.getFaceEdges $ fs[i]) as bitarray ; sel_face_edges=es*fe
if (sel_face_edges.NumberSet==2) then
(
polyop.setEdgeSelection $ sel_face_edges; sel_face_edges=sel_face_edges as array
ev=polyOp.getEdgeVerts $ sel_face_edges[1]
vert1=polyOp.getVert $ ev[1]; vert2=polyOp.getVert $ ev[2]
d=distance vert1 vert2; distance_between_edge=sp_distance.value
if (distance_between_edge > 0) then
(
temp=1.0*d/distance_between_edge
connect_edges_count=(floor temp) as integer
if (temp-connect_edges_count>=0.5) then connect_edges_count=connect_edges_count+1
connect_edges_count = connect_edges_count-1
if (connect_edges_count>0) then
(
$.connectEdgeSegments=connect_edges_count
$.ConnectEdges edgeFlag:1
$.connectEdgePinch=0
$.connectEdgeSlide=0
)
)
)
)
)
) ; redrawViews()
)
)
createdialog igorznag_ced)
)

harumscarum · 2012-05-11

macroScript ConnectEdgesByDistance

category:"AnyCategory" 

 

 

(

On IsVisible Return Filters.Is_EPolySpecifyLevel #{3}

On IsEnabled Return Filters.Is_EPoly()

 

 

On Execute Do (

 

rollout igorznag_ced "Connect Edges by Distance" width:220 height:40 

button btn_connect "Connect" pos:[150,10]

spinner sp_distance "Distance:" range:[0,3.40E38,1] pos:[15,10] scale:1.0 fieldwidth:60 type:#worldunits

on  btn_connect pressed do

( undo on

( if(classof $==Editable_Poly)then

( $.convertSelection #edge #vertex; $.convertSelection #vertex #face requireAll:true;

fs=(polyop.getFaceSelection $) as array; es=polyop.getEdgeSelection $;

for i=1 to fs.count do

(

fe=(polyOp.getFaceEdges $ fs[i]) as bitarray; sel_face_edges=es*fe;

if(sel_face_edges.NumberSet==2)then

( polyop.setEdgeSelection $ sel_face_edges; sel_face_edges=sel_face_edges as array

ev=polyOp.getEdgeVerts $ sel_face_edges[1]

vert1=polyOp.getVert $ ev[1]; vert2=polyOp.getVert $ ev[2]

d=distance vert1 vert2; distance_between_edge=sp_distance.value;

if(distance_between_edge>0)then

( temp=1.0*d/distance_between_edge; connect_edges_count=(floor temp) as integer;

if(temp-connect_edges_count>=0.5)then connect_edges_count=connect_edges_count+1;

connect_edges_count=connect_edges_count-1;

if(connect_edges_count>0)then

( $.connectEdgeSegments=connect_edges_count; $.ConnectEdges edgeFlag:1;

$.connectEdgePinch=0; $.connectEdgeSlide=0;

))))));redrawViews();

));createdialog igorznag_ced)) 

cmjohncheng · 2012-05-12

Thanks, but maybe u misunderstanding my meaning, ur script is like after connect, i thinking to get the result after chamfer, like picture show, erm, i got one box, width is 2000, divide by 5 = 333.33, ur script is same, if type 333.33 by ur script can let it auto divide by 5 too, but still hvnt get the result after chamfer.

after divide by 5, i need that 5 edge chamfer(let say i input a number(like picture is 100), but pink color part after chamfer should get the same width.

Attachments