Notifications
Clear all

[Closed] Pyramid builder script

Im trying to write a script that will make a pyramid out of a number of cubes , so far I have got my script to make a set of cubes that fit together in one big block . but I need the script to only make the cubes on the outside edge of each level and not make the cubes inside so I dont end up with a load of useless cubes i’m not going to see. also the script needs to cut back on each layer so it goes up in steps like the picture below. Ive only wrote a few scripts and that was sometime back so Im a bit stuck with this these two points.

This is the line of code that makes the boxxes

theBox = ChamferBox pos:[(bwi),(dli),(step*he)] width:wi length:li height:he fillet:fi Fillet_Segments:gi

am I goin about this the right way ? is there a more simple way and maybe I have missed it ?

Any help with this would be great … Thanks for reading

This is the output from my script so far

This is what I want my script to output, there are no cubes on the inside.

here is my script so far ;

 
	 ----- Ver 1.0
-- File Name	 : 3D Pyramid
-- Subject		: Makes a 3D Pyramid out of box objects
-- Enabled 3DSMax : 3dsmax 8.x
-- Description	: Makes a 3D Pyramid.
(
if main_win != undefined do closerolloutfloater main_win
main_win = newRolloutFloater "3D Pyramid" 200 400
rollout params "3D Pyramid"
(
button Doit "Create Pyramid" tooltip:"will make Pyramid" width: 130
Spinner x "Depth : " range:[1,100,5] type:#integer align:#right width:70 offset:[-1,0]
	Spinner y "Length : " range:[1,100,5] type:#integer align:#right width:70 offset:[-1,0]
Spinner st "Steps : " range:[1,100,5] type:#integer align:#right width:70 offset:[-1,0]
Spinner f "Fillet size : " range:[0,10,0] type:#integer align:#right width:55 offset:[-1,0]
Spinner g "Fillet segs : " range:[0,10,0] type:#integer align:#right width:55 offset:[-1,0]
Spinner h "box height : " range:[1,500,10] type:#integer align:#right width:80 offset:[-1,0]
Spinner l "box width : " range:[1,1000,10] type:#integer align:#right width:80 offset:[-1,0]
Spinner w "box length : " range:[1,1000,10] type:#integer align:#right width:80 offset:[-1,0]
Spinner zn "noise height : " range:[1,50,0] type:#integer align:#right width:80 offset:[-1,0]
Spinner yn "noise width : " range:[1,50,0] type:#integer align:#right width:80 offset:[-1,0]
Spinner xn "noise length : " range:[1,50,0] type:#integer align:#right width:80 offset:[-1,0]
 
on Doit pressed do
( 
Nx = xn.value
Ny = yn.value
Nz = zn.value
stp = st.value 
wi = w.value
li = l.value
fi = f.value
gi = g.value
row = x.value
he = h.value
count = y.value
 
delete $Block* 
	 for d = 1 to row do ( -- rows
 
	 for b = 1 to count do ( -- colums
 
	 for step = 1 to stp do ( -- levels
 
theBox = ChamferBox pos:[(b*wi),(d*li),(step*he)] width:wi length:li height:he fillet:fi Fillet_Segments:gi
theBox.name = (uniquename "Block") 
			)
	 )
	 ( 
)
)
)
)
addRollout params main_win
 
Rollout params "About and Help"
(
Group "Help"
(
button help_e "Info" width:60
)
Group "About "
(
Label a1 "3D Pyramid"
Label a2 "By Dmax"
 
)
on help_k pressed do
messagebox ("do it") beep:no title:"Help info "
on help_e pressed do
messagebox ("3D Pyramid Maker") beep:yes title:"Help"
)
addRollout params main_win
)

10 Replies

Do you actually need the cubes to be separate, or do you just want the visible shape of the tiered pyramid?

the cubes need to be separate

To only draw cubes at perphery, simply provide a conditional inside the inner most loop just before you create ChamferBox like this

 
if ((d==1 or d==row) and (b==1 or b==count) and (step==1 or step==stp)) then
( 
theBox = ChamferBox pos:[(b*wi),(d*li),(step*he)] width:wi length:li height:he fillet:fi Fillet_Segments:gi
theBox.name = (uniquename "Block")
)

Hope this helps
Mobeen

Thanks Mobeen I will give that a go

I had to change your code a small bit but you got me on the right path Thanks again Mobeen

if ((d==1 or d==row) or (b==1 or b==count))

Well I got it working in the end :). Ive still got to sort a few bit’s out . one thing I would like it to do is remember the last settings it had from the last time it was run . could anyone here tell me if this can be done and if so what commands should I be reading up on . Thanks for reading

The one of the many outputs it can do

To save it’s settings it’s pretty easy. The way I preffer doing it is by using an .ini file.
Look in reference for getIniSetting and setIniSetting. It’s really easy and straightforward.

Thanks vasilescu_anton I will look into that once again thanks for the reply

Interesting !

Could you please share the script ?
or only the loop creation part ?

for saving and loading settings, as vasilescu_anton said .INI file is good
something like :

INIfile=getdir(#plugcfg)+[\MyStuff.ini](file://\MyStuff.ini)

setINISetting INIfile “My Section” “MySpinner” (MySpinner.value as string)
setINISetting INIfile “My Section” “MyCheckbox” (MyCheckbox.state as string)
and then

MySpinner.value=(getINISetting INIfile “My Section” “MySpinner”) as integer
MyCheckbox.state=(getINISetting INIfile “My Section” “MyCheckbox” as boolean)
Have fun

I will post it up in a few days , I still have to clean it up a bit.

Page 1 / 2