Help with Parametric Hexagon Array: Type Error: Call needs function or class, got: 6
I'm currently working through a book called, Parametric Design for Architecture, and can't get one of the tutorial projects im doing to work. I think I need to adjust my order of operations, but am to noob to know which process's should come first for the rollout, any help is appreciated.
My Error:
--------------------------- MAXScript Rollout Handler Exception ---------------------------
-- Type error: Call needs function or class, got: 6
--------------------------- OK ---------------------------
My Script:
utility Hexagons "Hexagons"
(
global radius = 20.0
global spacing = 1
global rows = 6
global columns = 5
global myHexagons =#() -- an array of hexagons
--this function erases the previous grid and creates a new one.
fn generateHexagons=
(
--Empty the myHexagons array and delete all the hexagons in it.
hexCount = myHexagons.count
for i = 1 to hexCount by 1 do
(
tobedeleted = myHexagons[1]
deleteItem myHexagons 1
if(isDeleted tobedeleted !=true) then
(
delete tobedeleted
)
)
myHexagons.count = 0
--Create myHexagon array with parameters
offset = (cos 30)*(radius) + (spacing/2.0)
for i=0 to (columns - 1) by 1 do
(
for j=0 to (rows -1) by 1 do
(
hex = Ngon radius:radius nsides:6 scribe:1 pos:[0,0,0]
hex.wirecolor = white
case of
(
(mod i 2 == 0) : move hex [(i*((radius*1.5) + (spacing * (sqrt 0.75)))), ((j*2*offset) + offset), 0]
(mod i 2 != 0) : move hex [(i*((radius*1.5) + (spacing * (sqrt 0.75)))), ((j*2*offset)), 0]
)
append myHexagons hex
)
)
)
-- Create the User Interface
spinner radius_spinner "Radius:" range:[1,5000, radius] type:#WorldUnits
spinner spacing_spinner "Spacing:" range:[-5000,5000, spacing] type:#WorldUnits
spinner rows_spinner "Rows:" range:[0,5000, rows] type:#integer
spinner columns_spinner "Columns:" range:[0,5000, columns] type:#integer
button generate_button "Generate" enabled:true
on radius_spinner changed amt do -- when spinner value changes....
(
radius = amt
generateHexagons()
)
on spacing_spinner changed amt do -- when spinner value changes...
(
spacing = amt
generateHexagons()
)
on rows_spinner changed amt do -- when spinner value changes...
(
rows = amt
generateHexagons()
)
on columns_spinner changed amt do -- when spinner value changes
(
columns = amt
generateHexagons()
)
on generate_button pressed do
(
generateHexagons()
)
)
--end of utility
Comments
figured it out, just a silly
figured it out, just a silly error in:
for j=0 to (rows -1) by 1 do
no space sorry for wasting your time lol
.
There can be a space. This also works:
But you already figured out that -1 is a negative number and don't mean to substract 1 from ROWS and this causes the error.
Tools and Scripts for Autodesk 3dsMax