[Closed] scripting help
hello, i´m a new by and i need a script to do tubes along a spline and the tubes are all with diferent radius. kinf regards
Chew on this:
(
-- Create a shape
s = SplineShape name:(uniqueName #mySpline) wirecolor:black
addNewSpline s
for i = 1 to 10 do addKnot s 1 #smooth #curve (random [-200,-200,-200] [200,200,200])
updateShape s
-- get curve length
lengthS = curveLength s 1
-- define cylinder amount
steps = 50
-- Create the cylinders
for i = 0 to steps - 1 do
(
b = cylinder name:(uniqueName #followSpline) height:(lengthS/steps) radius:(random 1 20) heightsegs:20 sides:20 pos:s.pos parent:s wirecolor:orange
addModifier b (SpacePathDeform path:s Percent_along_path:(i * 100.0 / steps))
)
)
Goodluck,
-Johan
Hi JHN, and thank for the help, i have tried the script but is not what i want, i have attacched an image to explained better. kind regards
Hi,
You could do this ith the spacing tool, and then randomise the cylinders using a simple script like this:
for s in selection do s.radius=(random 1. 5)
No need to hit it with a sledgehammer
J.
hi j_man , thank you for help, i have tried that and it work , but about ranomize the space between the cylinders
for s in selection do s.space ? =( random x y)
i have tried with “distance” and “spacing” but i get an error.
kind regards
Ah – I’m afraid this is a little more complicated.
To acheive this is a little morecomplicated. You will want to place your cylinders along a shape using a path controller, and then randomise the path percentage.
Josh.
BTW great script Johan!
OK, this is a good start for you.
pth=$line01 -- the path shape
num=20 -- the number of cylinders along the path
radius=5 -- the radius of the cylinders
var=.1 -- the variation of radius and of distance between objects
for i=1 to num do
(
c=cylinder height:100 radius:(radius*(random (1-var) (1+var)))
p=Path_Constraint ()
c.pos.controller = p
p.path=pth
x=(100.0/num)
p.percent=(x*i)+(i*(random (1-var) (1+var)))
)
Josh.