[Closed] single function- different rollouts
Hi All,
i am asking whether it is applicable or not to collect variables for a function from different rollouts?
thank you
maha
I’m guessing the answer is ‘yes’, but you’ll have to elaborate on what you’re trying to do
the function FORMGENERATION is collecting A B C D AND E from the groups in the rollout cube.
i want to make these groups as rollouts site restrictions, building restriction and generate alternatives, each as a rollout with the same function. can i ?
rollout r1 "Candilis Cellular Automata"
(
activeXcontrol AXC1 "MSComctlLib.TabStrip.2" height:20
subRollout EmptySubRollout height:305 ---------------- empty rollout to include folded rollouts
-- Naming tabs--------------------------------------------
on r1 open do
(
AXC1.tabs[1].caption = "GAME OF LIFE "
AXC1.tabs.add pvCaption: "Clustering"
AXC1.tabs.add pvCaption: "Voronoi"
AXC1.tabs.add pvCaption: "Boolean Algebra"
)
-- rollout navigation control------------------------------
on AXC1 Click do
(
case AXC1.SelectedItem.index of
(
1:(
removeSubRollout EmptySubRollout S05
addSubRollout EmptySubRollout S01
addSubRollout EmptySubRollout S02
addSubRollout EmptySubRollout S03
)
------------------------------------------------
2:(
removeSubRollout EmptySubRollout S01
removeSubRollout EmptySubRollout S02
removeSubRollout EmptySubRollout S03
addSubRollout EmptySubRollout S05
)
------------------------------------------------
)
)
)
--------------------------------------------------------------------------------------------------------------------------------------
rollout S01 "Module Selection" width:312 height:350
(
radioButtons Module "RadioButtons" pos:[39,9] width:232 height:30 labels:#("Cube", "Hexagon", "GeoSphere") columns:3
)
-----------------------------------------------------------------------------------------------
rollout S02 "CUBE" width:311 height:347
(
GroupBox grp10 "Site restrictions" pos:[5,6] width:303 height:47
spinner spn7 "X- Dimension" pos:[52,25] width:100 height:16
spinner spn9 "Y- Dimension" pos:[199,25] width:100 height:16 range:[0,100,0]
GroupBox grp33 "Building restrictions " pos:[5,62] width:303 height:47
spinner spn10 "No of Stories " pos:[51,83] width:100 height:16 range:[0,100,0]
spinner spn33 "Court Diameter" pos:[191,83] width:110 height:16 range:[0,100,0]
GroupBox grp45 "Generate Alternatives " pos:[5,115] width:303 height:55
spinner spn5 "No of Prototypes" pos:[52,138] width:100 height:16 range:[0,100,0]
button btn1 "Generate" pos:[170,134] width:127 height:24
-- variables: Xmax Ymax NoGen CourtDia Alternatives
------------------------------------------ functmion starts here ---------------------------------------------------------
fn FormGeneration A B C D E =
(
for h= 1 to E
do(
-- creating first generation grid
for x= 0 to A do for y= 0 to B do (
MyPlane= Box length:1 width:1 Height:1 lengthsegs:1 widthsegs:1
MyPlane.name= ("Cell_" + x as string + "_X_" + y as string + "_X_0.0"+ h as string )
MyPlane.pos = [x,y,0]
MyPlane.wirecolor= [190,200,170]
)
hide( for o in geometry where distance o.center [(A/2),(B/2),0] > (D+3) and distance o.center [(A/2),(B/2),(C/2)]< B collect o)
hide( for o in geometry where distance o.center [(A/2),(B/2),0] < D collect o)
-- for o in geometry where try(o.ishidden== false) catch (false) do
for o in geometry where try(o.ishidden== false) and (classof o == box) catch (false) do(
state= random 0 1
if (state == 0) then hide o
)
for gen=0.0 to C by 1.0 do
(
-- first pass: neighbors information
StateArray = #() -- array to save each cell neighboring status
lifeORdead= #() -- array to save each cell status
Idx=1 -- initialize a conter for StateArray Index
for x=1 to (A-1) do for y=1 to (B-1) do
(
-- defining each cell to collect it's neighbor visibility
NameOfCell= ("Cell_" + x as string + "_X_" + y as string + "_X_" + gen as string + h as string)
visible= 0 -- number of visible cell's neighbors
for i= -1 to 1 do for j= -1 to 1 do
(
if (i==0 and j==0) then (
LifeorDeadCell= execute (" $'"+ NameOfCell + "'.ishidden" )
if (LifeorDeadCell == false) then ( lifeORdead[Idx]= 1)
else (lifeORdead[Idx]= 0)
)
else(
-- defining cell NeighborName
NeighborName= ("Cell_" + (x+i) as string + "_X_" + (y+j) as string + "_X_"+ gen as string + h as string)
checkclass = execute ("classof $'" + NeighborName + "'== Box")
if try (checkclass) catch (false) do
(
Visibility= execute ("$'"+ NeighborName + "'.ishidden" ) -- check cell neighbor visibility
if (visibility == false) then (visible= visible+1) -- update number of visible neighbors
else (visible=visible)
)
)
)
StateArray[Idx]= visible -- placement of visible cells no in the cell index of the StateArray
Idx=Idx+1 -- move to the next cell
)
-- second pass: applying rules
Idx=1 -- initialize variable to loop betwenn cells
for x=1 to (A-1) do for y=1 to (B-1) do
(
TotoPlane= box length:1 width:1 Height:1 lengthsegs:1 widthsegs:1
TotoPlane.name= ("Cell_" + x as string + "_X_" + y as string + "_X_"+ (gen+1) as string + h as string)
TotoPlane.pos = [x,y,((gen+1)+(0.2*(gen+1)))]
TotoPlane.wirecolor= [190,200,170]
--Conway's Game of Life:
--1. Any live cell with fewer than two live neighbors dies, as if by loneliness.
--2. Any live cell with more than three live neighbors dies, as if by overcrowding.
--3. Any live cell with two or three live neighbors lives, unchanged, to the next generation.
--4. Any dead cell with exactly three live neighbors comes to life.
-- if live cell
Visibility01= " $'"+ TotoPlane.name + "'.ishidden"+ " = true"
Visibility02= " $'"+ TotoPlane.name + "'.ishidden"+ " = false"
if (lifeORdead[Idx]==1) then (
case of
(
(StateArray[Idx]<2): execute Visibility01
(StateArray[Idx]>3): execute Visibility01
(StateArray[Idx]==2): execute Visibility02
(StateArray[Idx]==3): execute Visibility02
)
)
else (
case of
(
(StateArray[Idx]==3): execute Visibility02
(StateArray[Idx]!=3): execute Visibility01
)
)
Idx=Idx+1 -- move to the next cell
)
redrawViews()
)
delete (for o in objects where (o.ishidden == true) collect o)
UnionArray =(for o in objects where distance o.center [(A/2),(B/2),(C/2)] < (A+10) collect o)
uni = UnionArray[1]
for s in UnionArray do (uni + s)
--scale UnionArray[1] [3.6,3.6,3.6]
move UnionArray[1] [50,(20*h),0]
delete (for o in objects where distance o.center [(A/2),(B/2),(C/2)] < (A+10) collect o)
for o in objects do (o.name= uniquename "prototype")
--move (for o in objects where distance o.center [(A/2),(B/2),(C/2)] < A collect o) [50,(10*h),0]
freeze(for o in objects where distance o.center [(A/2),(B/2),(C/2)] > (A+10) collect o)
)
)
------------------------------------- function ends here ---------------------------
on btn1 pressed do
(
print spn7.value -- A
print spn9.value -- B
print spn10.value -- C
print spn33.value -- D
print spn5.value -- E
GO = FormGeneration (spn7.value) (spn9.value) (spn10.value-2) (spn33.value) (spn5.value)
)
)
------------------------------------------------------------------------------------------------
rollout S05 "Clustering" width:289 height:301
(
dropdownList ddl3 "Interpolation Direction" pos:[9,15] width:205 height:40 items:#("Vertical", "Horizontal")
GroupBox grp11 "Vertical " pos:[4,66] width:303 height:94
radiobuttons rdo7 "Organisation" pos:[34,79] width:166 height:30 labels:#("Staggered", "Random") columns:2
spinner spn18 "No. of Stories" pos:[75,121] width:123 height:16 enabled:true range:[0,4,0] type:#integer
GroupBox grp12 "Horizontal" pos:[4,167] width:303 height:102
radiobuttons rdo6 "Organisation" pos:[34,187] width:128 height:46 labels:#("Ribbon", "Puzzle", "Patio", "Grouped") default:1 columns:4
spinner spn19 "No. of Stories" pos:[75,230] width:123 height:16 enabled:true range:[0,4,0] type:#integer
)
-----------------------------------------------------P2 ends here------------------------------------------------------------------------
rollout S03 "Hexagon" width:311 height:347
(
)
-------------------------------------------------------------------------------------------------------
rollout S04 "GeoSphere" width:311 height:347
(
)
createdialog r1 350 350
addSubrollout r1.EmptySubRollout S01 -- to add the first rollout automatically when open the interface
addSubrollout r1.EmptySubRollout S02
addSubrollout r1.EmptySubRollout S03
addSubrollout r1.EmptySubRollout S04
--addSubrollout r1.EmptySubRollout p5
okay, so you want to split up the rollout “CUBE”, which currently has the three groups “Site restrictions”, “Building restrictions” and “Generate Alternatives” into 3 separate rollouts – one rollout for each of those groups – correct?
Next… what you’re asking, I think, is this…
You currently have a function, FORMGENERATION, that is a part of the “CUBE” rollout where it can access the parameters in each of those groups, and you are wondering how to change the code so that once you have the 3 separate rollouts, the FORMGENERATION funtion can still be called, and the FORMGENERATION function can access the parameters in each of the rollouts?
If so, you might do something like the following:
fn FormGeneration A B C D E = ( ... )
rollout roll_siteRestrictions "Site Restrictions" (
spinner spn7 "X- Dimension" pos:[52,25] width:100 height:16
spinner spn9 "Y- Dimension" pos:[199,25] width:100 height:16 range:[0,100,0]
)
rollout roll_buildingRestrictions "Building Restrictions" (
spinner spn10 "No of Stories " pos:[51,83] width:100 height:16 range:[0,100,0]
spinner spn33 "Court Diameter" pos:[191,83] width:110 height:16 range:[0,100,0]
)
rollout roll_generateAlternatives "Generate Alternatives" (
spinner spn5 "No of Prototypes" pos:[52,138] width:100 height:16 range:[0,100,0]
button btn1 "Generate" pos:[170,134] width:127 height:24
on btn1 pressed do (
valA = roll_siteRestrictions.spn7.value
valB = roll_siteRestrictions.spn9.value
valC = roll_buildingRestrictions.spn10.value
valD = roll_buildingRestrictions.spn33.value
valE = spn5.value
GO = FormGeneration valA valB valC valD valE
)
)