Notifications
Clear all

[Closed] PLEASE HELP! Simple maxscript required

Hi there!

I’m trying to get hold of a simple maxscript to help with an architectural project involving panels.

I’m really after a way to randomly generate the order of certain panels in an array.

There are 11 panel types (a,b,c,d,ee,f,g,h,i,j,k, see below)

a,b,c,d and ee must be included, along with either (f and g and h) or (i) or (j and k)

(eg, a,b,c,d,ee,f,g,h)

or

(eg, a,b,c,d,ee,i)

or

(eg, a,b,c,d,ee,j,k)

The panels are all 3000 tall (see below) and when combined in any order side by side in either of the 3 methods, add up to 2465 wide.

The only other rules are that no panel the same (a and b, d and ee, or f and g and h) can be next to each other, and that panels d or e cant be at the start or on the end of the array.

Just wondering if anyone had any good ideas of where to start?

many thanks!

–Colours, Black, creme, grey
–a.wirecolor = [0,0,0]
–a.wirecolor = [255,214,122]
–a.wirecolor = [123,121,115]

– create boxes
a = box pos:[0,0,0] width:330 height:3000 length:180
offset = 0.0
a.wirecolor = [123,121,115]

b = box pos:[500,0,0] width:330 height:3000 length:180
offset = 0.0
b.wirecolor = [123,121,115]

c = box pos:[1000,0,0] width:500 height:3000 length:300
offset = 0.0
c.wirecolor = [255,214,122]

d = box pos:[1500,0,0] width:420 height:3000 length:10
offset = 0.0
d.wirecolor = [0,0,0]

ee = box pos:[2000,0,0] width:420 height:3000 length:10
offset = 0.0
ee.wirecolor = [0,0,0]

f = box pos:[2500,0,0] width:155 height:3000 length:80
offset = 0.0
f.wirecolor = [255,214,122]

g = box pos:[3000,0,0] width:155 height:3000 length:80
offset = 0.0
g.wirecolor = [255,214,122]

h = box pos:[3500,0,0] width:155 height:3000 length:80
offset = 0.0
h.wirecolor = [255,214,122]

i = box pos:[4000,0,0] width:465 height:3000 length:80
offset = 0.0
i.wirecolor = [255,214,122]

j = box pos:[4500,0,0] width:155 height:3000 length:80
offset = 0.0
j.wirecolor = [255,214,122]

k = box pos:[5000,0,0] width:345 height:3000 length:80
offset = 0.0
k.wirecolor = [255,214,122]

1 Reply

well, maybe there is a simple solution, but i didn’t find it. Anyway, this looked so interesting that i couldn’t keep myself messing with it. Not very elegant solution, but it creates some nice patterns, and (i hope) not breaks the rules



(
 local yOffset = 0
 local a = #("a",330,3000,180,[123,121,115])
 local b = #("b",330,3000,180,[123,121,115])
 local c = #("c",500,3000,300,[255,214,122])
 local d = #("d",420,3000,10,[0,0,0])
 local ee = #("ee",420,3000,10,[0,0,0])
 local f = #("f",155,3000,80,[255,214,122])
 local g = #("g",155,3000,80,[255,214,122])
 local h = #("h",155,3000,80,[255,214,122])
 local i = #("i",465,3000,80,[255,214,122])
 local j = #("j",155,3000,80,[255,214,122])
 local k = #("k",310,3000,80,[255,214,122])
 local baseItems = #(a,b,c,d,ee)
 local altItems = #()
 altItems[1] = #(f,g,h)
 altItems[2] = #(i)
 altItems[3] = #(j,k)
  
 local allItems = #()
 local theResult = #()
 local noboxes
 
 local cnt
 fn chooseAlts = (
  v1 = altItems[random 1 3]
  return v1
 )
 fn gimmeFirst = (
  r1 = allItems[random 1 allItems.count]
  counter = 0
  while (r1[1] == "d" or r1[1] == "ee" and counter < 20) do (
   counter += 1
   r1 = allItems[random 1 allItems.count]
  )
  if(counter >= 20) then noboxes = 1
  return r1
 )
 fn gimmeNext indx = (
  counter = 0
  edell = theResult[indx-1]
  r1 = allItems[random 1 allItems.count]
  while (r1[5] == edell[5] and counter < 20) do (
   counter += 1
   r1 = allItems[random 1 allItems.count]
  )
  if(counter >= 20) then noboxes = 1
  return r1
 )
 fn doIt = (
  noboxes = 0
  theResult = #()
  allItems = baseItems + chooseAlts()
  cnt = allItems.count
  --print allItems
  --format "%
" cnt
  -- first box
  theResult[1] = gimmeFirst()
  -- next boxes
  for i = 2 to (cnt-1) do (
   num = findItem allItems theResult[i-1]
   deleteItem allItems num
   theResult[i] = gimmeNext i
  )
  num = findItem allItems theResult[cnt-1]
  deleteItem allItems num
  -- last box
  theResult[cnt] = allItems[1]
  --format "ratk : %
" theResult[cnt]
  if (theResult[cnt][1] == "d" or theResult[cnt][1] == "ee") do (
   noboxes = 1
  )
  
  --print theResult
  if (noboxes == 0) do (
   local offsets = #(0)
   local posoffset = 0
   for i in theResult do append offsets i[2]
   o = 1
   yOffset += 400
   for i in theResult do (
	o += 1
	posoffset += 0.5 * offsets[o-1] + 0.5 * offsets[o]
	box name:i[1] pos:[posoffset,yOffset,0] wirecolor:i[5]  width:i[2]  height:i[3] length:i[4]
   )
   completeRedraw()
  )
 )
 rollout r_thePanels "the Panels"
 (
  label lbl_note1 "If nothing happens, "
  label lbl_note2 "just keep pushing..  XD"
  button btn_doit "do it" width:100 height:20 align:#center
  
  on btn_doit pressed do doIt()
  
 )
 CreateDialog r_thePanels pos:[900,300] width:140
)