PDA

View Full Version : facade generator array scripting


mattoso
12-26-2006, 06:56 PM
hi
i know its holiday season but im a total novice and could do with someone pointing me in the
right direction.

I want to script a louvre generator for creating slatted facades for 3d building models.

I have begun a script with boxes where the louvre slats will go but dont know if im better off
using Matrix3 or if that will be too complicated (it doesnt really need to be mouseclick based.)

- i want it so the number of floors to the building can be changed and each floor will have
its own strip of facade but if you change the number of floors spinner more than once then
it just creates new boxes (to be facades) over the top rather than instead of the existing.

ALSO when it comes to creating the slatted louvres (which would replace the boxes)
i dont know what the best way to script it is, perhaps an array of lines (with thickness)?

HERE IS THE SCRIPT SO FAR (i know its a mess)
--louvre generator

rollout ssRoll "louvre generator"
(
group "Basic"
(
spinner spn_facadeWidth "Facade Width " type:#float range: [1,100,50]
spinner spn_floorHeight "Floor Height " type:#float range: [1,100,3.2]
spinner spn_numFloors "Number of Floors " type:#integer range:[1,10,1]
button but_createFacade "Create Facade "
pickbutton pbt_pickFacade " Pick Facade " autodisplay:true
)
local facade
--events
on but_createFacade pressed do
(
facade = box()
facade.width = spn_facadeWidth.value
facade.length = 0.2
facade.height = spn_floorHeight.value
)

on spn_facadeWidth changed value do
(
facade.width = spn_facadeWidth.value
)

on spn_floorHeight changed value do
(
facade.height = spn_floorHeight.value
)
--push button not used yet
on pbt_pickFacade picked facade do
(
facade.width = spn_facadeWidth.value
facade.height = spn_floorHeight.value
)
--this loop doesnt seem right as it creates multiples if numFloors is changes 2+ times
on spn_numFloors changed value do
for i = 2 to spn_numFloors.value do
(
c = reference facade
move c [0,0,(i*spn_floorHeight.value)-spn_floorHeight.value]
)
)

createDialog ssRoll 200 150

ANY HELP WOULD BE VERY APPRECIATED
HAPPY CHRISTMAS
mattoso

hblan
01-03-2007, 04:19 PM
rollout thebox "theboxes"
(
local demobox = undefined
local ori_length = 0.0
local ori_width = 0.0
local ori_height = 0.0
local ori_space = 20
local ori_floorcount = 10
----interface define ----
button loaddemobox "load demo box"
button createfloors "create floors"
group "box setting:"
(
spinner thelength "length:" range:[0.0,10000,ori_length]
spinner thewidth "width:" range:[0.0,10000,ori_width]
spinner theheight "height:" range:[0.0,10000,ori_height]
)
group "floor setting:"
(
spinner thefloorspace "floor space:" range:[0.0,10000,ori_space]
spinner thefloorcount "floor count:" range:[1,10000,ori_floorcount] type:#integer
)
button resetall "reset all"
button deletecreatedboxes "delete my boxes"
--- actions define ------
on loaddemobox pressed do
(
if selection.count ==1 and classof selection[1] == box then
(
demobox = selection[1]
-- set the interface value to the demo box .
thelength.value = demobox.length
thewidth.value = demobox.width
theheight.value = demobox.height
-- delete old boxes .
try(delete $lanhaibo_boxes*)catch()
)else messagebox "make a demobox ,and select the demo box for use."

)
------------------------------
on createfloors pressed do
(
-- check selection for use.
if demobox != undefined then
(
try(delete $lanhaibo_boxes* )catch()

-- create new boxes .
for i =1 to thefloorcount.value do
(
local tempbox = copy demobox name:"lanhaibo_boxes"
tempbox.pos.z += (i-1)*(thefloorspace.value)
tempbox.length = thelength.value
tempbox.width = thewidth.value
tempbox.height = theheight.value
tempbox.wirecolor = white
)

)else messagebox "make a demobox ,and select the demo box for use."
)
----------------------------------
on thelength changed val do createfloors.pressed()
on thewidth changed val do createfloors.pressed()
on theheight changed val do createfloors.pressed()
on thefloorspace changed val do createfloors.pressed()
on thefloorcount changed val do createfloors.pressed()
on resetall pressed do
(
thelength.value = ori_length
thewidth.value = ori_width
theheight.value = ori_height
thefloorspace.value = ori_space
thefloorcount.value = ori_floorcount
demobox = undefined
)
on deletecreatedboxes pressed do try(delete $lanhaibo_boxes*)catch()
---------------------------------------
)createdialog thebox

mattoso
01-08-2007, 12:38 AM
thanks it helps,

however is there a way of doing the same thing but not having to first create a box then select it? only im aiming to have an array of lots of boxes so if they could automatically be selected that would be easier.

cheers
mattoso

hblan
01-08-2007, 12:59 AM
for the first obj , is for u to fix the transform original . for later generate other boxes.
and i think it is more easy for use .script is a tool for doing works quickly , dont make anything with script . something easy with hand draw , something easy with code .

if u want make more style boxes and modify them with one set of spinner , the spinner should not be the fixed paramater of length,width,height , it should be scale value of them .

mattoso
01-08-2007, 01:50 AM
hi, i think i understand however im not sure id know enough to be able to get that working. It would speed things up.

Below is where i got to, although it is slow as the objects are all created in the script, this isn't good

Also i wanted to include a setting as part of it to create random louvres, i explained this on other post.
http://forums.cgsociety.org/showthread.php?t=448562

--louvre generator

rollout ssRoll "louvre generator"

(

local ori_width = 30

local ori_height = 3.2

local ori_space = 3.3

local ori_floorcount = 3

local ori_numslats = 60

local ori_slatthick = 0.2

local ori_slatlength = 0.2

local ori_slatwidth = 0.1

----interface define ----

group "Basic:"

(

button but_createFacade "Create Facade "

spinner spn_facadeWidth "Facade Width " type:#float range: [1,100,ori_width]

spinner spn_floorHeight "Floor Height " type:#float range: [1,100,ori_height]

spinner thefloorspace "floor space:" range:[0.0,100,ori_space]

spinner thefloorcount "floor count:" range:[1,10,ori_floorcount] type:#integer

)

group "Slats:"

(

checkbox profile "Rectangular Profile "

spinner spn_numSlats "Number of Slats" type:#integer range:[1,100,ori_numslats]

spinner spn_slatthickness "Round Slat Thickness " type:#float range:[0.05,0.6,ori_slatthick]

spinner spn_rectangularl "Rect. Slat Length " type:#float range:[0.05,0.6,ori_slatlength]

spinner spn_rectangularw "Rect. Slat Width " type:#float range:[0.05,0.6,ori_slatwidth]

)

button but_updateFacade "Update Facade "





on but_createFacade pressed do

(

(

new_spline = line()

new_spline.name = "matt"

--uniquename

(

addnewspline new_spline

addKnot new_spline 1 #smooth #curve [0,0,0]

)

addKnot new_spline 1 #smooth #curve [0,0,spn_floorHeight.value]



new_spline.render_renderable = true

new_spline.render_displayRenderMesh = true

new_spline.render_thickness = spn_slatthickness.value

new_spline.render_rectangular = profile.state

new_spline.render_viewport_rectangular = profile.state

new_spline.render_length = spn_rectangularl.value

new_spline.render_width = spn_rectangularw.value

updateshape new_spline

)



ds = spn_facadeWidth.value / spn_numSlats.value

for i = 1 to spn_numSlats.value do

(

a = copy new_spline

select a

maxops.cloneNodes $ offset:[(ds*i),0,0] newNodes:&test

)

(

myarray = for obj in objects where (classof obj == line) collect obj

for i = 1 to thefloorcount.value do

(

select myarray

maxops.cloneNodes $ offset:[0,0,thefloorspace.value*i] newNodes:&test

deselect myarray

)

)

)

on but_updateFacade pressed do

(

try(delete $matt*)catch()

but_createFacade.pressed()



)



)

createDialog ssRoll 250 300



any ideas on whats the best way to do this?
thanks

CGTalk Moderation
01-08-2007, 01:50 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.