ScriptSpot

Forum topic · ScriptSpot How To

Distribute grouped objects along edges

By thekevnn · 2013-01-06

Description

hi. I'm stuck at trying to distribute grouped objects along a given objects edges. At first I thought it was similar as with the case of vertices but it turned out to be quite complicated.
Hope I was clear. Anyones help highly appreciated.

Comments (3)

Thanks.

Yusuf_ES · 2017-01-07

"barigazy" Thank you.

#2 example

barigazy · 2013-01-27

And this is the thing that you asked

delete objects
numOfCopy = 8
obj = converttopoly (Box length:200 width:200 height:200 isselected:on wirecolor:black)
polyop.setEdgeSelection obj 8
max modify mode ; subobjectLevel = 2 ; max zoomext sel all

selEdge = (polyop.getEdgeSelection obj as array)[1]
edgVerts = polyOp.getEdgeVerts obj selEdge
a = for i = 1 to 2 collect (polyOp.getvert obj edgVerts[i])
theDir = normalize (a[2]-a[1])
theLength = (distance a[2] a[1])/(numOfCopy-1)
ball = sphere radius:5 pos:a[1]
for i = 1 to (numOfCopy-1) do
(
ballCopy = copy ball
ballCopy.pos += (i*theLength*theDir)
ballCopy.wirecolor = random black white
)

#1 example

barigazy · 2013-01-27

In this example I use splineShape

delete objects
numOfCopy = 8
a = #([15,30,20], [200,300,500])
b = splineshape wirecolor:yellow
addnewspline b
for i = 1 to 2 do addKnot b 1 #corner #curve a[i]
updateshape b
theDir = normalize (a[2]-a[1])
theLength = (distance a[2] a[1])/(numOfCopy-1)
ball = sphere radius:5 pos:a[1]
for i = 1 to (numOfCopy-1) do
(
ballCopy = copy ball
ballCopy.pos += (i*theLength*theDir)
)