A Thousand Steps

Page 1



Hello

World


Diploma Year 5 Computing Theory Portfolio All the information contained within details the development of the Computing & Design Theory module within the PG Dip Architecture (RIBA II) course at UEL. One Thousand Steps is designed as a pre-cursor to the One Thousand Plateaus Project. Further Info on the course can be found @ http://wiki.uelceca.net/msc1011/show/Adam+Mc+Aviney


Contents 1/ Hello World 2/ Balls In Space Workshop _2D NetLOGO

_3D NetLOGO _The Balls In Space

3/ VBA

_Week 1 - Point.Line

_Week 2 - Connected Lines

_Week 3 -

_Week 4 - Brownian Walker & Painter

_Week 5

_Week 6/7 - 2D Diffusion

_Week 8/9 - Grid & Rib Structures

_Week 10 - SelectionSets & Vectors

Spirals_Polylines_Faces

- 1d Array - The Self Organising String


1 / Hello World Progamming is a way that can allow architects to communicate with the machine and to get ‘under the hood’ of many of the tools which are common in architectural practice today.

Programming can offer architects the opportunity to understand the processes which occur when they click a button in a program and to explicitate the tacit knowledge which they have.Throughout history man has thought of himself as a God, being able to manipulate his conditions and the conditions that surround him in order to achieve comfort or performance - an architect is the sterotypical profession of this image, but as programmers or archi-programmers we must remember that we must think as ants, not Gods (this will become a familiar phrase).

Language:

Programming is a generic term for the process of communicating with the machine in a similar way as speaking can be a generic term for communicating with individuals , although neither specifiy what language is being used - Spanish,English, French etc. Programming is based on the syntax of natural language that has developed over thousands of years, similar to the spoken word the ideal of programming can be broken down into statements,agruments, conditions and functions (with further categorisation possible), but there are many languages that can be used ;- JAVA, PHYTON, C++, VB, VBA, VB.NET etc. The type of programming language that is used is based on which programs speak which languages, e.g. Autocad can ‘speak’ VB.NET & VBA (although its fluency in VBA is decreasing rapidly). Throughout the course we will start using NetLogo and advance to using VBA in Autocad in order to create some simple architectural proposals and to understand the logic involved

Sketching:

As architects or designers we often rely on the ability to explicitate tacit knowledge to ourselves and clients in the form of a ‘sketch’ or doodle. This helps the client or observers to understand the desired outcome of a design / building process. Although it may seem counter-intuitive, when programming, a sketchpad should always be beside the keyboard so that the user can clearly sketch out ideas of the process and what the desired outcome will be. This not only helps to focus the mind that can often get lost in a mountain of language, but it also helps to humanise the process.


Step 2

Variables

Create Globals

Step 3

HowMany C HowMany M Radius

Diagrams:

r D1

T1 N1programming process Flow diagrams like sketching are a key part of the - they If D1help > r Move N1 for D2 If D2 the designer to understand each part of the programming system and how infor-< r Move N2 ba N2 mation is to be passed or extracted from one end of the code to another and why it Attract produces the desired result. Often the flow diagrams will take place at the beginning and end of writing code for a specific operation - often as you get your teeth into the Procedures N1 coding of a function you will often find that your initial flow diagram / idea will not N2 D1 D2 this is the case - Ifand work as planned - or at least when you start programming D1 <then D2 node N is closer in di your flow diagram at the end whichRepel will show the operations in the code and helps D2 N N3 node N moves backw the user and observers to fully understand the functions and processes involved Prepareboth Breeds in the code (example below). N1 D1 Variables

Brace

Create Globals

D1

T1 D2 N2

Attract

Repel

N2 D2

Wiggle

T2

node N moves in dire T2

N

Escape If D1 < D2 N3

T1

D1

node N is closer in distance to N1 node N moves backwards

N1 D1

Brace

N2

D2 D2

N

N1

T2

D2

N

N3

T1 If D1 > r Move N1 forward If D2 < r Move N2 backward

N1 D1

D2

N

HowMany Cats HowMany Mice Radius

r N1

N2

D2

HowMany XY Position Colour Size If D1Shape < D2 nodeHeading N links with

N3

If D1 < D2 node N links with N1

T1 T2 node N moves in direction T1 or

D2 N

If D2<D1 then N mov backwards from T2


2 / ‘Balls In Space’ - Netlogo Workshop

What is Netlogo? NetLogo is a multi-agent programmable modeling environment for simulating natural and social phenomena. It was authored by Uri Wilensky in 1999 and is in continuous development – currently on model 4.1.1 . NetLogo is particularly well suited for modeling complex systems developing over time. Modelers can give instructions to hundreds or thousands of “agents” (known as turtles) all operating independently. This makes it possible to explore the connection between the micro-level behavior of individuals and the macro-level patterns that emerge from the interaction of many individuals.

Workshop Aim The main aim of the workshop, is to introduce students to programming and the concepts / structure involved, as most programming languages use a similar basic structure (global declarations, local variables, conditional statements etc). Programming is about being able to communicate with the computer through a structure and language that the computer can interpret and execute. The idea is to be able to create geometrys and architectural ‘things’ without actually using geometry the geometry will emerge as a global outcome. The ‘balls’ refer to the agents which were produced (also known as turtles) and the final physical outcome (INSERT PAGE NUMBERS) illustrates an emergent relationship that was formed following the writing of a specific piece of code within the software.

.................... Architects should think as


Like everything else, we must start basic before achieving the complex (not complicated). The first week of the workshop will be to establish the methods and principles of programming in 2d before starting to create more complex systems and outcomes in 3d in week 2. The figures below show the three screens contained within the 2D IDE [Fig 1] Interface – where the model/applet settings are located – buttons, sliders etc [Fig 2] Information – Help information can be found here [Fig 3] Procedure – Where the coding / scripting is done

Fig 1

ants not Gods.........

Fig 2

Fig 3


The Basics CODE STRUCTURE MAIN [to setup]

The first procedure is called set up and receives no information or arguements but consists of declarations

End ________________________________________________________________________ SUB REPORTER [to go] For economy and clarity we use subroutines that can handle repetitive or generic procedures. These routines can all other agrumenents and instructions from functions that can include commands to run, attract, repel etc

End ________________________________________________________________________ to-report auxiliary Are like subroutines, but they return explicit values. They return some value, but can be from outside the procedure. They produce the final outcome.

End

_______________________________________________________________________________

*** There will always be alot of repetition within code so the ability to recognise this and knowing when to copy & paste previous pieces of code can become invaluable for time management.


Useful Commands The following are commonly used commands within NetLogo & will aid in the understanding of both functions and code. ca – Clear All crt – Create Turtles (Agents) set color (colour spelt American) – Sets the agents colour set size – Sets the agents size set shape ” ” – Sets the shape of the agent eg set shape “turtle’ fd – the command for moving agent forward after a conditional statement pd – the pen down command – enables the agent to draw their path to create an image ; – putting a semi-colon after coding allows the user to add comments - comments will be coloured green.


Programming Concepts Agents | Procedure | Variables | Ask | Agentsets | Breeds Agents;

Agents can carry out their own activity or all simultaneously. - patches - turtles -observer Patches can be considered a type of agent-set, but do not move, form a 2-D wraparound grid and have integer co-ordinates. Turtles (agents) move on top of the patches - not necessarily in their centre and can have decimal co-ordinates and orientations (heading). Observers can create new turtles and can read & write access to all the agents and variables.(agents/turtles can be different sizes,shapes & colours - including turtles!)

Procedures; -Commands -Reporters -Primitives -Procedures -Variables

Commands are actions that agents carry out (functions) e.g. to setup ca crt 25 end ----------------------------------------------------------------------------------------to move let movement random 360 end


Reporters;

report a result value and can be considered as functions with a return type. e.g. to-reportabsolute-value [ number ] ifelse number >= 0 [ reportnumber ] [ report0 -number ] end

Primitives;

are built-in commands or reporters, some have abbreviated forms e.g. create-turtles = crt clear-all = ca etc

Procedures;

can be custom commands or reporters created by the user.

Variables;

places to store values - numbers or text. Variables can be global, local or conditional turtle & patch variables (set variables) Global variables are declared at the beginning of the code and declare one value for each variable and every agent has the ability to acess it. Turtle & patch variables, each turtle/patch has its own value for every turtle/patch variable e.g. ask turtles [ set color red ] Local variables are defined and accessible only inside a procedure scope. Ask Ask commands specifiy functions to be run by turtles or patches e.g. asking all turtles:

ask turtles[ fd 50 ... ]

asking all patches:

ask patches[ diffuse ... ]

asking one turtle:

ask turtle 5[ ... ]


Agentsets definition of a subset of agents all red turtles: turtles with[ color = red ] all red turtles on the patch of the current caller (turtle or patch): turtles-here with[ color = red ] all patches on right side of screen: patches with[ pxcor > 0 ]

Breeds

Breeds are a “natural� kind of agentset (other species than turtles) which can be defined by the user breed[ cats mice ] a new breed comes with automatically derived primitives: create-<breed>create-custom-<breed><breed>-here<breed>-at... the breed is a turtle variable: ask turtle 5 [ if breed = cats ... ]



2D NetLogo Day 1 We experimented with creation of at first a singular agent (turtle(s)) and then multiple agents instructing them to move forward or backwards randomly, while leaving a trail of their movement using the ‘pd’ or ‘pen down’ command. By setting our heading (means direction in Netlogo) to 0 it would give the agent the instruction to move up, 90 would be right, 180 would be down etc. Each agent would be created at co-ordinate 0,0 to ensure centralised results would occur (world co-ordinates can be discovered & altered via the IDE). Initially all movement was random and angular, but the addition of a ‘random 360’ function allowed for more organic movement within the environment rather than rigid lines and corners. Developing on the concept of randomness, we added a conditional statement to the code , which would determine if the agent would go right or left depending on the result of a ‘virtual coinflip’. Simple settings were explored and altered during the day to add variation to the iterations – such as agent size,agent colour, agent shape etc

Shown above it one of the iterations produced during the Day 1 Workshop class - the code used is shown right - more examples and scripts can be found online. Agent A heading is set to random 360 so they can move in any possible direction , when they move because the pd command is used they will leave a trail producing something similar to the image above.

y

x


to start

; can be any logical name to start, must always start with ‘to’

ca

; clear all – linked to clear button

crt howmany

; number linked to a slider called how many

ask turtles [

; turtles is referenced via crt remember square brackets

setxy random-xcor random-ycor set shape “circle” set size 0.5

; shape of agent

set heading random 360

; position of turtles / agents- randomly x & y

; size

set color random 139

; direction agents point towards ; colour of turtles

] end to move

; logical name for action - linked to move button

let movement random 360

;

ask turtles [

pd fd .2

; politely asking the agents to do something ; can put a pen down (pd) to make a trail ; forward step

ifelse (movement < 180) ; if its less than 180 then adds a direction to the previous direction added, right[set heading heading - 1] ] end

;if more than 180 then it goes left


Day 2

Step 3

Step 2

Step 1

We built upon the basics which were learnt in the previous day and agents became groups and aware of each other (also gained some self awareness…but not in an AI type of way). Initially we created a code to repel agents from, each other using conditional statements the each agent would be linked to the nearest agent – which provided some interesting results – partially because of the naivety and simplicity of the coding meant Procedures that previous links would not be broken, so links built up. The repel and link commands were built upon and an attract function was added. This resulted in a ‘wiggle’ from the agents, with them constantly moving back and forward the set distances from each other – when the brace command was activated this resulted in a tessellated net. Prepare Breeds to brace ask mice[set closest-mouse min-one-of other mice [distance myself] Variables ; a link/line is created between nearest neighbours HowMany Cats Create Globals HowMany Mice create-link-with closest-mouse Radius ] r

end

D1

N1

T1 D2 N2

If D1 > r Move N1 forward If D2 < r Move N2 backward

Attract N1 D1

Repel

N2

D2 D2

N

N3

If D1 < D2 node N is closer in distance to N1 node N moves backwards

N1 D1

Brace

N

N2

D2 D2

N3

If D1 < D2 node N links with N1



breed [mice mouse] ; defining agents and subsets mice-own [closest-mouse lucky-mouse] ; defined for later use to start

; can be any logical name to start, must always start with ‘to’

ca ; clear all - linked to clear button create-mice howmany ; number linked to a slider called how many ask mice [ ; mice is referenced in the global environment remember square brackets setxy random-xcor random-ycor ; position of turtle / agents set shape “circle” ; shape of set size 0.5 ; size set heading random 360 ; direction pointing towards set color random 139 ; colour of turtles ] end to move

; logical name for action - linked to move button

let movement random 360 ; movement is a variable to attach a random number to 0-360 ask mice [ ; politely asking the agents to do something pd ; can put a pen down (pd) to make a trail fd .2 ; forward step ifelse (movement < 180) ; if ‘movement’ is less than 180 thenadds a direction to the previous direction added, right[set heading heading - 1] ;if more than 180 then it goes left] end to repel

; new function class

ask mice [ ; ask the agents politely ; closes-mouse is determined globally - each agent(mouse) will already have been given a numberset closest-mouse min-one-of other mice [distance myself ] ;set the minimum distance away from agents self inorder to count as an other agent


closest-mouse != nobody [

;to stop it counting itself as its nearest neighbourif ; != means not equal

set heading towards closest-mouse ; change direction to the closest agent ;print min-one-of other mice [distance myself] ; print closest matches ;pd bk .2

;go back .2 from closest agent

] ] end to brace ask mice[set closest-mouse min-one-of other mice [distance myself] ; a link/line is created between nearest neighbours create-link-with closest-mouse ] end


Day 3

Step 1

Further development of the concept of repelling turtles from each other, as well as the new breed of turtles allowed the user to create emergent behaviour similiar to that of a Voronoi Diagram. Procedures ‘a Voronoi diagram is a special kind of decomposition of a metric space determined by distances to a specified discrete set of objects in the space, e.g., by a discrete set of points.’ Prepare Breeds

Step 1

Step 2

Here we can see theProcedures gradual arrangement of agents replicating Voronoi type behaviour. The turtles themselves obviousy don’t know this, but the coding determines their behaviour.

Create Globals

Step 2

Step 3

Prepare Breeds

rocedures

r D1

N1

Create Globals

D2

N2Cats HowMany HowMany Mice Radius

Attract

Step 3

repare Breeds

T1

Variables

r

N1

If If

HowMany

Shown above are examples of the Voronoi diagram - the leaf of N2 a tree D1 within XY Position T1 nature D1 N1 If D1 D2 >the r Move N1 forward Colour and the pattern on a giraffe. The new breed of turtles become targets, normal If D2 Size If D2 <obey r Move N2 backward turtles and new breeds obey the repel rule byt only the normal turtles the repel no VariablesRepel Shape D2 N N3 N2 - who try to stay away at a set radius. no Heading HowMany Cats Attract reate Globals HowMany Mice Radius

r D1

N1

T1

Repel D2 N2

N1 D1

N1

N2

D2 If D1 > r Move N1 forward N < r Move N2D2 N3 If D2 backward

Brace

N

N2 D1 If D1 D2 < D2 node N is closer in distance toIfN D2 backwards N3 no node N moves

ttract

epel

The new outcome is only due to the introduction of a new bread the principles used attract & repel & brace / link are still the same N1 although they are now used at once N1 rather than individually. T1 N2 D1 D1

N

N2

D2 D2

Brace N3

D2 If D1 < D2T2 If D1 < D2 N N is closer inD2 node N links with N1 node distanceN3 to N1 node N moves backwards Wiggle N

no T2


breed [mice mouse] ; these are variables of the specified breed. breed [cats cat] mice-own [closest-mouse danger-cat] cats-own [chased-mouse] to setup ca create-mice 300 create-cats 20 ask mice [ setxy random-xcor random-ycor set color blue set heading random 360 set shape “circle” set size .3]ask patches [ set pcolor white]ask cats [ setxy random-xcor random-ycor set color red set shape “circle” set size .5 ] end


Day 4 The mouse cursor is now introduced as an anchor point, the turtles are repelled against the nearest turtle and then the links are added creating a new geometry. to attract ask turtles [ set heading towardsxy mouse-xcor mouse-ycor ifelse (distancexy mouse-xcor mouse-ycor < radius ) [bk 1] [fd 1]

This now means that all iterations will be slightly different dependant on the positioning of the mouse and its movement within the window.



turtles-own [closest-turtle]

to setup

; setting up procedure

crt how_many_turtles ; creating a variable linked to a slider ask turtles[

; specifying the qualities of the turtles

setxy random-xcor random-ycor set color red set heading random 360 set shape “circle� set size .3 ] end to bg ask patches [ set pcolor white ] end to attract ask turtles [ set heading towardsxy mouse-xcor mouse-ycor ifelse (distancexy mouse-xcor mouse-ycor < radius ) [bk 1] [fd 1]


] end to repel ask turtles [ set closest-turtle min-one-of other turtles [distance myself] if closest-turtle != nobody [ set heading towards closest-turtle bk .2 ] ] end to join ask turtles [ set closest-turtle min-one-of other turtles [distance myself] if distance closest-turtle < 10 [create-link-with closest-turtle] ] if mouse-down? [clear-links] end to draw ask turtles [ pd ] end to undraw ask turtles [ pu ] end


Day 5 A tesselation from the previous day was selected and then a physical model illustrating the relationships established was produced. The task of creating a physical model of the tesselation both heightened the understanding of the system and its complexity which can be lost when a button is pressed on the screen. As with most digital tools - the removal of tactility and touch can abstract models and desgins too far from the user - when a line becomes a line rather than a representation of something that is built or to be built. Materiality Creating the model also raised issues such as materiality and construction - how do you create a complex system such as the tesselation on such a small scale? & how can it accurately represent the system without looking like less than its total parts? A relatively simple tesselation was chosen (FIG) in order to give the best possible chance of success and then constructed using a plywood base,pins and thread (FIG).

The connections shown and the systematic relationships that they represent act as a base and pre-curosr for the final ‘balls in space’ exercise which would be created following the completion of the 3D Netlogo tesselations. Each student in the workshop produced one 200(mm) x 200 panel of their own final 2D tesselation. The procedural flow diagram for this tesselation is shown on page PAGE NUMBER HERE!!!


28 Agents (Turtles) Attracted to mouse-movement Repelled from each other if too close Connections made to nearest agent

turtles-own [closest-turtle] to setup

; setting up procedure

crt how_many_turtles ; creating a variable linked to a slider ask turtles [ ties of the turtles

; specifying the quali-

setxy random-xcor random-ycor set color red set heading random 360 set shape "circle" set size .3

]

end to goforever

to repel ask turtles [ set closest-turtle min-one-of other turtles [distance myself] if closest-turtle != nobody [ set heading towards closest-turtle bk .2

attract repel

]

if mouse-down? [stop] end to attract ask turtles [ set heading towardsxy mouse-xcor mouseycor ifelse (distancexy mouse-xcor mouse-ycor < radius ) [bk 1] [fd 1]

] if mouse-down? [stop] end

] if mouse-down? [stop] end to join ask turtles [ set closest-turtle min-one-of other turtles [distance myself] if distance closest-turtle < 10 [create-link-with closestturtle] ] if mouse-down? [clear-links] end


Step 1

Procedures

Step 2

Prepare Breeds

Variables

Create Globals

Step 3

HowMany Cats HowMany Mice Radius

r D1

N1

T1 D2 N2

If D1 > r Move N1 forward If D2 < r Move N2 backward

Attract N1 D1

Repel

N2

D2 D2

N

N3

If D1 < D2 node N is closer in distance to N1 node N moves backwards

N1 D1

Brace

N2

D2 D2

N

N3

If D1 < D2 node N links with N1

T1 T2

Wiggle

node N moves in direction T1 or T2

N T2

Escape

T1

D1

D2 N

If D2<D1 then N moves heading backwards from T2


BREED MICE

BREED CATS

MICE-OWN Closest-Mouse Closest-Cat

CATS-OWN Closest-Cat Closest-Mouse

HowMany XY Position Colour Size Shape Heading

SetUp Agents

Calculate shortest node distance based on itself and other nodes Target moves towards closest node

Calculate shortest node distance based on itself and other nodes Node moves away from closest node

Calculate shortest node distance based on itself and other nodes Links created between two closest nodes

Calculate shortest node distance based on itself random heading > 10 Yes

Nodes move towards direction T1

Calculate shortest node distance based on itself and other targets Node moves away from closest target

No

Nodes move towards direction T2


3D NetLogo

Once the basic principles of Netlogo coding / programming were established in 2D in the first week, we moved onto the 3D version. Currently Netlogo 2D & 3D are split into two applications. The developers maintain that the split is temporary. Eventually a single unified application will support both 2D and 3D modeling. Netlogo 2D & 3D use the same basic language syntax and structure with only a few obvious differences. * 3D – involves a Z-axis – setxyz * 3D – involves a pitch – pitch is the 3-dimensional version of heading In order to write a similar procedure as we did in 2D involving agents repelling and attracting each other – we must be aware that the environment is 3D and now contains a Z axis, so we must now be aware of the restrictions in 3-dimensions or else we will encounter mutlipe areas of the agents splitting or wrapping around the world.


y

x

z

y

x

The diagram above illustartes the difference between 2D NetLOGO & 3D NetLOGO the addition of a Z axis* allows the user for infinitely more possibilities in directional terms alone. The code itself is very similar although like 2D NetLOGO the ‘world’ which it operates within is ‘donut’ shaped and wraps around itself - this can lead to some interesting tesselations while also creating problems when agents interact of the edge of the world and end up wrapping around to the other side of the world. Y x

1d Array

2d Array

x

setxyz (random-float world-width + min-pxcor ) / 2 (random-float world-height + min-pycor ) / 2 (random-float world-depth + min-pzcor ) / 2 ]

In order to stop problems like the one illustrated within the image above - we create a world within a world by restricting the area to which the agents can work within, this means that we will not encounter any problems with agents being split between the two sides of the world.


;\\\\\\\\\ Global Variables \\\\\\\\\\\\\\\\\\\\\\\\ breed [cats ] breed [ mice] cats-own [ closest-cat ] mice-own [closest-mouse ] ;\\\\\\\\\\\\\\ Setup \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ to setup ca create-mice howmanycats create-cats howmanymice ask cats [ set size catsize set color green set shape “circle” setxyz (random-float world-width + min-pxcor ) / 2 (random-float world-height + min-pycor ) / 2 (random-float world-depth + min-pzcor ) / 2 ] ask mice [ set size mousesize set color white set shape “circle” setxyz (random-float world-width + min-pxcor ) / 2 (random-float world-height + min-pycor ) / 2 (random-float world-depth + min-pzcor ) / 2

] end


/////////////////Functions//////////////////////////////////////// to attract ask cats [ set closest-cat min-one-of other mice [distance-nowrap myself ] if closest-cat != nobody [set heading towards-nowrap closest-cat set pitch towards-pitch-nowrap closest-cat] ifelse distance-nowrap closest-cat > radius [fd .4] [bk .4] ] if mouse-down? [stop] end to repel ask mice [ set closest-mouse min-one-of other cats [distance-nowrap myself] if closest-mouse != nobody [ set heading towards-nowrap closest-mouse set pitch towards-pitch-nowrap closest-mouse] ifelse distance-nowrap closest-mouse > radius [fd .4] [bk .4] ] if mouse-down? [stop] end to links_create ask cats [ set closest-cat min-one-of other cats [distance myself] if distance closest-cat < 10 [create-link-with closest-cat] ] if mouse-down? [clear-links] end


The above images and the code on the previous pages are the 3D versions of the code which was completed the previous week involving two breeds of agents, attract,repel and link functions. This code will helps to produce the system and co-ordinates for the final ‘balls in space’ installation. Due to the fact that the cats and mice start at random locations - each iteration of the code will produce a slightly different result than the previous attempt.

The addition of several sliders aids the user in customizing the possible outcomes from the size of agents to the number and the radius between agents - thus effecting


the final size of the spheres. In order to produce the ‘balls in space’ installation, coordinate points were needed. These could be extracted from the model via Autocad. The model was exported to Autocad as a 3D model and the co-ordinates were plotted on a plane (shown above) in their 2D positions which would be later needed. All the spheres were a different length from the plane (400 different lengths) so each length was exported and numbered to a txt file which would be used during the manual manufacturing process of the installation. The flow diagram for the procedure is shown on the following pages illustrating how each procedure received and distributed its information in order to achieve the final outcome.


Step 1

Procedures

Step 2

Prepare Breeds

Step 3

Create Globals

r D1

N1

T1 D2 N2

Attract

If D1 > r Move N1 forward If D2 < r Move N2 backward

N1 D1

Repel

N2

D2 D2

N

N3

If D1 < D2 node N is closer in distance to N1 node N moves backwards

N3

If D1 < D2 node N links with N1

N1 D1

Brace

N

N2

D2 D2


BREED MICE

BREED CATS

MICE-OWN Closest-Mouse Closest-Cat

CATS-OWN Closest-Cat Closest-Mouse

HowMany XY Position Colour Size Shape Heading

SetUp Agents

Calculate shortest node distance based on itself Node distance > target radius? Yes

Nodes move towards target T1

No

Nodes move away from target T2

Variables HowMany Cats HowMany Mice Radius

Calculate shortest node distance based on itself and other nodes Node moves away from closest node

Calculate shortest node distance based on itself and other nodes Links created between two closest nodes



‘The Balls In Space’





In total 400 individual balls were used (with a few spare..) & 400 unique lengths of string were cut . The final installation was successful, but the complexity of creating a physical model of the emergent system was under-estimated. The result could have been improved if more agents where used to increase the density of the emergent shapes or possibly if a thin wire was used instead of string.

* All Photo Credits to Emmanouil Zaroukas


3 / VBA

VBA (Visual Basic Applications) for autocad is an extension of the popular programming language VB (Visual Basic). VBA is effectivetly a subset of VB that allows for custom automation (macros) of the specific program that is is built into. Visual Basic for Applications (VBA) is a programming language and environment that is included with many Microsoft applications, such as Word, Excel, PowerPoint, and Access. Since Release 14, VBA has been available with AutoCAD allowing for greater integration for the more ‘computer savy’ user , allowing businesses to develop applications that were better suited what they do. VBA is ideally suited for situations in which you need to work with more than one application at a time. ActiveX, enables you to access objects in other applications. However, you can also use VBA to program AutoCAD alone. VBA in AutoCAD works slightly differently from VBA in most other applications, in that VBA projects are stored in a separate file, with the DVB filename extension, but can also be stored within the drawing file. Autodesk has begun the transition of Visual Basic customization from VBA to .NET technology. Currently, VBA is still supported however it is no longer part of the default CAD installation and must be downloaded and installed separately .


The Basics Why VBA? Once you have decided to make the step to start programming in AutoCAD there are a few possible languages that can be used - AutoLisp,VBA, VB.net etc. Why use VBA? VBA has the following advantages: VBA is faster than AutoLisp VBA is common to many other applications. If you have used VBA for Excel for example it is quite easy to transfer knowledge from one program to the other. VBA is generally believed to use an easier syntax than AutoLisp. VBA programs are saved as ‘projects’. A project contains all of the parts that are needed to execute the function of the program , this can be viewed through the VBA Manager. Useful Commands : VBAIDE Displays the Visual Basic Editor. VBALOAD Loads a global VBA project into the current work session. VBAMAN Manages VBA project operations using a dialog box. VBARUN Runs a VBA macro. VBASTMT Executes a VBA statement at the Auto CAD Command prompt. VBAUNLOAD Unloads a global VBA project.


User Interface To start working with VBA you must open the VBA environment. VBA has its own internal IDE, a graphical user interface - similar to that experienced in NetLogo. To display the IDE you can type VBAIDE in the AutoCAD command prompt line or choose Tools > Macro > Visual Basic Editor .

The AutoCAD Command Prompt Line

AutoCad will then display the VBA environment window. The editor contains several different windows - The first time you open it, it will look like below. AutoCAD is still running in the background. You can return to it at any time by clicking its button on the Windows task bar, or by clicking View AutoCAD on the VBA IDE Standard toolbar.

The AutoCAD VBA IDE


The Project Explorer The Project Explorer window displays a hierachical view called a treeview of your projects components that are loaded in the IDE - this will become particularly useful with more complex programs that use global variables and declarations! - We’ll get to that later! The view lists all of the UserForms,code and class modules associated with each project. Right shows a typical Project Explorer Window. As more modules and coding is created the list will automatically update - the window can be closed to gain more space in the IDE but its useful to keep it open. The Code Window The code window is where most of the development work and coding takes place.

Code Window

The drop down box in the top right of the code window displays what module is currently being worked on - this because useful when working with multiple modules within a project.


VBA Code As with any language (programming, written or spoken) you need to be familiar with the syntax and understand the variables before you can use them. AutoCADS Help (EXPLAINED LATER) gives alot of examples that can help with this. Alot of the basic concepts are built upon those established via the Balls In Space Workshop, but VBA is alot more explicit than the compact nature of NetLogo. Components of VBA Type Procedure property Project Module Form Subroutine Function Property Declaration Macro

Definition Code that does something - can be sub routine, function or a A set of forms and modules Can contain sub-routines,functions & declarations - a project can contain many modules A container of visual components - buttons, labels etc A procedure that does not return a value A procedure that returns a value A procedure that specifies a value / property of an object A non executable statement - naming constants or variables A public subroutine that a user can directly execute

There are many concepts that we will stumble through while programming with VBA - but they will be explained during each project - three main subjects that are reoccuring throughout coding will be discussed before any coding begins. Variables Variables can be declared by the user and allow them to retain values for use locally in a procedure or globally in the entire application. Variables are known by their datatype - that is the type of data which they can store. Variables can be declared at the beginning of a procedure below the Sub main() or above (for global declaration). The syntax for declaring a variable: Dim (variable name) As (datatype) E.G.


Constants Constants are values that never change. If a value is used throughout a procedure where the value will never change it should be delcared as a contants - like Pi. E.G.

It is possible to declare a constant as both public and private, but they are most often kept as public. To make a constant accessible in all the applications modules the word public is prefixed before the declaration e.g. Public Const PI = 3.14159 Typically constant names are written in CAPITAL LETTERS to quickly distinguish them from variables. Datatypes Visual Basic supplys basic data types to be used to define variables - if the needed datatype is unknown then by default it becomes a variant - but for ease of understanding the datatype should always be declared when known. The list below is not extensive but covers the most commonly used types. Data Type Integer Long Double String Boolean Variant

Value Range Whole Numbers Large Whole Numbers 8 Bytes of Data Text Characters 1 or 0 Anything

Purpose Negative & Postive Whole Numbers Relatively Large Negative & Positive Whole Double Decimal Numbers with 8bytes of data Text Characters True / Flase, Yes/No Default datatype if none specified


VBA Syntax To start programming an understanding of how a VBA routine is put together is needed. Shown below is a basic routine which draws random lines.

Sub draw_lines() ‘declare variables Dim start_point(2) As Double Dim end_pt(2) As Double Dim steps As Integer Dim myline As AcadLine ThisDrawing.SendCommand “ erase all “ steps = 200 start_point(0) = Rnd * Rnd start_point(1) = Rnd * Rnd start_point(2) = Rnd * Rnd For i = 0 To steps end_pt(0) = Rnd * Rnd end_pt(1) = Rnd * Rnd end_pt(2) = Rnd * Rnd Set myline = ThisDrawing.ModelSpace.AddLine(start_point, end_pt) Next i ZoomExtents End Sub


Line 1 : Sub indicates the start of a procedure, which is named - usually explaining the function of the procedure - this time its draw_lines() because the procedure results in lines being drawn. A project can have several sub procedures within modules. Line 2: Any sentence that starts with an apostrophe ( ‘ ) is a comment. Placing comments in routines helps you and others to understand what you’re doing. Line 3-6: Variables declared using Dim statements - declaring the datatype for the start and end points of the lines, as well as the amount of lines (steps) and the line datatype itself - an autocad line. Line 7: A direct command to AutoCAD to clear the modelspace before the application starts drawing lines - this ensures that nothing gets over written. Line 8: The number of steps for the Loop is defined Line 9-11: The start point for line is calculated (x,y,z). Line 12: A counter is established to make sure that only 201(steps) lines are drawn everything the loop is produced 1 is added to the count. Line 13-15: The end point for each line is calculated (x,y,z) Line 16: A line is added to the start and end points previously calculated in model space Line 17: This will go back to the start_point unless the number of steps have been reached Line 18: Modelspace will Zoom to extents Line 19: The procedure is ended.


Using the Visual Basic Editor When you type code from scratch in the Visual Basic Editor, you will immediately notice that VB colorcodes your text as you go. The most common colors are: Normal text Black Syntax-error text Red Comments Green Keyword text Blue Keywords include variable types and other words that Visual Basic recognizes, such as Dim and Sub.

HELP! VBA offers several help features. To access help on an object, choose it in Object Browser through right clicking the keyword and selecting object browser or through the help menu in the toolbar or using F1. After you open a help page, click Example to see an example. These examples are a great way to learn VBA.

The syntax explainations are contained at the bottom of the Object Browser window.


A tip that can come in very useful in fully understanding code that has been copied or inherited is using the ‘traffic lights’ within the VBA IDE.

Clicking to the left of the code at the point which you want the process to stop will cause a red dot to appear - this means that the action will only work until this point. Do undo this and let the code run in its entirity then you simple click the red dot again - this can be useful if there is an error or an undesired and your not sure why.


Week_1 Drawing Objects Autocad provides the user the ability to draw lines and objects through many different ways within the application - typing l or line in the command line, selecting draw > line etc. Nearly all objects that can be created through the main interface can be created and manipulated through the VBA IDE. Point Line Constructing a line with VBA uses the same characteristics as drawing a line in AutoCAD directly - first we must choose our tool - the line in this case - then we must select our start point which consists of 3 co-ordinates (X,Y,Z) then we specify our end point (X,Y,Z) and then the line is closed. The only difference to this routine using VBA is that we must declare our start ,end and line type and specify the three co-ordinates of the start and end point through typing rather than clicking modelspace. Sub main() Dimstart_point(2) As Double Dimend_point(2) As Double Dim my_lineAsAcadLine

’declare line type (this is a comment!)

start_point(0) = 10.123 ‘ x value start_point(1) = 10.123 ‘ y value start_point(2) = 10.123 ‘ z value ‘ declaring x(0), y(1) or z(2) values end_point(0) = 100.123 end_point(1) = 100.123 end_point(2) = 100.123

‘we use 100.123 to remember that it is double not an inte ger

Set my_line= ThisDrawing.ModelSpace.AddLine(start_point, end_point) ‘ here the line which ive called my_line is constructed using two points (start_point, end_point) Zoom All End Sub


Loops We have created our first line! Although it was quite exhaustive to create one line! It would have been quicker to use the ‘traditional’ method in AutoCAD to draw the line. In order to harness the true strength of VBA for AutoCAD we will now draw 100 lines. The process is the exact same as drawing one line, but it needs to be repeated 100 times. In order for this to work efficiently we need a LOOP to repeat the process (though we could write out 100 different three value start and end points but no one wants to do that!). We will use the For....Next Loop - E.G For i = 0 To 99 ‘remember that the computer starts counting from 0 - so 99 has 100 values!

Whatever is written within the box is repeated 100 times

Next i If we just add For i = 0 to 99 and a Next i statements before and after the start and end points we will get what is shown below. Although it looks the same as our first basic code - it is actually 100 lines ontop of each other. In order to achieve the desired result of 100 visiable lines we must alter the co-ordinates of the start and end points after each loop.


Code Sub main() Dim start_point(2) As Double Dim end_point(2) As Double Dim my_line As AcadLine For i = 0 To 99 start_point(0) = Rnd * 100 ‘ x value - Rnd is a random start point - which is multi plied by start_point(1) = Rnd * 100 by 100 after each loop start_point(2) = Rnd * 100 end_point(0) = 100.123 end_point(1) = 100.123 end_point(2) = 100.123 Set my_line= ThisDrawing.ModelSpace.AddLine(start_point,end_point) Next i Zoom All End Sub

Because we have specified a z value - start_point(2) and end_point(2) which are greater than zero , the 100 lines created are 3-dimensional and not limited to a 2D projection. Through simply altering the figures for the start_point and end_point we have the ability to produced varied and random results.


Constants We now introduced constants (Const) at the very beginning of the code - above the Sub Main() statement which means that it can be used for every sub-routine as it is a global declaration - if it was declared below the Sub Main() statement then it would be local and therefore only used within that specific sub-routine. Code: Const STEPS = 500 ‘our constants are integers Const SPACE = 100 ___________________________________________________________________ Sub main() Dim start_point(2) As Double Dim end_point(2) As Double Dim my_lineAsAcadLine This Drawing.SendCommand ”erase all “ For i = 0 To STEPS

‘This command clears modelspace ‘The STEPS constant has replaced 100

start_point(0) = Rnd* SPACE ‘ The 100 value has been replaced by STEPS (500) start_point(1) = Rnd* SPACE start_point(2) = Rnd* SPACE end_point(0) = Rnd* SPACE end_point(1) = Rnd* SPACE end_point(2) = Rnd* SPACE Set my_line= ThisDrawing.ModelSpace.AddLine(start_point,end_point) ‘Anything within the box will be repeated by STEPS (500) plus 1 (because the computer starts counting from zero Next i End Sub


Adding a Box We can add a Box to the end of the lines which we have created rather simply something that would be very tiresome without VBA. Using the AddXXX method (addline in previous code). Firstly we have to declare and dimension the box similarly to how we did the points and lines previously, then we have to pass the information into the loop so that a box is created at the end of each individual line - Set box = ThisDrawing.ModelSpace.AddBox(start_point, 2, 2, 2) Sub main() Dim start_point(2) As Double Dim end_point(2) As Double Dim my_line As AcadLine Dim box As Acad3DSolid ThisDrawing.SendCommand “erase all” For i = 0 To STEPS Set box = ThisDrawing.ModelSpace.AddBox(start_point, 2, 2, 2) start_point(0) = Rnd * SPACE start_point(1) = Rnd * SPACE start_point(2) = Rnd * SPACE end_point(0) = Rnd * SPACE end_point(1) = Rnd * SPACE end_point(2) = Rnd * SPACE Set my_line = ThisDrawing.ModelSpace.AddLine(start_point, end_point) Next i ZoomExtents End Sub


The image above illustrates the boxes positioned at the start of every line within the code. To add a box to the end point aswell is a very easy procedure. Dim box As Acad3DSolid Dim box2 As Acad3DSolid For i= 0 To Steps Set box = ThisDrawing.ModelSpace.AddBox(start_point, 2, 2, 2) Set box2 = ThisDrawing.ModelSpace.AddBox(end_point, 1, 1, 1) Next i The text in the boxes contain the additional code necessary to add a box to each end line point - in the example the boxes added are half the size of those at the beginning of the line (end_point, 1, 1, 1) - 1,1,1 is the width , height and depth of the object. The principle for adding a box to the line start and end points can be applied for any object which AutoCAD can produce - although the syntax is slightly different - e.g. a sphere/circle is developed through radius or diameter so they will require one measurement rather than width, height and depth. Dim Ball As Acad3DSolid Set Ball = ThisDrawing.ModelSpace.AddSphere(start_point,2) Next i


Colour (color) Condition So far everything that we have produced has been very monotone and boring! Introducing colour to our procedures is quite simple and can result in some very impressive results.We must remember that basic which VB derives from was written by Americans, so words like color are spelt seemingly incorrectly. Firstly like objects we must declare a new variable Dim Ball As Acad3DSolid Dim box As Acad3DSolid Dim col As New AcadAcCmColor ‘ we have shortened colour to col for ease of typing For i = 0 To STEPS Set Ball = ThisDrawing.ModelSpace.AddSphere(start_point,2) Set box = ThisDrawing.ModelSpace.AddBox(end_point, 1, 1, 1) col.SetRGB255, 0, 0 Ball.TrueColor = col (col)

‘ specifying the colour from the RGB table (red) ‘ making sure the sphere (ball) is set to the specified colour

Next i

We can add an If Then statement to alternate colours on the model. If start_point(2)>20 Then col.SetRGB 255,0, 0 box.TrueColor = col Else col.SetRGB 0, 255, 0 box.TrueColor = col End If


We can use the MOD command (explained later) to introduce colour gradients: col.SetRGB 255, (i * 10) Mod 255, 0 or the RND command to produce a random collection of coloured boxes col.SetRGB 255, (i * 10) Rnd 255, 0 Both these commands and code lines will and can be used in most projects and can add a nice degree of variation within code.


Week_2 Connected Lines As architects generally speaking it is rare to deal with apparently random lines - that have no connection or relation to each other. In order to write a VBA code to connect different lines it is important to consider the syntax and the start-end point relation. In order to continue a line, we must know the end point of the initial line. We must set the start and end point of the first line, then AddLine to the two points and then change the definition of start point to equal end point inside the loop so that the start point in the second iteration is now the first iterations’ end point. Code Example: Const STEPS = 10 Const SPACE = 50 Sub main () Dim i As Integer Dim start_point(2) As Double Dim end_point(2) As Double Dim my_line As AcadLine start_point(0) = Rnd * SPACE start_point(1) = Rnd * SPACE start_point(2) = Rnd * SPACE

‘ Random * 50

For i = 0 To STEPS - 1

‘-1 is included so that there is 10 steps

end_point(0) = Rnd * SPACE end_point(1) = Rnd * SPACE end_point(2) = Rnd * SPACE

‘ Random * 50

Set my_line = ThisDrawing.ModelSpace.AddLine(start_point, end_point) start_point(0) = end_point(0) start_point(1) = end_point(1) start_point(2) = end_point(2) Next i ZoomAll End Sub

‘redefining the start point


Start

End/Start Redefine

End/Start Redefine B 3,4

P2

P1 N

3 P3

A P4

2,1

1

We can add spheres at the end of each line in order to make it obvious that there are indeed 10 seperate lines. Set spheroid = ThisDrawing.ModelSpace.AddSphere(start_point, 2) y = 0.8

r=1

col.SetRGB 255, 0, 0 spheroid.TrueColor = col x = 0.6 Next i


Sub-Routine A procedure is a block of code that has a name and a specific purpose. A procedure can be a sub-routine, function or a property. A sub routine or procedure is a block of code that can be explicitly called by another procedure within the application (but does not return a value - it returns a data type). E.G. Const STEPS = 10 Const SPACE = 50 Sub main() Dim i As Integer Dim start_point(2) As Double Dim end_point(2) As Double Dim my_line As AcadLine For i = 0 To STEPS - 1

‘-1 is included so that there is 10 steps

col.SetRGB 255, (3 * i) Mod 255, 0 draw_the_line col

‘ routine called ‘draw_the_line’ is called

Next i ZoomAll End Sub The introduction of a sub routine makes the code more compact and easier to understand - as long as common sense naming conventions are adhered to!. The draw_the_line sub rountine is contained within a seperate module within the application and is explicitiy called from within the code procedure. The code for the draw_the_line sub routine is not smaller than when it was contained within the main procedure - but it means that neither procedure is overwhelming and now becomes more easily understood. Variables that are passed from one sub routine to another sub-routine do NOT have to keep the same name, but it is the order of the variables which is important.


Sub draw_the_line (paint AsAcadAcCmColor) Dim start_point(2) As Double, end_point(2) As Double Dim my_lineAsAcadLine Dim spheroid AsAcad3DSolid Dim box AsAcad3DSolid start_point(0) = Rnd* SPACE start_point(1) = Rnd* SPACE start_point(2) = Rnd* SPACE end_point(0) = Rnd* SPACE end_point(1) = Rnd* SPACE end_point(2) = Rnd* SPACE Set my_line= ThisDrawing.ModelSpace.AddLine(start_point,end_point) Set spheroid = ThisDrawing.ModelSpace.AddSphere(start_point, 2) Set box = ThisDrawing.ModelSpace.AddBox(end_point, 1, 1, 1) spheroid.TrueColor= paint my_line.TrueColor= paint End Sub The main routine can be identified from other routines by having nothing within the brackets e.g. Sub Main ()


Constructing Circles There are many ways in which a circle can be constructed in AutoCAD - typing ‘circle’ into the command line, draw>circle>centre radius, draw>circle>centre diameter etc. Using VBA we encounter similar options 1 AUTOCAD OBJECT Dim circus As AcadCircle Set circus = Thisdrawing.Modelspace.Addcircle(center, radius)

2 TRIGONOMETRY for i = 0 to (2*pi) x = cos(i) y = sin(i) next i

3 POLAR f or i = 1 to 360 position(i+1) = position(i) + direction * length next

All three approaches result in the same outcome (shown above), but these approaches begin to introduce the user to the idea of the user as an observer and how geometry is constructed. Are the circles results of abstract observations or is there a mechanistic logic behind their construction?


Const Pi = 3.14159 Const rad_x = 12 Const rad_y = 12 Const Segments = 360 Const DegToRad = Pi / 180 Const H = 5 Sub trig_circle() Dim I As Integer Dim divisions As Double Dim start_pt(2) As Double Dim end_pt(2) As Double Dim segment As AcadLine ThisDrawing.SendCommand “erase all” start_pt(0) = Cos(0) rad_x start_pt(1) = Sin(0) rad_y start_pt(2) = 0 angle_c = 360 / Segments For I = 1 To Segments end_pt(0) = Cos(I angle_c DegToRad) rad_x end_pt(1) = Sin(I angle_c DegToRad) rad_y end_pt(2) = H * I Set segment = ThisDrawing.ModelSpace.AddLine(start_pt, end_pt) start_pt(0) = end_pt(0) start_pt(1) = end_pt(1) start_pt(2) = end_pt(2) ThisDrawing.Regen acActiveViewport ZoomExtents Next I End Sub


Week 3 Spirals,Poyline & Faces In order to create a polyline using AutoCAD we select the polyline tool and click a start point , another point etc then the end point or you can select the tool and manually enter the co-ordinates in the command line. This process does not differ from when we use VBA - we must have a collection (array) of co ordinates (points) in order to create a 2D (Pline) or 3D polyline (3DPoly). E.G. set polyline = thisDrawing.modelSpace.add3DPoly(pt) declare pt (3* no_points-1) as double setup a loop: To draw a 3 point polyline we must remember that each point itself contains 3 co ordinates (x,y,z) E.G. Point 1 (X1, X2, X3) Point 2 (X4 , X5, X6) Point 3 (X7 , X8, X9) So, for 3 points we have a 9 element array, AutoCAD will divide the array into 3 (x,y,z)for each point automatically. We can set up this code using 3 methods : Using k as a counter, Using no counter and using K as a variable E.G Method 1: Using K as a counter k=0 angle_c= 360 / NoPoints For i= 0 To NoPoints-1 ‘* TURNS pt(k) = Cos(i* angle_c* DegToRad) * RAD_x pt(k + 1) = Sin(i* angle_c* DegToRad) * RAD_y pt(k + 2) = i* 1 Everytimeit overwrites the memory so we have to Introducek=k+3 Now it works! Next i

Method 2: k=3 angle_c= 360 / NoPoints For i= 0 To NoPoints-1 ‘* TURNS pt(k*i) = Cos(i* angle_c* DegToRad) * RAD_x pt(k*i+ 1) = Sin(i* angle_c* DegToRad) * RAD_y pt(k*i+ 2) = i* 1 Next i Method 3: Using No Counter angle_c= 360 / NoPoints For i= 0 To NoPoints-1 ‘* TURNS pt(i* 3) = Cos(i* angle_c* DegToRad) * RAD_x pt(i* 3 + 1) = Sin(i* angle_c* DegToRad) * RAD_y pt(i* 3 + 2) = i* 1 Next i


Const NoPoints = 36 Const PI = 3.14159265358979 Const RAD_x = 120 Const RAD_y = 120 Const DegToRad = PI / 180 Sub main () Dim i As Integer, k As Integer Dim angle_c As Double Dim pt(3 * NoPoints - 1) As Double Dim mypolyline As Acad3DPolyline ThisDrawing.SendCommand “erase all “ k=0 angle_c = 360 / NoPoints For i = 0 To NoPoints - 1 ‘* TURNS pt(k) = Cos(i * angle_c * DegToRad) * RAD_x pt(k + 1) = Sin(i * angle_c * DegToRad) * RAD_y pt(k + 2) = i * 1 k=k+3 ZoomExtents Next i Set mypolyline = ThisDrawing.ModelSpace.Add3DPoly(pt) End Sub


So far we have explored the three methods of creating a spiral using a polyline, but in order to add a face or panel to the spiral, it needs a depth / frame. The easiest way to produce this is to offset or copy and move the spiral - as a user would do in AutoCAD. When something is copied all the information and properities of the original are taken and passed onto the copy - with this in mind we will need to declare a new polyline within the procedure for the new copy. E.G Dim myother_polyline As Acad3DPolyline hence Set myother_polyline=mypolyline.Copy

‘its best not to use AutoCAD commands such as copy in naming conventions the name myother_polyline ‘ We then create myother_polyline

If we were to add these statements to the previous spiral code - we would produced two identical spirals BUT these spirals would appears as one as they are ontop of each other. We must now move the copy to our desired distance - + / - . To move the spiral we need two points (a start and an end) , a varient not a double! We dimension the new point and where to move the copied polyline . E.G Dim nw_point As Variant Set mypolyline = ThisDrawing.ModelSpace.Add3DPoly(pt) Set myotherpoly = mypolyline.Copy nwpt = mypolyline.Coordinate(0) ‘ the co-ordinate of mypolyline is set as newpoint nwpt(2) = 50

‘ the third co-ordinate(Z) of newpoint is distanced 50 away

myotherpoly.Movemypolyline.Coordinate(0), newpt ‘ the copy is moved to the newpoint ThisDrawing.RegenacActiveViewport

‘ the drawing is regenerated / updated

ZoomExtents End Sub The complete code is shown opposite with the results shown.


Const NoPoints = 36 Const PI = 3.14159265358979 Const RAD_x = 120 Const RAD_y = 120 Const DegToRad = PI / 180 Sub main() Dim i As Integer, k As Integer Dim angle_c As Double Dim pt(3 * NoPoints - 1) As Double Dim mypolyline As Acad3DPolyline Dim myother_polyline As Acad3DPolyline Dim nw_point As Variant ThisDrawing.SendCommand “erase all “ k=0 angle_c = 360 / NoPoints For i = 0 To NoPoints - 1 ‘* TURNS pt(k) = Cos(i * angle_c * DegToRad) * RAD_x pt(k + 1) = Sin(i * angle_c * DegToRad) * RAD_y pt(k + 2) = i * 1 k=k+3 ZoomExtents Next i Set mypolyline = ThisDrawing.ModelSpace.Add3DPoly(pt) Set myother_polyline=mypolyline.Copy nwpt = mypolyline.Coordinate(0) nwpt(2) = 50 myotherpoly.Movemypolyline.Coordinate(0) ThisDrawing.RegenacActiveViewport ZoomExtents End Sub


3D Face Now that we have our ‘frame’ we can add our 3D face - in order to add our 3D face we will require a LOOP. Typically our 3D face will be either a triangle requiring 3 points or a square / rectangle requiring 4 points. For this example we will use a rectangle. The first thing that we need to do is to declare the surface that will become our 3D face. Set face =ThisDrawing.ModelSpace.Add3DFace, (mypolyline.Coordinate(0), mypolyline.Coordinate(1), myotherpoly.Coordinate(1), myotherpoly.Coordinate(0)) We must remember that each polyline has been created using a number of points (36), the Set face command will use the co-ordinates on each polyline in order to create the 3D face - E.G The first point on the original polyline then the first point on the copy etc. In order to create multiple 3D faces we need to use our LOOP. For j= 0 To NoPoints-2

‘ its NoPoints - 2 so that we do not exceed the limit of the argument - another way would be to use MOD

Setpane =ThisDrawing.ModelSpace.Add3DFace, _ (mypolyline.Coordinate(j), mypolyline.Coordinate(j+1), myotherpoly.Coordinate(j+1), myotherpoly.Coordinate(j)) Next j



Const NoPoints = 360 Const PI = 3.14159265358979 Const RAD_x = 120 Const RAD_y = 120 Const DegToRad = PI / 180 Sub Multi_Turn() Dim i As Integer, k As Integer Dim angle_c As Double Dim pt(3 * NoPoints - 1) As Double ‘ each point needs 3 co-ordinates. Dim mypolyline As Acad3DPolyline Dim myother_polyline As Acad3DPolyline Dim pane As Acad3DFace Dim j As Integer ThisDrawing.SendCommand “erase all “ k=0 angle_c = 360 / NoPoints For i = 0 To NoPoints - 1 ‘* TURNS pt(k) = Cos(i * angle_c * DegToRad) * RAD_x pt(k + 1) = Sin(i * angle_c * DegToRad) * RAD_y pt(k + 2) = i * 1 + angle_c k=k+3 Next i Set mypolyline = ThisDrawing.ModelSpace.Add3DPoly(pt) Set myotherpoly = mypolyline.Copy newpt = mypolyline.Coordinate(0) newpt(2) = 60 myotherpoly.Move mypolyline.Coordinate(0), newpt For j = 0 To NoPoints - 2


Set pane = ThisDrawing.ModelSpace.Add3DFace _ (mypolyline.Coordinate(j), _ mypolyline.Coordinate(j + 1), _ myotherpoly.Coordinate(j + 1), _ myotherpoly.Coordinate(j)) ThisDrawing.Regen acActiveViewport Next j ZoomExtents End Sub


We can add variation to our spiral with simple ‘tweaks’ within the code in order to create new shapes - more turns within the spiral or more regular forms. E.G


Tower Venturing to more architectural terrioritory we can create simple towers and structures using previous codes and syntaxs with relative ease. We will start by using the polyline circle code, creating new circles at different heights until we have a tower of circles. We will declare each circle as a ‘floor’ and initially as a constant so that we understand how many circles will be created ; Const NoFloors =25 In order for the code to work we must introduce a ‘nested loop’ (a loop within a loop) so that a new floor will be created until the number of floors is reached.

We can create 3D faces / panels on the tower to further the architectural intention of the project by adding another nested loop and using the MOD function (explained later). Using MOD we modulise the number of floors and the number of points.

For j = 0 To NoFLOORS - 2 For i = 0 To NoPoints - 1 Set pane = ThisDrawing.ModelSpace.Add3DFace(mypolyline(j).Coordinate(i), mypolyline(j).Coordinate((i + 1) Mod NoPoints), _ mypolyline((j + 1) Mod NoFLOORS).Coordinate((i + 1) Mod NoPoints), mypolyline((j + 1) Mod NoFLOORS).Coordinate(i)) col.SetRGB 255, (j * 10) Mod 255, 0 pane.TrueColor = col


ConstNoPoints= 25 ConstNoFLOORS= 20 ConstPI = 3.14159265358979 ConstDegToRad= PI / 180 _______________________________________________________________________________ Sub trig_circle() Dim i As Integer, k As Integer, j As Integer Dim RAD_xAs Double, RAD_y As Double Dim angle_c As Double Dim pt(3 * NoPoints-1) As Double ‘ each point needs 3 co-ordinates. Dim mypolyline(0 To NoFLOORS-1) As Acad3DPolyline ThisDrawing.SendCommand ”erase all “ angle_c= 360 / NoPoints For j = 0To NoFLOORS-1 RAD_x= 120 ‘---or alternative you can use this RAD_y= 120 ‘ Xrad= 20 -10 + Cos(j * DegToRad) / 10 k = 0 ‘ Yrad= 20 For i= 0 ToNoPoints-1 pt(k) = Cos(i* angle_c* DegToRad) * RAD_x pt(k + 1) = Sin(i* angle_c* DegToRad) * RAD_y pt(k + 2) = j * 10 k=k+3 Next i Set mypolyline(j) = ThisDrawing.ModelSpace.Add3DPoly(pt) mypolyline(j).Closed = True ThisDrawing.RegenacActiveViewport ZoomExtents Next j End Sub


We can add variation to the tower by rotating the floorplates creating a twisted effect within the facade. To rotate the floor plates we have to dimension a point “cc” around which we want to do the rotation, we add the rotation code after creating polyline. Dim cc(2) As Double Dim col As New AcadAcCmColor ____________________________________________________________ Set mypolyline(j) = ThisDrawing.ModelSpace.Add3DPoly(pt) mypolyline(j).Closed = True mypolyline(j).Rotate cc, j * 5 * DegToRad _______________________________________________________ col.SetRGB 255, (j * 10) Mod 255, 0 pane.TrueColor = col

By using the random function (Rnd) we can create some interesting results by altering constants and integers contained with the code.

Xrad = Rnd * 20 Yrad = Rnd * 20

Set mypolyline(j) = ThisDrawing.ModelSpace.Add3DPoly(pt) mypolyline(j).Closed = True mypolyline(j).Rotate cc, j * Rnd * DegToRad


MOD (Modulus Operator) So far we have used the MOD (modulus operator) a few times - mainly to help create a colour gradient (but it can also become useful when used in conditional statements). The modulus operator is used in operations involving two numbers E.G number 1 Mod number 2 The Mod operator syntax has these parts: Part Description result Required; any numeric variable. number1 Required; any numeric expression. number2 Required; any numeric expression. Mod divides number 1 by number 2 *rounding floating-point numbers to integers) Used to divide two numbers and return only the remainder as result. For example, in the following expression, A (result) equals 5. A = 19 Mod 6.7 Usually, the data type of result is a Byte, Byte variant, Integer, Integer variant, Long, or Variant containing a Long, regardless of whether or not result is a whole number. Any fractional portion is truncated. However, if any expression is Null, result is Null. Any expression that is Empty is treated as 0. The example uses the Mod operator to divide two numbers and return only the remainder. If either number is a floating-point number, it is first rounded to an integer. Dim MyResult MyResult = 10 Mod 5 ‘ Returns 0. MyResult = 10 Mod 3 ‘ Returns 1. MyResult = 12 Mod 4.3 ‘ Returns 0. MyResult = 12.6 Mod 5 ‘ Returns 3. A more detailed explanation is available through the VBA Help menu.


Week 4 Brownian Walker & Painter We can create outputs through a behavioural process similar to the agents which we used in NetLOGO - this means that although the function creates an output it itself is not aware of the output. We can create a outcome similar to that of a ‘browian motion’** by constraining the possible outcome to a set range of possibilities E.G 0-5 etc. The code creates a seemingly random ‘walk’ made of 501 different line lengths - at the end of each length a new locality is assumed.

Old Direction + Range

Random New position

Random New position

Old Direction - Range

We can easily create a random route by altering the code (over leaf) by changing the range constraints to either a very high value or to Rnd (random). For i = 0 To Num range = Rnd

Y x

1d Array

2d Array

x

new_position(0) = position(0) + Cos(i * direction * DegToRad) * length new_position(1) = posit *Brownian notion describes the movement of particles in fluids


Option Explicit Const PI = 3.14159 Const Num = 500 ‘---number of steps Const DegToRad = PI / 180 Sub Brownian_Walker() Dim i As Integer Dim position(2) As Double Dim new_position(2) As Double Dim length As Double Dim walk As AcadLine Dim direction As Double, d1 As Double, d2 As Double Dim range As Double Dim col As New AcadAcCmColor ThisDrawing.SendCommand “erase all “ length = 1 direction = 1 position(0) = random(0, 500) position(1) = random(0, 500) position(2) = 0 For i = 0 To Num range = 0.1 new_position(0) = position(0) + Cos(i * direction * DegToRad) * length new_position(1) = position(1) + Sin(i * direction * DegToRad) * length new_position(2) = 0

Set walk = ThisDrawing.ModelSpace.AddLine(position, new_position) col.SetRGB 255, 0, 0 walk.TrueColor = col


position(0) = new_position(0) position(1) = new_position(1) position(2) = new_position(2) d1 = direction + range d2 = direction - range

direction = random(d1, d2)

ThisDrawing.Regen acActiveViewport ZoomExtents Next i ZoomExtents End Sub


Painter We continue creating agent like behaviour through the painter exercise. To do this we use sub-routines and if statements - creating linear conditions producing results reminiscent of Piet Mondrian.

If-Statement There are two main categories which control the flow of a program - loops and conditionals - we have already encountered loops, now we are encountering conditionals, as the name suggusts they rely on a defined condition being statisifed to achieve a result. The If -Statement is the most common example of conditionals.If-Statements are control and decision structures - they allow for the testing of a condition value or state and perform operations dependent on the result. Conditionals bring the notion of ‘decisions’ into the program - automated decisions. E.G. If (condition = True) Then do_something. The If-statement can have one to several conditions using different syntaxes , E.G. If (condition A = True)Then do A ElseIf(condition B = True)Then do B Else do C End If


The painter exercise is similar in output to one of the exercises that were completed during the ‘Balls In Space’ workshop. Examples of the NetLOGO output and code are shown below - to illustrate the similarites and differences between the two programs. to setup ca crt 1 ask turtles [ setxy 0 0 set shape “circle” set size 0.5 set heading 0 set color white ] end to paint let coinflip random 10 ask turtles [ pd fd random 5 ifelse (coinflip < 5) [set heading heading + 90]; adds a direction to the previous direction added, right [set heading heading - 90] ;left ] end As shown above the syntax and language of NetLOGO is very simple and straight forward compared to the more explicit VBA. Although the same basic syntax is used for both declare variables - VBA- length etc NETLOGO - size declare co-ordinates- VBA position etc NETLOGO - set xy function - VBA newposition etc NETLOGO - fd 5 direction - VBA flipcoin NETLOGO - coinflip


Option Explicit Const PI = 3.14159 Const Num = 500 ‘---number of steps Const DegToRad = PI / 180 Sub painter() Dim i As Integer Dim position(2) As Double Dim new_position(2) As Double Dim length As Double Dim walk As AcadLine Dim direction As Double, d1 As Double, d2 As Double Dim range As Double Dim col As New AcadAcCmColor ThisDrawing.SendCommand “erase all “ direction = 1 position(0) = random(0, 500) position(1) = random(0, 500) position(2) = 0 For i = 0 To Num length = random(1, 10) range = 90 new_position(0) = position(0) + Cos(i * direction * DegToRad) * length new_position(1) = position(1) + Sin(i * direction * DegToRad) * length new_position(2) = 2 * d1

Set walk = ThisDrawing.ModelSpace.AddLine(position, new_position) col.SetRGB 255, 0, 0 walk.TrueColor = col


position(0) = new_position(0) position(1) = new_position(1) position(2) = new_position(2) d1 = flipcoin direction = range * d1 ‘direction + range * d1

ThisDrawing.Regen acActiveViewport ZoomExtents Next i ZoomExtents End Sub

Public Function flipcoin() As Integer flipcoin = IIf((random(0, 10) > 5), 1, -1) End Function


Week 5 1D Array - The Self Organising String We have previously touched on the functions of arrays, loops and sub-routines - in this exercise we will combine all three with data types and conditionals aswell to create a 1-dimensional array - The Self Organising String. An array will be created in conjunction with a loop in order to diffuse a set of height values between nodes of a polyline - a form of diffusion algorithm.

The basic principle of the code is that we start of with x number of nodes which will be represented by circles Const MAX_NODES = 150 ‘ amount of nodes in the chain Type node pos(2) As Double ‘ position of node includes current state temp As Double ‘ intermediate state for averaging neighbours link As AcadCircle ‘ the actual node representation End Type Each nodes position is then calculated relative to its neighbours position to its right

and averaged to create a new temporary node position - this temporary array acts as Y a buffer store of sorts and will over over written after each loop. This loop continues 100 times and becomes linked with a ‘chain’ (polyline) when each loop is completed. x

1d Array

2d Array

x


Code Flow Sub main() Dim nodes(MAX_NODES) As node initialize nodes

For d = 0 To 100 calculate nodes

calculate nodes subroutine

update_nodes nodes

update_notes subroutine

Next d

x100

End Sub Shown above is the main procedure - through the use of subroutines the code has become quite tidy and easily comprehendable to others. When the complete code is viewing including all subroutines the code can become quite overwhealming , but using subroutines the code is broken into logical steps. There is one new type of coding terminalogy** used in this routine - ABS - that we are not familiar with . ABS is the absolute value of any equation and will only return a positive value. (more explicit information is available through VBA help).


Const MAX_NODES = 150 ‘ amount of nodes in the chain Type node pos(2) As Double ‘ position of node includes current state temp As Double ‘ intermediate state for averaging neighbours link As AcadCircle ‘ the actual node representation End Type Public chain As Acad3DPolyline ‘a public variable - the polyline __________________________________________________________________________ Sub main() Dim nodes(MAX_NODES) As node ‘decalare a variable using the new datatype “NODE” ‘set up array initialize nodes

‘exchange information and adjust

For d = 0 To 100 calculate nodes

‘calling subroutine calculate with argument nodes

update_nodes nodes Next d End Sub Sub initialize(nodes() As node) Dim pts((MAX_NODES + 1) * 3 - 1) As Double ‘ ThisDrawing.SendCommand “erase all “ Randomize ‘built in function to reset the random function For i = 0 To MAX_NODES nodes(i).pos(0) = i nodes(i).pos(2) = Rnd * 200 Set nodes(i).link = ThisDrawing.ModelSpace.AddCircle(nodes(i).pos, 0.5) ‘---collect points for the polyline


pts(p) = nodes(i).pos(0) pts(p + 1) = nodes(i).pos(1) pts(p + 2) = nodes(i).pos(2) p=p+3 Next i Set chain = ThisDrawing.ModelSpace.Add3DPoly(pts) ZoomExtents End Sub Sub calculate(nodes() As node) Dim l_n As Integer, r_n As Integer For n = 0 To MAX_NODES ‘get left neighbour index If (n > 0) Then ; first conditional statment BLOCK IF l_n = n - 1 Else l_n = MAX_NODES End If ‘get right neighbour index If (n < MAX_NODES) Then ; second conditional statment BLOCK IF r_n = n + 1 Else r_n = 0 End If nodes(n).temp = (nodes(l_n).pos(2) + nodes(n).pos(2) + nodes(r_n).pos(2)) / 3 ‘sum neighbour values and average into ‘TEMP’


Next n End Sub Sub update_nodes(nodes() As node) ‘ update all node information first then the polylines For n = 0 To MAX_NODES ‘nodes nodes(n).pos(2) = nodes(n).temp nodes(n).link.center = nodes(n).pos ‘polyline chain.Coordinate(n) = nodes(n).pos Next n ThisDrawing.Regen acActiveViewport ZoomExtents End Sub



Week(s) 6-7 2D Diffusion We can build upon the 1d diffusion algorithm started last week and make it a 2d array and create a 3d mesh with some simple additions to the code.

‘This intails the idea of going from a line to a surface and relax the surface according to some parameters that need to be compared and averaged, just like we did last week with the line nodes’ 161110 | programming architecture The process of compiling and averaging nodes on a surface (mesh) represent a simple version of Artificial Life or Celluar Automation (CA) :

‘The basic principle of a CA entails the following few rules: + every element adapts to its immediate local environment: this means that each element’s or position’s value is calculated from the values of its surrounding topological neighbours + the elements cannot directly inform their topological neighbouring elements, ie each element is passively receiving information, not giving information (kind of a voting principle: you discuss with your neigh bours but you have to vote yourself ) + all elements need to compute simultaneously: this means that all elements need to extract at some point t, the same information from all their neighbours. Consequently, this pseudo parallel processing requires the system to be frozen for a moment and later updated when all elements have computed their new value All of the above rules or conditions apply to the averaging in 1d and 2d for our lines and surfaces, and thus constitute a CA.’ 161110 | programming architecture In order to process the array we need to organise the nodes in 2 dimensions this requires a 2 dimensional array - one array within another array. It easiest understood to think of the arrays as co-ordinates for a grid system one for x and one for y. This helps to modulate the process of the creation of a 3d mesh.


Y x

1d Array

2d Array

x

initialize nodes For j = 1 To TURNS - 1 calculate nodes update nodes Set achain(0) = chain Set achain(j) = chain.Copy origin(2) = chain.Coordinate(0)(2) movept(2) = origin(2) + 5 * j achain(j).Move origin, movept place_face achain, j Next j Each time the loop is run a new start position is defined and connections made between each iteration of the loop which creates the 3d Mesh.



Option Explicit Const TURNS = 100 Const MAXNO = 100 Type element pts(2) As Double body As AcadCircle temp(2) As Double pen As AcadLine End Type Public chain As Acad3DPolyline Public achain(TURNS - 1) As Acad3DPolyline _______________________________________________________________________________ Sub main() Dim nodes(MAXNO) As element Dim i As Integer, j As Integer, before As Integer, after As Integer Dim origin(2) As Double, movept(2) As Double Dim col As New AcadAcCmColor initialize nodes For j = 1 To TURNS - 1 calculate nodes update nodes Set achain(0) = chain Set achain(j) = chain.Copy origin(2) = chain.Coordinate(0)(2) movept(2) = origin(2) + 5 * j achain(j).Move origin, movept place_face achain, j Next j End Sub


Sub initialize(nodes() As element) Dim i As Integer Dim pts((MAXNO + 1) * 3 - 1) As Double ThisDrawing.SendCommand “erase all “ For i = 0 To MAXNO nodes(i).pts(0) = i nodes(i).pts(1) = Rnd * 150 nodes(i).pts(2) = 0 Set nodes(i).body = ThisDrawing.ModelSpace.AddCircle(nodes(i).pts, 0.3) ‘---collect the point to link them with a chain pts(i * 3) = nodes(i).pts(0) pts(i * 3 + 1) = nodes(i).pts(1) pts(i * 3 + 2) = nodes(i).pts(2) Next i Set chain = ThisDrawing.ModelSpace.Add3DPoly(pts) ZoomExtents End Sub _______________________________________________________________________________ Sub calculate(nodes() As element) Dim i As Integer Dim before As Integer, after As Integer For i = 0 To MAXNO before = i - 1 after = i + 1 If before < 0 Then before = MAXNO


If after > MAXNO Then after = 0

/3

nodes(i).temp(1) = (nodes(before).pts(1) + nodes(i).pts(1) + nodes(after).pts(1)) Next i

End Sub _______________________________________________________________________________ Sub update(nodes() As element) Dim i As Integer Dim col As New AcadAcCmColor

For i = 0 To MAXNO nodes(i).pts(1) = nodes(i).temp(1) nodes(i).body.Center = nodes(i).pts nodes(i).body.update chain.Coordinate(i) = nodes(i).pts Set nodes(i).pen = ThisDrawing.ModelSpace.AddLine(nodes(i).pts, nodes(i).

pts)

col.SetRGB 255, 0, 0 nodes(i).pen.TrueColor = col Next i

ZoomExtents End Sub


Sub place_face(achain() As Acad3DPolyline, j As Integer) Dim k As Integer Dim newpt(2) As Double Dim panel As Acad3DFace Dim col As New AcadAcCmColor

For k = 0 To (MAXNO - 1) newpt(0) = achain(j).Coordinate(k)(0) newpt(1) = achain(j).Coordinate(k)(1) newpt(2) = achain(j).Coordinate(k)(2) - j * 0.05 Set panel = ThisDrawing.ModelSpace.Add3DFace(newpt, achain(j 1).Coordinate(k), _ achain(j - 1).Coordinate(k + 1), achain(j). Coordinate(k + 1)) col.SetRGB 255, 200, j * 2 panel.TrueColor = col

Next k

End Sub


Week(s) 8-9 Grid & Rib Structures The weeks project will become the base / source code for the Thousand Plateaus project and will introduce some synaptic tricks and new terms that help aid an economy of typing within our coding.

User Input

The basic premise of the code is to build upon the relaxation exercise - we first initialize a point grid - representented by circles, we are then prompted by the command line to pick a point on the grid. If the user does not click exactly on a node

Position Input Calculate Node Position

within the point grid then the computer processes the nearest node location using Force Input the phygorian theorm - in a similar way that we did it previously using NetLOGO [set closest-mouse min-one-of other mice [distance myself] The user will then be prompted to apply a force to this node via a message box

No

(InputBox(“specify the strength of input source “, “enter value”, “5”)) Once this is completed we start the loop again with input points and strength, when this condition is satisfied the grid will distort with the selected node(s) elevating


to the desired heights input by the user. The user is then prompted for rib height and then thickness via message boxes - lines are constructed on the horizontal and vertical axises and moved and extruded to form 3d solids.

The ribs are then copied , labelled and rotated so that they can be fabricated (Laser Cut, CNCed etc). rib(u).Move cordu(u).GetFitPoint(0), insertptu rib(u).Rotate3D insertptu, axisptu, ang Shown below is the main procedure () - we have once again utilised sub routines to ensure that the code is easy to understand - the complete code is available at the end of this chapter. Sub main() ‘initialize array initialize 0 ‘exchange information and adjust For d = 0 To 20 calculate 0 - Call Calculate Procedure update_nodes 0 - Call Update_nodes Procedure Next d ‘draw braces insert_lines 0 End Sub

- Call Insert_lines Procedure


During this exercise as you will see from the full code we used several new methods which we have previously hinted at, they include: Ubound Redim IIf Conditional Loops Acad Extrusions Ubound The ubound stands for the ‘upper bound’ of an array and literally expresses the maximum size of elements in the array. You can use this if you are not sure of the size of an array E.G Dim my_array(10) as integer You can find out its size by defining ‘limit’ as the upper bound of my_array limit = ubound(my_array) limit = 10 which means that you have 11 elements in the array (0 - 10). * Remember a computer counts 0,1,2,3,4 NOT 1,2,3,4 like humans. Redim The ReDim statement allows you to change the size of your arrays, this can be useful whenever you have a dynamic array - an array that had no initial set of values () (an empty bracket) e.g. Dim my_array () As Integer Later in the code you can adjust this using redim ReDim my_array (10) As Integer You can only change the size of the array using ReDim not the datatype. If you do use ReDim this will change all previous instances of where the array had been dynamic and possibly over the new defined length - to keep previous instances you can use ReDim preserve e.g. ReDim Preserve my_array(10,15) as data_type


IIf We have previously used conditional statements - If-Then etc, but if there are only two possible solutions - True or False then it is more convenient to use the IIf statement. E.G. l_n = IIf(u > 0, u - 1, HOR) We have been writing this previously as: If(u > 0) then l_n = u-1 Else l_n = HOR End If As we can see the IIf method is alot quicker and more understandable when in the ‘know’. Conditional Loops We have used loops many times now in most codes but we have been using the For.. Next Loop. We use another type of loop in this code - the Do Loop While - this is used while a certain condition is not satisfied in this case it corresponds to some of the input messages boxes that appear to prompt the user - if the user clicks no then the loop ends, if the user clicks yes then the loop begins again. Do ... answer = MsgBox(“do you want to seed another point?”, vbYesNo, “tired”) Loop While (answer = vbYes)


ACAD Extrusions ‘To do extrusions in AutoCAD you have to follow a very specific set of steps (an algorithm) 1 - select the objects to be extruded into an array of type AcadEntity 2 - turn the AcadEntity array into an AcadRegion, which initially pro duces a result of type variant 3- Extrude the first element of the variant (which is the region) into an Acad3DSolid We have followed this procedure in order to extrude the ribs into solid objects: Dim links(3) As AcadEntity Dim temp As Variant Dim rib As Acad3DSolid Set links(0) = ThisDrawing.ModelSpace.AddSpline(pts, st, et) Set links(1) =links(0).Copy Set links(2) = ThisDrawing.ModelSpace.AddLine(p1,p2) Set links(3) = ThisDrawing.ModelSpace.AddLine(p1,p2) temp = ThisDrawing.ModelSpace.AddRegion(links) Set rib = ThisDrawing.ModelSpace.AddExtrudedSolid(temp(0), 1, 0) Note how you use the Spline and Line and any object you want and build it into the AcadEntity array. Eventually those four objects make a closed planar polygon that can be extruded’ 161110 | programming architecture


Step 1

Procedures

User Input

Initialize

Position Input

Initialize_ Ground

Calculate Node Position

Force Input

Step 2

Check_Input

Step 3

Initialize Force

Calculate_Ground

Rib Height

Step 6

Step 5

Step 4

Initialize_Ribs Rib Thickness

Calculate_Ribs

Initialize_Fab_Ready


Nodes SetUp Nodes

No

Input Finished? Yes

Calculate Ground

Rib Setup

Rib Calculate

Fabricate Setup


Const HOR = 30 Const VER = 30 Type user_input pos As Variant force As Integer End Type Type node fix As Boolean values pos(2) As Double state As Double temp As Double body As AcadCircle End Type

‘horizontal dimension (u) ‘vertical dimension (v) ‘location ‘strength

‘fixes the state when near the source, so it doesnt diffuse

Public nodes() As node ‘points on surface/space Public inputs() As user_input ‘source points and intensity Public max_z As Double _______________________________________________________________________________ Sub main() ‘initialize array initialize 0 ‘exchange information and adjust For d = 0 To 20 calculate 0 update_nodes 0 Next d ‘draw braces insert_lines 0 End Sub Sub initialize(anyname As Integer) ‘ HOR = howmany(0) ‘---is coming from the function howmany that returns a value which is howmany ‘ VER = howmany(1)


‘Dim pts((VER + 1) * 3 - 1) As Double ReDim nodes(HOR, VER) As node ThisDrawing.SendCommand “erase all “ Randomize For u = 0 To HOR For v = 0 To VER nodes(u, v).pos(0) = u * 2 nodes(u, v).pos(1) = v * 2 nodes(u, v).pos(2) = 0 Set nodes(u, v).body = ThisDrawing.ModelSpace.AddCircle(nodes(u, v).pos, 0.5) Next v Next u ‘get source information get_sources 0 ‘check whether close to source| if yes, then take source properties check_sources 0 ZoomExtents End Sub Sub get_sources(token As Integer) Dim answer As Integer, n As Integer Dim pt As Variant Do pt = ThisDrawing.Utility.GetPoint(, “select a location on screen”) ReDim Preserve inputs(n) As user_input inputs(n).pos = pt ‘inputs(n).force = ThisDrawing.Utility.GetInteger(“specify the strength of input source”) inputs(n).force = val(InputBox(“specify the strength of input source “, “enter value”, “5”)) If (Abs(inputs(n).force) > max_z) Then max_z = Abs(inputs(n).force) answer = MsgBox(“do you want to seed another point?”, vbYesNo, “tired”) n=n+1


Loop While (answer = vbYes) End Sub _______________________________________________________________________________ Sub check_sources(token As Integer) Dim q As Integer, u As Integer, v As Integer, nearest(1) As Integer, nearest_n(1) As Integer, nearest_r(1) As Integer, nearest_l(1) As Integer, nearest_b(1) As Integer, nearest_a(1) As Integer Dim mindis As Double, dis As Double For q = 0 To UBound(inputs) mindis = 100000 For u = 0 To HOR For v = 0 To VER dis = Sqr((inputs(q).pos(0) - nodes(u, v).pos(0)) ^ 2 + (inputs(q).pos(1) nodes(u, v).pos(1)) ^ 2) If (dis < mindis) Then nearest(0) = u ‘nearest node horizontal index nearest(1) = v ‘nearest node vertical index mindis = dis End If

‘new minimum distance

Next v Next u ‘user_input gibt information an node weiter und update node nodes(nearest(0), nearest(1)).fix = True nodes(nearest(0), nearest(1)).state = inputs(q).force nodes(nearest(0), nearest(1)).body.center = nodes(nearest(0), nearest(1)).pos For i = nearest(0) - 1 To nearest(0) + 1 For j = nearest(1) - 1 To nearest(1) + 1 nearest_n(0) = i nearest_n(1) = j nodes(nearest_n(0), nearest_n(1)).fix = True nodes(nearest_n(0), nearest_n(1)).state = inputs(q).force nodes(nearest_n(0), nearest_n(1)).body.center = nodes(nearest_n(0), nearest_n(1)).pos


Next j Next i

Next q End Sub Sub calculate(token As Integer) Dim l_n As Integer, r_n As Integer, a_n As Integer, b_n As Integer For u = 0 To HOR For v = 0 To VER l_n = IIf(u > 0, u - 1, HOR) r_n = IIf(u < HOR, u + 1, 0) b_n = IIf(v > 0, v - 1, VER) a_n = IIf(v < VER, v + 1, 0)

‘left neigh index ‘right neigh index ‘below neigh ‘above neigh

With nodes(u, v) If (.fix) Then .temp = .state Else .temp = (.pos(2) + nodes(l_n, v).pos(2) + nodes(r_n, v).pos(2) _ + nodes(u, a_n).pos(2) + nodes(u, b_n).pos(2)) / 5 End If End With Next v Next u End Sub Sub update_nodes(token As Integer) Dim col As New AcadAcCmColor For u = 0 To HOR


Next j Next i

Next q End Sub Sub calculate(token As Integer) Dim l_n As Integer, r_n As Integer, a_n As Integer, b_n As Integer For u = 0 To HOR For v = 0 To VER l_n = IIf(u > 0, u - 1, HOR) r_n = IIf(u < HOR, u + 1, 0) b_n = IIf(v > 0, v - 1, VER) a_n = IIf(v < VER, v + 1, 0)

‘left neigh index ‘right neigh index ‘below neigh ‘above neigh

With nodes(u, v) If (.fix) Then .temp = .state Else .temp = (.pos(2) + nodes(l_n, v).pos(2) + nodes(r_n, v).pos(2) _ + nodes(u, a_n).pos(2) + nodes(u, b_n).pos(2)) / 5 End If End With Next v Next u End Sub Sub update_nodes(token As Integer) Dim col As New AcadAcCmColor For u = 0 To HOR


For v = 0 To VER ‘update body nodes(u, v).pos(2) = nodes(u, v).temp nodes(u, v).body.center = nodes(u, v).pos If (nodes(u, v).pos(2) >= 1 Or nodes(u, v).pos(2) <= -1) Then nodes(u, v).body. Radius = 1 / (1 + Abs(nodes(u, v).pos(2))) ‘ col.SetRGB 255 - 255 / max_z * Abs(nodes(u, v).pos(2)), 255 - 255 / max_z * Abs(nodes(u, v).pos(2)), 255 - 255 / max_z * Abs(nodes(u, v).pos(2)) ‘ nodes(u, v).body.TrueColor = col nodes(u, v).body.Update Next v Next u End Sub Sub insert_lines(token As Integer) Dim u As Integer, v As Integer Dim pts() As Double, st(2) As Double, et(2) As Double, slotptu(2) As Double, slotptv(2) As Double Dim brace As AcadLine, cordu(HOR) As AcadSpline, cordv(VER) As AcadSpline Dim links(3) As AcadEntity Dim linkss(3) As AcadEntity Dim copie As AcadSpline Dim here As Variant, there As Variant Dim tempu(HOR) As Variant Dim tempv(VER) As Variant Dim slotu As Acad3DSolid, slotv As Acad3DSolid

Dim rib(HOR) As Acad3DSolid Dim ribs(VER) As Acad3DSolid Dim thick As Double Dim height As Double Dim cornptA(2) As Double, cornptB(2) As Double, cornptC(2) As Double, cornptD(2) As Double Dim lineA(3) As AcadEntity Dim tempo As Variant


‘thick = howmany(0) height = val(InputBox(“rib height “, “enter value”, “1”)) thick = val(InputBox(“rib thickness “, “enter value”, “.2”)) ‘height = ThisDrawing.Utility.GetReal(“specify the height of the material”) ‘thick = ThisDrawing.Utility.GetReal(“specify the thickness of the material”) For u = 0 To HOR ReDim pts(2) As Double For v = 0 To VER pts(UBound(pts) - 2) = nodes(u, v).pos(0) pts(UBound(pts) - 1) = nodes(u, v).pos(1) pts(UBound(pts)) = nodes(u, v).pos(2) ReDim Preserve pts(UBound(pts) + 3) As Double Next v ReDim Preserve pts(UBound(pts) - 3) As Double Set cordu(u) = ThisDrawing.ModelSpace.AddSpline(pts, st, et) Set copie = cordu(u).copy here = cordu(u).GetControlPoint(0) there = here there(2) = here(2) - height copie.Move here, there

On Error Resume Next Set links(0) = cordu(u) Set links(1) = copie Set links(2) = ThisDrawing.ModelSpace.AddLine(here, there) Set links(3) = ThisDrawing.ModelSpace.AddLine(cordu(u).GetFitPoint(VER), copie.GetFitPoint(VER)) tempu(u) = ThisDrawing.ModelSpace.AddRegion(links) Set rib(u) = ThisDrawing.ModelSpace.AddExtrudedSolid(tempu(u)(0), thick, 0)

ThisDrawing.Regen acAllViewports


Next u ‘----------------------------------‘---draw the horizontal For v = 0 To VER ReDim pts(2) As Double For u = 0 To HOR pts(UBound(pts) - 2) = nodes(u, v).pos(0) pts(UBound(pts) - 1) = nodes(u, v).pos(1) pts(UBound(pts)) = nodes(u, v).pos(2) ReDim Preserve pts(UBound(pts) + 3) As Double Next u ReDim Preserve pts(UBound(pts) - 3) As Double Set cordv(v) = ThisDrawing.ModelSpace.AddSpline(pts, st, et) Set copie = cordv(v).copy here = cordv(v).GetControlPoint(0) there = here there(2) = here(2) - height copie.Move here, there On Error Resume Next Set links(0) = cordv(v) Set links(1) = copie Set links(2) = ThisDrawing.ModelSpace.AddLine(here, there) Set links(3) = ThisDrawing.ModelSpace.AddLine(cordv(v).GetFitPoint(HOR), copie.GetFitPoint(HOR)) tempv(v) = ThisDrawing.ModelSpace.AddRegion(links) Set ribs(v) = ThisDrawing.ModelSpace.AddExtrudedSolid(tempv(v)(0), thick, 0) ThisDrawing.Regen acAllViewports Next v Dim cutu(HOR) As Variant For u = 0 To HOR For v = 0 To VER cornptA(0) = nodes(u, v).pos(0) + thick / 2 + 0.02 cornptA(1) = nodes(u, v).pos(1) cornptA(2) = nodes(u, v).pos(2) + height / 2 cornptB(0) = nodes(u, v).pos(0) - thick / 2 + 0.02


cornptB(1) = nodes(u, v).pos(1) cornptB(2) = nodes(u, v).pos(2) + height / 2 cornptC(0) = nodes(u, v).pos(0) - thick / 2 + 0.02 cornptC(1) = nodes(u, v).pos(1) cornptC(2) = nodes(u, v).pos(2) - height / 2 cornptD(0) = nodes(u, v).pos(0) + thick / 2 + 0.02 cornptD(1) = nodes(u, v).pos(1) cornptD(2) = nodes(u, v).pos(2) - height / 2

On Error Resume Next Set lineA(0) = ThisDrawing.ModelSpace.AddLine(cornptA, cornptB) Set lineA(1) = ThisDrawing.ModelSpace.AddLine(cornptB, cornptC) Set lineA(2) = ThisDrawing.ModelSpace.AddLine(cornptC, cornptD) Set lineA(3) = ThisDrawing.ModelSpace.AddLine(cornptD, cornptA) tempo = ThisDrawing.ModelSpace.AddRegion(lineA) cutu(u) = tempo lineA(0).Visible = False lineA(1).Visible = False lineA(2).Visible = False lineA(3).Visible = False tempv(v)(0).Boolean acSubtraction, cutu(u)(0) Next v Next u Dim cutv(VER) As Variant For u = 0 To HOR For v = 0 To VER cornptA(0) = nodes(u, v).pos(0) cornptA(1) = nodes(u, v).pos(1) + thick / 2 + 0.02 cornptA(2) = nodes(u, v).pos(2) - height / 2


cornptB(0) = nodes(u, v).pos(0) cornptB(1) = nodes(u, v).pos(1) - thick / 2 + 0.02 cornptB(2) = nodes(u, v).pos(2) - height / 2 cornptC(0) = nodes(u, v).pos(0) cornptC(1) = nodes(u, v).pos(1) - thick / 2 + 0.02 cornptC(2) = nodes(u, v).pos(2) - height * 1.5 cornptD(0) = nodes(u, v).pos(0) cornptD(1) = nodes(u, v).pos(1) + thick / 2 + 0.02 cornptD(2) = nodes(u, v).pos(2) - height * 1.5

On Error Resume Next Set lineA(0) = ThisDrawing.ModelSpace.AddLine(cornptA, cornptB) Set lineA(1) = ThisDrawing.ModelSpace.AddLine(cornptB, cornptC) Set lineA(2) = ThisDrawing.ModelSpace.AddLine(cornptC, cornptD) Set lineA(3) = ThisDrawing.ModelSpace.AddLine(cornptD, cornptA) tempo = ThisDrawing.ModelSpace.AddRegion(lineA) cutu(v) = tempo lineA(0).Visible = False lineA(1).Visible = False lineA(2).Visible = False lineA(3).Visible = False

tempu(u)(0).Boolean acSubtraction, cutu(v)(0) Next v Next u

positioning tempu, tempv, cordu(), cordv()


cornptB(0) = nodes(u, v).pos(0) cornptB(1) = nodes(u, v).pos(1) - thick / 2 + 0.02 cornptB(2) = nodes(u, v).pos(2) - height / 2 cornptC(0) = nodes(u, v).pos(0) cornptC(1) = nodes(u, v).pos(1) - thick / 2 + 0.02 cornptC(2) = nodes(u, v).pos(2) - height * 1.5 cornptD(0) = nodes(u, v).pos(0) cornptD(1) = nodes(u, v).pos(1) + thick / 2 + 0.02 cornptD(2) = nodes(u, v).pos(2) - height * 1.5

On Error Resume Next Set lineA(0) = ThisDrawing.ModelSpace.AddLine(cornptA, cornptB) Set lineA(1) = ThisDrawing.ModelSpace.AddLine(cornptB, cornptC) Set lineA(2) = ThisDrawing.ModelSpace.AddLine(cornptC, cornptD) Set lineA(3) = ThisDrawing.ModelSpace.AddLine(cornptD, cornptA) tempo = ThisDrawing.ModelSpace.AddRegion(lineA) cutu(v) = tempo lineA(0).Visible = False lineA(1).Visible = False lineA(2).Visible = False lineA(3).Visible = False

tempu(u)(0).Boolean acSubtraction, cutu(v)(0) Next v Next u

positioning tempu, tempv, cordu(), cordv() End Sub


Sub positioning(tempu() As Variant, tempv() As Variant, cordu() As AcadSpline, cordv() As AcadSpline) Dim insertptu(2) As Double, insertptv(2) As Double, axisptu(2) As Double, axisptv(2) As Double, textpt(2) As Double Dim rib(HOR) As Variant Dim ribs(VER) As Variant Dim label As AcadText Dim no As String insertptu(0) = VER * 2 + 10 insertptu(1) = 0 insertptu(2) = 0 insertptv(0) = 0 insertptv(1) = VER * 2 + 10 insertptv(2) = 0 ang = 90 * 3.14 / 180 ango = 270 * 3.14 / 180 For u = 0 To HOR insertptu(0) = insertptu(0) + 5 axisptu(0) = insertptu(0) axisptu(1) = insertptu(1) + 100 textpt(0) = insertptu(0) - 0.8 textpt(1) = insertptu(1) + 0.2 Set rib(u) = tempu(u)(0).copy rib(u).Move cordu(u).GetFitPoint(0), insertptu rib(u).Rotate3D insertptu, axisptu, ang no = u Set label = ThisDrawing.ModelSpace.AddText(no, textpt, 0.3) Next u ZoomExtents For v = 0 To VER insertptv(1) = insertptv(1) + 5 insertptv(2) = 0 axisptv(0) = insertptv(0) - 100


axisptv(1) = insertptv(1) axisptv(2) = 0 textpt(0) = insertptv(0) + 0.4 textpt(1) = insertptv(1) - 0.8 Set ribs(v) = tempv(v)(0).copy ribs(v).Move cordv(v).GetFitPoint(0), insertptv ribs(v).Rotate3D axisptv, insertptv, ango no = v Set label = ThisDrawing.ModelSpace.AddText(no, textpt, 0.3) ZoomExtents Next v ZoomExtents End Sub Public Function howmany(what As Integer) As Integer Dim message As Variant, title As Variant, default As Variant Select Case what Case 0 message = “specify horizontal dimension (u)” title = “udim” default = “10” Case 1 message = “specify horizontal dimension (v)” title = “vdim” default = “10” Case 2 message = “specify the thickness of the material” title = “thick” default = “.2” End Select ‘ Display message, title, and default value. howmany = InputBox(message, title, default)



Week 10 Selection Sets & Vectors Selection Sets In AutoCad there are two different ways of collecting objects - into collections and into selection sets. We will concentrate on selection sets. As the name suggests, a selection set is a set of specified objects that you selected. In other words it is a way to filter objects by type, length etc - an automized way of how you would do it with a mouse in model space. Before one can select anything from the drawing and store that selection into a set, one must declare and dimension a selection set like any other variable: Dim ss As AcadSelectionSet After declaring it, as usual it has to be instantiated into the drawing database with its name: Set ss = ThisDrawing.SelectionSets.add(“it”)

‘SS is selection set

Now we can begin using the SelectionSet, there are 4 ways to use the SelectionSet with two being the most common (ss.select & ss.selectbypolygon).Each methods requires given parameters as arguments that will define the selection mode. We will use the acSelectionSetAll mode, which can be given some filtering parameters. We use the third (group code) and fourth (type code): ss.Select acSelectionSetAll, , , gp, dv The full filter lists for SelectionSets can be viewed through the developer documentation within AutoCAD DXF Codes for Common Filter Types 0

Object Type (string) e.g. ‘circle’

8

Layer Name (string) e.g Layer0

60

Object visiability (integer) e.g. Visable = 0 , Invisiable = 1

There are many dxf codes for filter types - these are just some of the more common.


Vectors

End/Start

ne

A vector is a geometric description of direction and magnitude (length), it is not a position or location but can be represent a quantity of x,y,z co-ordinates. Vectors are typically expressed as numbers and arranged in columns.

End/Start

To finnd the direction and express it as a vector from point A to point B, the starting point of the vector have to be subtracted from the end point of the vector e.g. Redefine B 3,4

P2

3 P3

A 2,1

1

point A = (2,1) point B = (3,4) vector v = 3 - 2 = 1 4-1=4 That means that to get from point A to point B - the direction from point A to point B - you have to ‘travel’ 3 unit along the X-axis and 4 units along the Y-axis. The same method is valid also in three dimensions. The direction of the vector can be translated from axes quantities into simple radians (in two dimensions) via the equation: radians_angle = Atn(y / x) Don’t forget that in the second and third quadrant (x < 0), one has to adapt the angle by adding Pi to the radians: radians_angle = PI + radians_angle To translate radians to degrees: radians_angle * (180 / Pi) To translate degrees to radians: degrees_angle * (Pi/180)


To find out the magnitude or length of the vector (here it would be the distance between point A and point B), one has to simply use Pythagoras’ distance equation length = Sqr( x2 + y2 ) (length = Sqr(-3 * -3 + 4 * 4) = Sqr(9 + 16) = 5) Normalise & Scale When the direction of a vector is important sometimes the orientation and size of the vector can complicate calculations so we reduce the length of the vector to radius 1 of a sphere. When reducing the length of a vector to standard radius 1, it’s called ‘normalizing’ the vector. A normalized vector with length 1 is called the unit vector. In order to calculate all one has to doEnd/Start is to divide each dimension Start the unit vector, End/Start of the vector by the length. If we take the above example we get: Redefine

Redefine

unit.x = v.x / length ( -3 / 5 = -0.6) unit.y = v.y / length ( 4 / 5 = 0.8)

B

In order to travel along a direction at specific lengths one has to start at3,4some point, P2 P1 add the axes quantities and scale the quantities by a desired length.We have done so for inserting points along the wall line: N

For i = 0 To DIVISION

3 P3

wall.pos(i).vec.x = startpoint.x + direction.x * ( i * SPACING)A P4

2,1

wall.pos(i).vec.x = startpoint.x + direction.x * ( i * SPACING) Set test = ThisDrawing.ModelSpace.AddCircle(wall.pos(i).vec, 1) Next

y = 0.8

r=1 x = 0.6

1


Perforated Wall This weeks exercise is based on an existing condition - an area plan - consisting of a wall and three obsticles which sheild the wall from certain view points - this condition can be quite easily altered or adjusted - but we see how VBA can interact with pre-existing scenarios in AutoCAD rather than starting afresh each time. We use the vector and selectionset operations previously discussed this week and a boolean operation to create X number of voids within a solid wall. Boolean operations are based on the mathematics of sets invented by British mathematitian Georg Boole around 1800. There are three 3DSolid boolean operations in AutoCad Union Subtraction Intersection The boolean operations on 3D solids are unique in AutoCad and we use them to cut out the viewing volumes from the walls, and to measure the volume quantity of the intersecting volumes. There are 3 viewing points in the basic code - and the more of the wall they can ‘see’ or the more times different vectors touch a given area then the larger the subtraction from that area will become. Functions such as this can and have been used in Urban Design by practices such as Space Syntax, Aedas, Foster & Partners - the use of sightlines can help determine the connectivity of an area - but this can lead to a more analytical analysis of the area rather than forming space or form which we are doing here.


Option Explicit Sub main() set_up 0 check_views “context” perforate 0 ‘output_xcl wall ThisDrawing.Regen acAllViewports End Sub Sub check_views(layername As String) Dim i As Integer, t As Integer, c As Integer Dim ft(1) As Integer Dim fv(1) As Variant Dim fpts(5) As Double ‘---is for fence points Dim ss As AcadSelectionSet Dim test As AcadLine sel_set_del 0 Set ss = ThisDrawing.SelectionSets.add(“checker”) ft(0) = 0 fv(0) = “3DSolid” ft(1) = 8 fv(1) = layername For c = 0 To UBound(wall) For i = 0 To UBound(wall(c).pos) With wall(c) For t = 0 To UBound(targets) fpts(0) = .pos(i).vec(0) fpts(1) = .pos(i).vec(1) fpts(3) = targets(t).vec(0) fpts(4) = targets(t).vec(1) ss.SelectByPolygon acSelectionSetFence, fpts, ft, fv If (ss.Count = 0) Then .hit(i) = .hit(i) + 1 ‘--- just a simple counter thta counts how many times the certain point has been hit ‘--- draw fence line


Set test = ThisDrawing.ModelSpace.AddLine(.pos(i).vec, targets(t).vec) test.Update .rot(i) = .rot(i) + test.angle End If ss.Clear

‘just clear out the set, don’t delete it or its contents

Next t End With Next i Next c ss.Delete End Sub Sub perforate(token As Integer) Dim i As Integer, maxTargets As Integer, c As Integer Dim skalar As Double, ang As Double Dim cutter As Acad3DSolid, res As Acad3DSolid, temp As Acad3DSolid For c = 0 To UBound(wall) maxTargets = UBound(targets) + 1 For i = 0 To UBound(wall(c).pos) If (wall(c).hit(i) > 0) Then ang = wall(c).rot(i) / wall(c).hit(i) skalar = IIf(wall(c).hit(i) < maxTargets, SPACING * (wall(c).hit(i) / maxTargets), SPACING) Set cutter = ThisDrawing.ModelSpace.AddBox(wall(c).pos(i).vec, WALL_ DEPTH, skalar, SLOT_HEIGHT) cutter.Rotate cutter.Centroid, ang ‘--- make substitute objects for volume count Set res = wall(c).body.Copy Set temp = cutter.Copy res.Boolean acIntersection, temp wall(c).volume(i) = res.volume res.Delete ‘--- boolean subtract the window from wall


‘--- boolean subtract the window from wall wall(c).body.Boolean acSubtraction, cutter End If Next i Next c End Sub



This book presents the exploration of architectural computing within the computing module of the PG Dip (RIBA II) course at the University of East London. The book catalogues the use of digital modeling programs (AutoCAD & NetLOGO) combined with the use of VBA coding to conceive new forms, digital techniques and develope created. systems through which architecture can be created The book is to be read as a pre-cursor to the Thousand Plateaus project which has been developed as the result of the module itself. (cover image 2d Diffusion)


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.