@Anonymous version 4 had a bug that if the file already contained Geosphere001 and it was not linked to a path the program would crash.
Version 5 below changes this so that a geosphere named Geosphere__Master is used as the base object. It is very unlikely that your Max file would include such a named object and therefore should execute fine.
Please let me know if you have any problems with the program.
-- Creates user specifed number of geospheres of a given radius r
-- that are evenly spaced along the selected spline
--
-- L. Minardi 9/22/2021 version 5
--
-- IMPORTANT - select the path spline before execution
--
if ballsRollout != undefined do
(
try(DestroyDialog ballsRollout)catch()
)
rollout BallsRollout "Balls Along Spline" width:200 height:120
(
spinner 'BallRad' "Ball radius:" range:[0,10000,0.1] fieldWidth:40 type:#float
spinner 'numBalls' "Total number of balls:" range:[0,100000,10] fieldWidth:40 type:#integer
spinner 'numSegs' "Number of ball segments:" range:[0,50,2] fieldWidth:40 type:#integer
button 'btnGo' "Go" pos:[50,75] width:96 height:36 align:#left
on btnGo pressed do
(
if
-- ((selection[1] != undefined) and (superClassOf selection[1] != shape)) then
(selection[1] != undefined) then
(
thePath = selection[1]
clearSelection()
GeoSphere pos:[0.0,0.0,0.0] isSelected:on radius:BallRad.value name:"GeoSphere001__Master" segments:numSegs.value
s01 = selection[1]
s01.pos.controller = Path_Constraint ()
s01.pos.controller.path = ThePath
clearSelection()
for k = 1 to (numBalls.value - 1) do
(
GeoSphere pos:[0.0,0.0,0.0] isSelected:on radius:BallRad.value segments:numSegs.value
s02 = selection[1]
s02.pos.controller = Path_Constraint ()
s02.pos.controller.path = ThePath
delta = "Percent + " + (k as float / numBalls.value ) as string
select $GeoSphere001__Master
paramWire.connect $.pos.controller[#Percent] s02.pos.controller[#Percent] delta
clearSelection()
)
print "DONE"
)
else
(
messageBox "Select a shape object!"
)
)
)
createdialog BallsRollout
lee.minardi