The GDL cookbook
Subtitle: teach yourself GDL by the cookbook method and 'ArchiCAD tips and tricks'
By: by David Nicholson-Cole.
Publisher: Marmalade Graphics
Published: 1998
Place of publication: Nottingham
Language: eng
Subjects: Geometric programming.; Computer-aided design.
Description: ARCHICAD internal 3d object cookbook of GDL - Graphical description language. Describes how to addapt a make your own object. A must for Generated architecture
Notes: TABLE OF CONTENTS
1. Introduction.................................................................................................................... 1
2. Anatomy of a GDL Object ............................................................................................. 5
What is a GDL Object? .................................................................................................................................. 5
Creating an Object........................................................................................................................................... 7
Open an Existing Object for Editing ............................................................................................................ 9
Placeable Objects............................................................................................................................................11
Object Subtype ...............................................................................................................................................12
Parameters .......................................................................................................................................................14
Subtypes, Parameters and Template Objects ............................................................................................17
Object Details .................................................................................................................................................20
The GDL Scripts............................................................................................................................................21
Preview Window............................................................................................................................................25
Drawing Fragments .......................................................................................................................................25
2D Symbol.......................................................................................................................................................26
2D Full View...................................................................................................................................................26
3D View ...........................................................................................................................................................27
Preview Picture...............................................................................................................................................27
3. Variables .........................................................................................................................29
Assigning a Value to a Variable ....................................................................................................................30
Naming Variables...........................................................................................................................................32
Variable Type..................................................................................................................................................33
Array and Vector Variables ...........................................................................................................................35
Scope.................................................................................................................................................................38
4. Operators and Expressions ...........................................................................................41
The Equals Operator.....................................................................................................................................42
The Inequality Operator ...............................................................................................................................43
Order of Operations......................................................................................................................................44
Using Brackets to Control the Order of Operation ................................................................................45
Logical Operators...........................................................................................................................................46
Bit Operators ..................................................................................................................................................48
5. Working with Text Strings ..........................................................................................51
Number of Characters in a String................................................................................................................52
Searching for a Text within a String............................................................................................................52
Reading Part of a String ................................................................................................................................53
Substituting Text ...........................................................................................................................................53
ii
Displaying Numeric Data as a String ..........................................................................................................54
Displaying the Current Date and Time as a String..................................................................................58
Extracting Numeric Data from a String .....................................................................................................60
6. Using the Stack ............................................................................................................. 63
Using Put and Get to Simplify Scripts........................................................................................................64
The Use Function ..........................................................................................................................................67
Clearing the Stack ..........................................................................................................................................67
Put and Get Data within a Block.................................................................................................................67
When to Use the Stack .................................................................................................................................68
7. Loops............................................................................................................................. 69
The ‘for–next’ Loop ......................................................................................................................................69
The repeat – until and while – endwhile Loops .......................................................................................72
Infinite Loops..................................................................................................................................................74
Practically Infinite Loops..............................................................................................................................78
8. Scripting Style ............................................................................................................... 83
Write Readable Code....................................................................................................................................84
Structured Scripting ......................................................................................................................................90
Managing Transformations ..........................................................................................................................92
Legible vs. Efficient ........................................................................................................................................92
9. Macros & Sub-Routines ............................................................................................... 95
Macros ..............................................................................................................................................................96
Sub-Routines.................................................................................................................................................106
Re-Usable Sub-Routines.............................................................................................................................108
Macros or Sub-Routines?............................................................................................................................112
10. The 2D Symbol ........................................................................................................... 117
2D Transformations....................................................................................................................................118
Attributes.......................................................................................................................................................120
The 2D Symbol Drawing Window...........................................................................................................121
2D Line Segments ........................................................................................................................................126
2D Circles and Arcs.....................................................................................................................................127
Ellipses ............................................................................................................................................................130
2D Splines......................................................................................................................................................131
2D Fill Polygons ...........................................................................................................................................132
Drawindex .....................................................................................................................................................145
11. The 3D Model............................................................................................................. 147
General Controls..........................................................................................................................................148
iii
3D Transformations....................................................................................................................................150
Basic 3D Elements .......................................................................................................................................152
3D Polygons and Planes..............................................................................................................................157
Prisms, Slabs and Extrusions......................................................................................................................159
Revolved Forms ............................................................................................................................................167
Tubes ..............................................................................................................................................................171
12. Groups & Solid Element Operations ........................................................................175
Solid Element Operations ...........................................................................................................................176
Defining a Group of Elements ...................................................................................................................178
Placing a Group ............................................................................................................................................179
Nested Groups..............................................................................................................................................179
Group Operations........................................................................................................................................180
13. Text ...............................................................................................................................183
Selecting a Font and Script Type ...............................................................................................................184
Smarter Font and Script Type Selection ..................................................................................................186
Defining a Text Style...................................................................................................................................195
Text Size.........................................................................................................................................................197
Placing a Single Line of Text.......................................................................................................................198
Defining a Paragraph...................................................................................................................................200
Using Paragraphs..........................................................................................................................................205
Text Orientation..........................................................................................................................................207
Text in 3D .....................................................................................................................................................210
14. Working with Graphics ..............................................................................................213
Creating an Image with Transparency......................................................................................................214
Images for the Object Settings Dialog ......................................................................................................216
15. User Interface...............................................................................................................221
Selection and Referencing ...........................................................................................................................222
Graphic Editing ............................................................................................................................................225
The Custom Settings Palette......................................................................................................................232
Images in the User Interface Palette..........................................................................................................237
Outfields ........................................................................................................................................................237
Basic Infields..................................................................................................................................................238
Values Lists & Graphic Infields..................................................................................................................241
Buttons...........................................................................................................................................................242
Tool Tips .......................................................................................................................................................244
Organizing Data...........................................................................................................................................244
iv
Interactive Parameters.................................................................................................................................248
Working with Selections of Multiple Objects ........................................................................................249
Language ........................................................................................................................................................249
16. Approximating Curves............................................................................................... 253
Circular Arcs .................................................................................................................................................254
Ellipses ............................................................................................................................................................256
Helices ............................................................................................................................................................257
Bezier Splines ................................................................................................................................................259
Traditional Cubic Splines ...........................................................................................................................266
17. Linear Algebra 101 ..................................................................................................... 279
Scalars and Vectors.......................................................................................................................................280
Vector Components ....................................................................................................................................281
Vector Notation ...........................................................................................................................................282
Vector Diagrams...........................................................................................................................................283
Length of a Vector........................................................................................................................................283
Equivalent Vectors.......................................................................................................................................284
Adding Vectors .............................................................................................................................................284
Scalar Multiplication ...................................................................................................................................286
Unit and Zero Vectors ................................................................................................................................287
Cross Product ...............................................................................................................................................289
Perpendicular Vector in 2D........................................................................................................................293
Dot Product ..................................................................................................................................................293
Equation of a Line........................................................................................................................................295
Equation of a Plane ......................................................................................................................................295
18. Linear Algebra Applications...................................................................................... 297
Does a Point Lie on a Line Segment?........................................................................................................298
Parallel Lines .................................................................................................................................................302
Intersection of Two Lines in 2D................................................................................................................305
Intersection of Line Segments ....................................................................................................................308
Intersection of a Line Segment and an Arc in 2D ..................................................................................310
Calculating an Angle ...................................................................................................................................317
Intersection of 2 Arcs ..................................................................................................................................319
Equation of a 2D Arc through 3 Points ...................................................................................................322
Closest Point on a Line ...............................................................................................................................328
Closest Point on a Line Segment ...............................................................................................................331
Distance between a Point and a Line ........................................................................................................334
Distance between Two Lines......................................................................................................................335
v
Find the Points of Closest Approach........................................................................................................338
Distance between a Point and a Plane ......................................................................................................341
Closest Point on a Plane ..............................................................................................................................341
Intersection of a Line and a Plane..............................................................................................................341
19. Matrix Transformations .............................................................................................343
Elementary Transformation Matrices ......................................................................................................343
Matrix Multiplication .................................................................................................................................346
Multiple Transformations..........................................................................................................................348
Translations...................................................................................................................................................349
The xform Command.................................................................................................................................349
Calculating Natural Co-ordinates.............................................................................................................351
20. Freeform 3D Modeling ...............................................................................................353
Cardboard Cut-Outs...................................................................................................................................358
Basic Texture Mapping...............................................................................................................................367
3D Modeling.................................................................................................................................................371
Freeform Modeling......................................................................................................................................378
Advanced Texture Mapping.......................................................................................................................387
Randomizing Objects..................................................................................................................................392
Trouble Shooting.........................................................................................................................................394
21. Polygon Operations.....................................................................................................395
Defining a Polygon ......................................................................................................................................396
Polygon Area .................................................................................................................................................397
Polygon Sense................................................................................................................................................399
Check if a Point Lies Inside a Polygon......................................................................................................400
Polygon Addition.........................................................................................................................................403
Intersection of Two Polygons.....................................................................................................................413
Subtract One Polygon from Another .......................................................................................................415
Offset a Polygon ...........................................................................................................................................417
Closest Point on a Polygon .........................................................................................................................422
Center of Gravity .........................................................................................................................................423
Optimizing the Polygon Operations.........................................................................................................425
22. Optimizing for Speed..................................................................................................427
Speed Testing................................................................................................................................................428
Use Efficient Algorithms............................................................................................................................429
Calculate Only when Required..................................................................................................................431
Reduce the Polygon Count .........................................................................................................................432
v i
Provide Optional Data................................................................................................................................438
Use Group Operations Sparingly...............................................................................................................438
23. Quality Control .......................................................................................................... 439
Scripting Style ...............................................................................................................................................440
Testing............................................................................................................................................................443
Fixing Issues...................................................................................................................................................445
24. Development Strategies ............................................................................................. 447
A Model for Development ..........................................................................................................................448
Opportunity ..................................................................................................................................................451
Some Thoughts on Planning and Design.................................................................................................455
Improving the Resource Pool .....................................................................................................................460
Implementation............................................................................................................................................462
Testing............................................................................................................................................................462
Maintenance..................................................................................................................................................463
Appendices ............................................................................................................................... 464
A1: Barrel Bridge Example ..........................................................................................................................464
A2: Playground Swing Example .................................................................................................................468
A3: Boat & Trailer Example .......................................................................................................................488
Table of contents: class: section