Thanks erilaz! Here’s my “final” version, with one more system using all three axes and with a little more pen commands. Hope you enjoy. Until the next challenge hehe 
(
fn laine pointA pointB =
(
ss=SplineShape pos:pointA
addNewSpline ss
addKnot ss 1 #corner #line PointA
addKnot ss 1 #corner #line PointB
updateShape ss
ss
)
-- Koch variant which only uses right angles
rollout kochmain1 "Koch 1"
(
spinner spn_nmax "Iterations:" type:#integer range:[0,100,0] align:#center
spinner spn_angle "Angle:" type:#integer range:[1,180,90] align:#center
button btn_doit "Do it" align:#center
progressBar doit_prog "" align:#center
on btn_doit pressed do
(
-- L-System variable related declaration
seed(timestamp())
t_start=timestamp()
doit_prog.value=0
n=0 -- Current iteration
seq="F" -- Axiom
-- Construct L-system string
for n=0 to spn_nmax.value do
(
seqtemp=""
for i=1 to seq.count do
(
case of
(
(seq[i]=="F"):
(
if n==0 then seqtemp=seq
else
(
seqtemp=seqtemp+"F+F-F-F+F"
)
)
(seq[i]=="+"):
(
seqtemp=seqtemp+"+"
)
(seq[i]=="-"):
(
seqtemp=seqtemp+"-"
)
)
)
doit_prog.value = 100.*n/spn_nmax.value
seq=seqtemp
)
t_end=timestamp()
print ("L-System string took " + ((t_end - t_start) / 1000.0) as string + " seconds")
-- L-system constructed
--Begin visual representation of L-system
seed(timestamp())
t_start=timestamp()
doit_prog.value=0
suspendEditing() -- Disable Modify Panel to make creation faster
delete $Koch1_* --Delete previous Koch geometry
length=10
angle=spn_angle.value
roda_left=false
roda_right=false
lx=0 -- Last X Point
ly=0 -- Last Y Point
lz=0 -- Last Z Point
af=0 -- Angle Facing
for i=1 to seq.count do
(
case of
(
(seq[i]=="F"):
(
nx=lx+(length*cos(af))
ny=ly+(length*sin(af))
nz=lz
newshape=laine [lx,ly,lz] [nx,ny,nz]
select newshape
newshape.name=uniquename "Koch1_"
newshape.render_displayRenderMesh=true
newshape.wirecolor=white
lx=nx
ly=ny
lz=nz
roda_left=false
roda_right=false
)
(seq[i]=="+"):
(
af+=angle
roda_left=true;
)
(seq[i]=="-"):
(
af-=angle
roda_right=true
)
)
doit_prog.value = 100.*i/seq.count
)
resumeEditing() -- Enable Modify Panel
clearSelection()
max zoomext sel all
t_end=timestamp()
print ("L-System graphic took " + ((t_end - t_start) / 1000.0) as string + " seconds")
-- End visual representation of L-System
-- End Koch
)
)
-- Quadratic Koch island
rollout kochmain2 "Koch 2"
(
spinner spn_nmax "Iterations:" type:#integer range:[0,100,0] align:#center
spinner spn_angle "Angle:" type:#integer range:[1,180,90] align:#center
button btn_doit "Do it" align:#center
progressBar doit_prog "" align:#center
on btn_doit pressed do
(
-- L-System variable related declaration
seed(timestamp())
t_start=timestamp()
doit_prog.value=0
n=0 -- Current iteration
seq="F-F-F-F" -- Axiom
-- Construct L-system string
for n=0 to spn_nmax.value do
(
seqtemp=""
for i=1 to seq.count do
(
case of
(
(seq[i]=="F"):
(
if n==0 then seqtemp=seq
else
(
seqtemp=seqtemp+"F-F+F+FF-F-F+F"
)
)
(seq[i]=="+"):
(
seqtemp=seqtemp+"+"
)
(seq[i]=="-"):
(
seqtemp=seqtemp+"-"
)
)
)
doit_prog.value = 100.*n/spn_nmax.value
seq=seqtemp
)
t_end=timestamp()
print ("L-System string took " + ((t_end - t_start) / 1000.0) as string + " seconds")
-- L-system constructed
--Begin visual representation of L-system
seed(timestamp())
t_start=timestamp()
doit_prog.value=0
suspendEditing() -- Disable Modify Panel to make creation faster
delete $Koch2_* --Delete previous Koch geometry
length=10
angle=spn_angle.value
roda_left=false
roda_right=false
lx=0 -- Last X Point
ly=0 -- Last Y Point
lz=0 -- Last Z Point
af=0 -- Angle Facing
for i=1 to seq.count do
(
case of
(
(seq[i]=="F"):
(
nx=lx+(length*cos(af))
ny=ly+(length*sin(af))
nz=lz
newshape=laine [lx,ly,lz] [nx,ny,nz]
select newshape
newshape.name=uniquename "Koch2_"
newshape.render_displayRenderMesh=true
newshape.wirecolor=white
lx=nx
ly=ny
lz=nz
roda_left=false
roda_right=false
)
(seq[i]=="+"):
(
af+=angle
roda_left=true;
)
(seq[i]=="-"):
(
af-=angle
roda_right=true
)
)
doit_prog.value = 100.*i/seq.count
)
resumeEditing() -- Enable Modify Panel
clearSelection()
max zoomext sel all
t_end=timestamp()
print ("L-System graphic took " + ((t_end - t_start) / 1000.0) as string + " seconds")
-- End visual representation of L-System
-- End Koch
)
)
-- Bracketed OL System
rollout brackmain1 "Bracketed OL System 1"
(
spinner spn_nmax "Iterations:" type:#integer range:[0,100,0] align:#center
spinner spn_angle "Angle:" type:#integer range:[1,180,26] align:#center
button btn_doit "Do it" align:#center
progressBar doit_prog "" align:#center
on btn_doit pressed do
(
-- L-System variable related declaration
seed(timestamp())
t_start=timestamp()
doit_prog.value=0
n=0 -- Current iteration
seq="F" -- Axiom
-- Construct L-system string
for n=0 to spn_nmax.value do
(
seqtemp=""
for i=1 to seq.count do
(
case of
(
(seq[i]=="F"):
(
if n==0 then seqtemp=seq
else
(
seqtemp=seqtemp+"FF-[-F+F+F]+[+F-F-F]"
)
)
(seq[i]=="+"):
(
seqtemp=seqtemp+"+"
)
(seq[i]=="-"):
(
seqtemp=seqtemp+"-"
)
(seq[i]=="["):
(
seqtemp=seqtemp+"["
)
(seq[i]=="]"):
(
seqtemp=seqtemp+"]"
)
)
)
doit_prog.value = 100.*n/spn_nmax.value
seq=seqtemp
)
t_end=timestamp()
print ("L-System string took " + ((t_end - t_start) / 1000.0) as string + " seconds")
-- L-system constructed
--Begin visual representation of L-system
seed(timestamp())
t_start=timestamp()
doit_prog.value=0
suspendEditing() -- Disable Modify Panel to make creation faster
delete $Branch1_* --Delete previous Koch geometry
length=10
angle=spn_angle.value
roda_left=false
roda_right=false
lx=0 -- Last X Point
ly=0 -- Last Y Point
lz=0 -- Last Z Point
af=90 -- Angle Facing
stack_af=#()
stack_x=#()
stack_y=#()
stack_z=#()
for i=1 to seq.count do
(
case of
(
(seq[i]=="F"):
(
nx=lx+(length*cos(af))
ny=ly+(length*sin(af))
nz=lz
newshape=laine [lx,ly,lz] [nx,ny,nz]
select newshape
newshape.name=uniquename "Branch1_"
newshape.render_displayRenderMesh=true
newshape.wirecolor=white
lx=nx
ly=ny
lz=nz
roda_left=false
roda_right=false
)
(seq[i]=="+"):
(
af+=angle
roda_left=true;
)
(seq[i]=="-"):
(
af-=angle
roda_right=true
)
(seq[i]=="["):
(
append stack_af af
append stack_x lx
append stack_y ly
append stack_z lz
)
(seq[i]=="]"):
(
af=stack_af[stack_af.count]
lx=stack_x[stack_x.count]
ly=stack_y[stack_y.count]
lz=stack_z[stack_z.count]
deleteItem stack_af stack_af.count
deleteItem stack_x stack_x.count
deleteItem stack_y stack_y.count
deleteItem stack_z stack_z.count
)
)
doit_prog.value = 100.*i/seq.count
)
resumeEditing() -- Enable Modify Panel
clearSelection()
max zoomext sel all
t_end=timestamp()
print ("L-System graphic took " + ((t_end - t_start) / 1000.0) as string + " seconds")
-- End visual representation of L-System
-- End Koch
)
)
-- Bush
rollout bushmain1 "Bush 1"
(
spinner spn_nmax "Iterations:" type:#integer range:[0,100,0] align:#center
spinner spn_angle "Angle:" type:#integer range:[1,180,26] align:#center
button btn_doit "Do it" align:#center
progressBar doit_prog "" align:#center
on btn_doit pressed do
(
-- L-System variable related declaration
seed(timestamp())
t_start=timestamp()
doit_prog.value=0
n=0 -- Current iteration
seq="F" -- Axiom
-- Construct L-system string
for n=0 to spn_nmax.value do
(
seqtemp=""
for i=1 to seq.count do
(
case of
(
(seq[i]=="F"):
(
if n==0 then seqtemp=seq
else
(
seqtemp=seqtemp+"F-[F\\F+F&F]/[F[-F]^F]/F"
)
)
default:
(
seqtemp=seqtemp+seq[i]
)
)
)
doit_prog.value = 100.*n/spn_nmax.value
seq=seqtemp
)
t_end=timestamp()
print ("L-System string took " + ((t_end - t_start) / 1000.0) as string + " seconds")
-- L-system constructed
--Begin visual representation of L-system
try
(
seed(timestamp())
t_start=timestamp()
doit_prog.value=0
suspendEditing which:#modify alwaysSuspend:true -- Disable Modify Panel to make creation faster
delete $Bush1_* --Delete previous Koch geometry
angle=spn_angle.value
blength=10
afx=90
afy=0
afz=90
lpx=0
lpy=0
lpz=0
npx=0
npy=0
npz=0
stack_afx=#()
stack_afy=#()
stack_afz=#()
stack_x=#()
stack_y=#()
stack_z=#()
for i=1 to seq.count do
(
case of
(
(seq[i]=="F"):
(
npx=lpx+(blength*cos(afx))
npy=lpy+(blength*sin(afy))
phi=90-afz
npz=lpz+(sin(afz)*blength*cos(phi))
newshape=laine [lpx,lpy,lpz] [npx,npy,npz]
select newshape
newshape.name=uniquename "Bush1_"
newshape.render_displayRenderMesh=true
newshape.render_sides=4
newshape.wirecolor=white
lpx=npx
lpy=npy
lpz=npz
)
(seq[i]=="+"):
(
afx+=angle
afy+=angle
)
(seq[i]=="-"):
(
afx-=angle
afy-=angle
)
(seq[i]=="\\"):
(
afx+=angle
afz+=angle
)
(seq[i]=="/"):
(
afx-=angle
afz-=angle
)
(seq[i]=="&"):
(
afy+=angle
afz+=angle
)
(seq[i]=="^"):
(
afy-=angle
afz-=angle
)
(seq[i]=="|"):
(
afx+=90-afx
afy+=0
afz+=90
)
(seq[i]=="["):
(
append stack_afx afx
append stack_afy afy
append stack_afz afz
append stack_x lpx
append stack_y lpy
append stack_z lpz
)
(seq[i]=="]"):
(
afx=stack_afx[stack_afx.count]
afy=stack_afy[stack_afy.count]
afz=stack_afz[stack_afz.count]
lpx=stack_x[stack_x.count]
lpy=stack_y[stack_y.count]
lpz=stack_z[stack_z.count]
deleteItem stack_afx stack_afx.count
deleteItem stack_afy stack_afy.count
deleteItem stack_afz stack_afz.count
deleteItem stack_x stack_x.count
deleteItem stack_y stack_y.count
deleteItem stack_z stack_z.count
)
)
doit_prog.value = 100.*i/seq.count
)
clearSelection()
max zoomext sel all
t_end=timestamp()
print ("L-System graphic took " + ((t_end - t_start) / 1000.0) as string + " seconds")
throw "Done"
)
catch
(
resumeEditing which:#modify alwaysSuspend:true-- Enable Modify Panel
)
)
)
rollout aboutmain1 "About"
(
label lbl_label1 "by Artur Leão for CGTalk Maxscript Challenge" align:#center
hyperlink hl_hp "Artur Leão Portfolio" color:(color 0 0 255) address:"[http://dimensao3.com/al](http://dimensao3.com/al)" align:#center
)
try
(
closerolloutfloater lsystemsfloater
) catch()
lsystemsfloater = NewRolloutFloater "L-Systems" 300 555
AddRollout kochmain1 lsystemsfloater
AddRollout kochmain2 lsystemsfloater
AddRollout brackmain1 lsystemsfloater
AddRollout bushmain1 lsystemsfloater
AddRollout aboutmain1 lsystemsfloater
)
And a simple image created with the last system.
Download here (1280x1024)
