Cookbook3_1

311
by David Nicholson-Cole and guests The GDL Cookbook Version 3 Teach yourself GDL by the Cookbook method & ‘ArchiCAD Tips and Tricks’

Transcript of Cookbook3_1

Page 1: Cookbook3_1

by David Nicholson-Cole

and guests

The GDL

Cookbook

Version 3

Teach yourself GDL

by the Cookbook method

&

‘ArchiCAD Tips and Tricks’

Page 2: Cookbook3_1

The GDL

Cookbook 3

The SOURCE of all that is good in GDL

• and •

ArchiCAD Tips and Tricks

by David Nicholson-Cole

with guest contributions

Page 3: Cookbook3_1

The GDL Cookbook 3

ALL rights reserved. Printed in the United Kingdom ofGreat Britain. No part of this book, or the software with

it, may be copied or reproduced in any form, or by any means,or stored in a database or retrieval system, without prior per-mission of the publisher, except in the case of brief quota-tions embodied in critical articles or reviews. Making copiesof any part of this book for any purpose other than yourown use is a violation of UK copyright laws.

Cookbook Website> http://www.nottingham.ac.uk/sbe/cookbook/with additional material on http://www.innotts.co.uk/exmicro/

The GDL Cookbook is distributed through Graphisoft and ArchiCAD dealers,through the Internet and by word of mouth.

• ISBN 0 9535216 0 5 •

First published March 98; Version 2.0 June 1999; Version 2.1 February 2000;Version 3.0 December 2000

This edition: Cookbook 3.01 May 2001Text printed by Alpha Graphics, Angel Row, Nottingham, England, covers by Adlard Print.

Set in Britannica, Garamond and Frutiger, using Adobe Pagemaker on a Macintosh G3

The GDL Cookbook is available in chunks, as a series of web based supplements,Cookbook X-Tracts. Please look at the Cookbook website for further information.

The GDL Cookbook was largely written by David Nicholson-Cole GDLA, but for thisedition, he has brought in contributions from expert friends. This team effort hasadded a richer variety and a visibly elevated level of expertise to the content. In

particular, Dwight Atkinson MAIBC of Vancouver, Canada has been most helpful as atechnical proofreader, and Laurent Godel GDLA has made a substantial contribution..

THIS book and the software included on disk is sold as is,without warranty of any kind, either expressed or im-

plied. While every precaution has been taken in the prepa-ration of this book, the Author and the Publisher assume noresponsibility for errors or omissions. Neither is any liabilityaccepted for damages resulting from the use of the informa-tion or instructions contained herein.

All terms used in this book that are known to be trade-marks have been capitalised.

Key to Illustrations:Front cover and interleaves: Staircase at 9 Sloane St by Eva Jiricna, model byCathy Wood (University of Nottingham 1998), one of DNC’s students.

Front cover: The Tower crane, July 2000, by David Nicholson-Cole

Front cover and interleaves: Design idea for Railway station, Stuart Buckenham,Stuart Winter, Andy Hitchcock, David Nicholson-Cole.

Inside front cover: Pinero structure for a Railway Station, by David Nicholson-Cole.

The GDL Cookbook 3, the SOURCE of all that is good in GDL, is published byMarmalade Graphics, Nottingham ©1998, 1999, 2000

Marmalade Graphics, 15 Elmtree Ave, West Bridgford, Nottingham NG2 7JU, England

International Tel +44-115-945-5077 : Fax +44-115-945-5121:UK Tel 0115-945-5077 : Fax 0115-945-5121:

email: [email protected] / [email protected]/ [email protected]

"The sea is dangerous and its storms terrible, but these obstacles have never been sufficient reasonto remain ashore... Unlike the mediocre, intrepid spirits seek victory over those things that seemimpossible... it is with an iron will that they embark on the most daring of all endeavours... to meetthe shadowy future without fear and conquer the unknown."

Ferdinand Magellan, Explorer (c.1520)

Page 4: Cookbook3_1

The GDL Cookbook 3

What is GDL?

GEOMETRIC Description Language (GDL) is ArchiCAD’sbuilt in scripting language for object making.

GDL scripting in a nutshell...

GDL uses a variety of written commands likeBLOCK, EXTRUDE and TUBE. Combining these

in GDL, you can built up 2D and 3D objects whichcan be used in ArchiCAD as Library Parts.

• Because GDL includes Cylinders, Cones, Prisms,Tubes, Surfaces and much more, you can makeObjects that cannot be made with wall+slab tools.

• Because you can use variables like X and Y, youcan make the objects change their parameters – theycan be Parametric.

• Because you can write IF Statements, you can makethe objects obey rules – they can be Smart.

• Because you can build in Repetitive Loops, you cango beyond object making – and make Tools.

• Because you can rotate and move elements, youcan make Mechanisms.

What can you do with GDL?

WITH GDL, you can build structural elementsthat look right for their purpose, elements of

detail that make a building model look authentic,furniture that is smart and elegant, lights that let youturn them on and tune their luminance, windows thatcan open or swivel, doors that can change their panelstyles, stairs that offer a choice of landing and hand-rail styles, picture objects on which you can plasterbuilding elevations and thus build whole street scenes,2D drawing tools that can enhance our productivity– and much more besides.

• Let’s learn something of this power!

Could you learn GDL?

ALL major CAD packages have an internal scriptinglanguage. It is most fortunate for ArchiCAD users

that GDL grew out of BASIC, the most popular andwidely taught programming language of the eighties,thus making it accessible to all users, not just to peo-ple with a degree in Computer Science. With a fewhours of exploration into GDL, the total beginner canmake something surprisingly useful, indeed powerful.For the more experienced user, GDL has a depth thatnever ceases to turn up interesting new techniques andpossibilities.

• Now that you have this book you have the key!

Who is GDL really useful for?

THE normal ArchiCAD user can use GDL toenhance the quality of their models, improve their

productivity, and to further their personal skills base.

The component manufacturer can see GDL as away of providing components and tools that will en-courage ArchiCAD users to specify their products. Theengineer can see GDL as a means of providing build-ing components that can display levels of intelligenceand adaptability. The would-be GDL developer canfind enough in GDL to grasp career enhancing oppor-tunities. The university student can find a way toextend all that maths learned at college and add valueto their architectural portfolio. The ArchiCAD resellerhas the means to prove to potential customers thatArchiCAD carries a significant power advantage.

Who supports the GDL user?

THE worldwide culture of GDL is assisted byGraphisoft itself by providing a reliable product

in the stable and growing environment of ArchiCAD;by the efforts of organisations like the GDL Alliance(a network of GDL developers supporting the cultureof GDL and promoting the professionalisation of GDL);GDL Technology Inc (created 2001 to promote GDLto furniture and component manufacturers); Objectson Line, and www.add-onstore.com (Internetstorefronts enabling download of objects); a numberof enlightened ArchiCAD dealers who are willing tofoster the wider use of GDL; the users of ArchiCAD-Talk (Internet conference on all ArchiCAD matters) andof GDLTalk (a similar Internet conference on GDL mat-ters); by the OMWAC beginners book (Object Makingwith ArchiCAD); by the GDL Cookbook; and finallyby Graphisoft’s own Technical Standards publica-tion.

Where is GDL going to?

GDL is now becoming a major language of 3D form.Graphisoft’s Object Initiative is a drive to promote

GDL technology. GDL objects can be used in AutoCADas well as ArchiCAD, and manufacturers are being en-couraged to think of GDL as a new way to distributeCAD images of their products. DXF may be universal,but it’s dumb and obese, and manufacturers’ productranges need to be converted to GDL.

Until 2000, GDL was largely enjoyed by ‘inspiredamateurs’, architects who dabbled with GDL to com-plete their projects on time and elegantly; for that, GDLonly had to be good enough for the day. Now, a moreserious approach needs to be taken. GDL could betaken up by a new breed of of technical specialists whowork to a high standard. There is a huge amount ofwork available in the next few years for people pre-pared to adapt all these libraries to GDL. Go for it!

Page 5: Cookbook3_1

The GDL Cookbook 3

THE GDL Cookbook is a collection of models which have been produced to help teach GDL. Eachone is accompanied by explanatory text and images. Sections on Theory and Technique fill out thespace between. The CD also contains most of the examples, and a few other files which contribute tothe learning experience of GDL. The models are sequenced to give a ‘Cookbook’ style of progressivelearning. GDL can be fun, as well as being useful in your career.

The GDL Cookbook 3The SOURCE of all that is good in GDL

Difficulty Level? Try OMWAC!

THIS book is quite ‘pacey’. You need to move fastand determinedly through it. The beginner’s pages

do not last long before you are into more challengingterritory. If you find the pace too hot, do not worry.Put the book on the shelf and spend some time withthe junior book on GDL, Object Making with Archi-CAD (hereafter called ‘OMWAC’), written by the sameauthor and published by Graphisoft, and targeted atGDL beginners. Just as the Cookbook is designed tomake the GDL Reference manual easier, the OMWACis designed to make the GDL Cookbook easier. It willbring you safely into the foothills of GDL. After thatyou will find the GDL Cookbook easier to work with.

This edition

THE design environment is constantly changing –no sooner had the original GDL Cookbook settled

down to a level of completion in 1998 than I was hav-ing to adjust to ArchiCAD 6.0 at the end of 1998. At theend of 1999, ArchiCAD 6.5 appeared! As each freshrelease of ArchiCAD is expected, the Cookbook has toadapt. This is why I operate a generous upgrade policy.Whenever you find that ArchiCAD or the GDL Cook-book has moved on a step or two, you can have a re-placement Cookbook for a concessionary price, onlyfrom the publisher.

How does this edition vary from the previous? TheCookbook has always been evolutionary. At any pointin time, the Cookbook of the time has always beenadequate to kick start your GDL knowledge.

This edition is built on the 2.10 edition of Feb 2000.CB2 had become congested with my attempts to keepthe airmail weight as low as possible and to keep sin-gle topics to exact numbers of pages. Fonts were toosmall, illustrations overlapped in places, and anychance of translation was out as just about every otherlanguage requires more space than English.

Graphisoft recognised the Cookbook 2 as a targetsolution in the centre of the GDL education processand commissioned OMWAC in April 2000. They pub-lished their own document at the professional level.Now, for the Cookbook, it’s time to blow out the pagi-nation with fresh white space and larger fonts, to makeit more of a compendium at the centre of GDL. Somerewriting and additions are inevitably provided, bring-ing it up to the title of Cookbook 3. I hope you agreethat it deserves that title.

The Cookbook Idea

THE original GDL manual is good but it has too fewexamples and explanations. It is dry and humour-

less. This ‘Cookbook’ approach to learning is designedto change what seems like a daunting task into some-thing enjoyable and useful.

This book is not intended to rewrite the manual,nor to repeat the GDL textbook from Graphisoft, pub-lished in 1997. All of these have their place and areuseful. Always have the GDL reference manual handywhile you work, and please use the ‘Helpmenus’ whenin ArchiCAD.

The metaphor of ‘Cookbook’ suggests that you willlearn some GDL in a few days. This is quite true if youwork through the starting exercises. This is also truethe first time you pick up a guitar and have a few basiclessons. However, you will require much longer thanthat, and need to try some real projects, to acquire pro-ficiency to the level of a GDL Voyager.

Smart Parametric Models

YOU are truly privileged. You are the only mem-bers of the CAD community who have the ability

to build PARAMETRIC objects without needing a de-gree in Computer Science. Quite simply, ‘Parametric’means that you can change the parameters of an ob-ject. With GDL, it also means that the object can be‘smart’ – change its own characteristics according torules or calculations. Thus it can display a level of ‘ar-tificial intelligence’. This is the power of GDL!

In other CAD software, if you stretch an object, itwill stretch, but the elements of the object will be dis-torted proportionally. Whereas, with a parametricallybuilt window, handrail, stair or structural truss tool, itcan be written to recalculate the spacing of members,to resize members if necessary, correct user’s errors,offer the user intelligent choices through pop-downmenus in the object, and change the way it looks atdifferent scales or distances. All these techniques arecovered in the GDL Cookbook.

Tips and Tricks

THE Tips and Tricks sections of this book are notjust about GDL. They are designed to make your

whole use of ArchiCAD more fulfilling and produc-tive. Many of them are contributed by experts fromaround the world. Please Enjoy!

Page 6: Cookbook3_1

The GDL Cookbook 3

Reasons why you need not learn GDL

• You can already make library objects using theWall, Slab and Roof tools.

• You are contented to manage with the existingArchiCAD library.

• You can purchase CDs of more objects.

• You can pay a bureau to make 3D objects whenthe need arises.

• A lot of the work you do is 2D and doesn't need3D modelling.

sition in the model, storey, or camera locationchanges. They can even consider whether to botherdrawing themselves or not.

• You can do a useful clean-up job on objects cre-ated with wall, roof and slab tools, if you know a bitof GDL.

• You can increase or decrease the level of detail ina model by being firmly in control of the number ofpolygons.

• It’s fun, and easy once you get the hang of it. It isenjoyable to use simple mathematics and program-ming skills to see 3D forms popping out of the screenin front of your eyes!

• With GDL, you have the opportunity to develop aniche skill that will put you ahead of others in yourfield, and could open the way to new career oppor-tunities now that Graphisoft have ‘liberated’ GDL bymaking GDL objects usable in other CAD environ-ments.

Clearly, the reasons to use GDLfar outnumber the reasons not

to (:-)

Reasons why you should learn GDL

• It looks difficult – the GDL manual makes youshudder, just looking at it.

• You think you can't remember trigonometry orgeometry, and you think you cannot program.

• None of the objects you make need to be 'smart'or elegant, or be repeated (surely not?)

• You can make insanely great things that, for inter-est and complexity, go far beyond library objectsmade with wall, roof and slab tools.

• You can make ‘tools’ – such as a joist tool, louvretool or a handrail tool – that increase your productiv-ity.

• You can make parametric models – i.e. an objectthat offers you a dialog box with the means of chang-ing its height, diameter, colour, frequency, style, etc.

• It is very economical in disk space – GDL modelsonly occupy the disk size of a script plus a smallheader and footer.

• You speed up rendering time; objects can be writ-ten with clean coding, unlike the dirty code producedby DXF or library objects made with wall, roof andslab, which needlessly calculate forms to one mil-lionth of a metre accuracy.

• You can have really cool features like modestlyintelligent objects that complain if you enter wrongparameters; that offer you options in the language ofyour choice; offer you popdown menus to assist youwith choosing parameters; dynamically turn to facethe camera; can change colour or shape as their po-

GDL is an investment

I often hear from people who have bought the GDLCookbook that they “haven’t had time to get going

with it yet”. This is a matter of organising your time,taking a long term view. The time you spend now isan investment in your future; the time you spend onan object could also ensure that the object has a greatfuture.

Ask yourself if the object you want to make is to beused more than once, if it could be useful in otherprojects. You might be the one person in the officemaking objects for other people, and therefore youneed to make the object usable by others. If you makeit parametric and smart, it might take you longer tomake an object that could more quickly be made with

the slab, wall and roof tools. But if the object has ver-satility and can be applied to many more projects forever after, the time taken to make the object well is agood investment and your users will be grateful forthe effort. Objects made with the Toolbox are no longereditable if the original floor plan file that made themhas been lost.

A piece of GDL that is well written can be extendedand made more powerful when your own knowledgeof GDL improves or when a new edition of ArchiCADoffers more features. A well written object could betaken on by someone else in the office, years after youhave left, and improved to take advantage of the fea-tures in a future version of ArchiCAD.

Page 7: Cookbook3_1

The GDL Cookbook 3

You’ve read the book, nowtell me what you think:• I found the GDL Cookbook an excellent support for GDLobject generation in ArchiCAD. The style of your book isreally refreshing and informative. Its personal touch helpsin learning GDL in an entertaining way. I fully recommendthe GDL Cookbook to any ArchiCAD user who wants to ac-cess the full power of object parametrics in their designs.Andras Haidekker, CEO GDL Technology Inc, Dec’98• The more I write, the more I’m addicted to it – GDL is sogreat! Again, I cannot thankyou enough for teaching usGDL. Chee Horng Chang, architect, Leeds• Today I actually created an object with embedded textscaling related to drawing scale for a client. Paid off theCookbook in just one exercise. Thankyou. Also, gratitudefor the squiffle line idea. Fabulous! Dwight Atkinson, Canada• I LOVE THE COOKBOOK!!!! I think you've done a greatjob! Greg Richmond, Dallas• Great book, v. exciting because it at least gets you doingthings! So far, can’t put it down – has made me keen tolearn more – Kevin Hayes, Brisbane, Australia• I’m wading through the Cookbook and am (oh-so) slowlygetting it for the first time in ten years of using ArchiCAD.Jack Suben, California, USA.• I am the no. 1 fan of your Cookbook and your organisa-tion. Majid Ahari, structural engineer• I have had a much better chance to study the Cookbook...its a wonderful work. I regret not having the book in 94when I started teaching myself ArchiCAD it would savedme a lot of headaches and money. Even though I have donea lot of GDL development, you have clearly done a lot more;there is very little you haven't covered. I have tended tofavour a smaller subset of the 2d and 3d GDL statementsand not delved too deeply into the full range of GDL possi-bilities. Mike Carbone - Australia• The best thing I've done apart from buying AC has beenyour CB's and the establishment of "My_Library".Rod Jurich & Associates, Australia• Just a note of appreciation for your cookbook exercises:I’ve been working my way through them recently, with adawning sense of the potential of parametric GDL script-ing... And I’m beginning to change sides on the great graphicvs scripted debate, having spent several unhappy weekstrying to see the point of Visual GDL.... David Collins• When I think about it, meeting you is one of the bestthing in my university life, you taught me something thatcould shift my whole career. Somehow, there is a mergingbetween architecture, computer programming and databasemanagement. Alfred Man• Thank you very much for the GDL Cookbook. You pro-duced a very thorough and readable piece of work. Con-gratulations! Willem Langelaan, author of MasterLibrary• I was a little disappointed with ArchiCAD until I stumbledinto its 'hidden garden' - GDL. I now realise that, middleaged or no, drawing things is old hat. I have to learn toprogram them. William Henderson• Thank you, thank you! Your GDL Cookbook is wonderful.Too many ArchiCAD users deprive themselves of the richrewards available through the use of this script. On theaverage, end users find the GDL manuals too daunting andnever progress further then perhaps using objects made in

the 3D-view window if even that. Your rational, clear andabundantly documented examples help the neophyte andothers in demystifying this very powerful language.Jacques Couture, ASYM technologies, the first reseller ofArchiCAD in the United States• I got your book last month. Congratulations, it is great. Inever had time to update my book, but you do a muchbetter job of evangelising GDL.Pal Szabo, author of The In-troductory Guide to GDL• I am reading your book and cannot express my feeling.Everything in this book is so interesting, innovating andintelligent. This book is more than GDL. This book is morethan a book. It’s a way of thinking, it’s a way of life! DuskoMaksimovich, Aalto Skola Racnara• The cookbook is one of the best purchases this year. It's areal eye-opener: it gives me the anwers to most of myquestions about Archicad and GDL and it also provides mesome solutions for problems I didn't even know existedbefore. I hope I find the time to go through it all. Thank youfor your excellent work and helping making GDL easier.Christian Cerliani, Zurich• Without a doubt, the GDL Cookbook is the best manualI've seen written on GDL. The Cookbook is so thoroughlyindexed and documented that I'm finding it has not beendifficult to quickly find answers to my questions. The Cook-book, in combination with the GDL training I received, hasalso made Graphisoft's GDL Reference Manual much easierto understand. You have successfully demonstrated thatthere are no limits to what can be done in ArchiCAD if oneapplies the skills & techniques that you teach in your train-ing and in the Cookbook. Chris Stringer USA• You very effectively got me over the hump of GDL and Iam very appreciative of your efforts. Robert Davis, Texas• The company I work for has been using ArchiCAD for sev-eral years and not yet really got into it's wonderful powerand flexibility with the GDL side of it. We bought GDL Cook-book earlier this year and a couple of us 'drafties' haveread thru and tried to complete a number of your exercisesIt is full of interesting tips and tricks that have helped usenormously. Trevor Wright Summit Projects, Perth, WA• I’ve been working with GDL for a while until I discoveredyour GDL-Cookbook – and it was amazing! Every problemI’ve had could be solved with it. Marc AssmanDavid, I'm very happy. Your book is this year’s ‘Best Buy’product. Every day I produce 1 new full parametric object.Yesterday, tube rail, and today, Chimney hole, for insertingin to the wall via Window tool. Branislav Drgon, SlovakiaArchiCAD is very powerful. The capabilities of GDL are in-credible (my hat is off to DNC who inspired me to push myknowledge). I am an ArchiCAD believer. James HuetherI'm in GDL-Heaven! I have a GDL Cookbook now in myhands and started ‘eating’ it bit by bit! I was very pleasedto realize, that I was doing almost all of the basics yourecommended in the right way. In the next days and weeksI will oversee my existing objects for improvements, espe-cially the bits which ‘cooked’ my brain cells really hot! WhatI see has opened a new universe to me and I'm optimisticto be able to reflect the professional education of your bookin my next GDL projects! Many thanks for writing this bookfrom here and now. Karl Heinz Pfefferer

Page 8: Cookbook3_1

The GDL Cookbook 3

Contents: GDL DiscoveryIntroducing GDL ...................................................................................................................... 1So, you think you can’t program... ........................................................................................... 2How do you make an Object? .................................................................................................. 3First Look at GDL...................................................................................................................... 4Working in 3D space: 3D Cursor ............................................................................................. 5Your first 3D Elements.............................................................................................................. 63D & 2D Cursor Movement ...................................................................................................... 7Your first object ... a very simple Chair .................................................................................... 9Your First 2D Elements ........................................................................................................... 10Curvature Control ................................................................................................................... 112D script for the very simple chair ......................................................................................... 11More 3D Commands .............................................................................................................. 12END and Line numbering ...................................................................................................... 12The Good Chair ...................................................................................................................... 13Tubular Handrail .................................................................................................................... 14Structured Programming? ....................................................................................................... 16These need thinking about... ................................................................................................. 17PEN ......................................................................................................................................... 17The ‘Subroutine’ ..................................................................................................................... 18Converting a script into subroutines ...................................................................................... 19IF... THEN... ELSE... ENDIF .................................................................................................... 20BAD Chair example ................................................................................................................ 21Steps in 2D – Dimension Tool ............................................................................................... 22PRINT...................................................................................................................................... 22Tubular Steel Chair ................................................................................................................. 23The wickedness of GOTO ..................................................................................................... 25FOR... NEXT Loops, The inexhaustible workhorse of GDL .................................................. 26Stretchy Beam Tool ................................................................................................................ 27Other types of Loop ............................................................................................................... 27Stretchy Joist Tool ................................................................................................................... 28Domino House: Loops ........................................................................................................... 30More 3D Commands – Prisms ................................................................................................ 32Car Park Barrier ...................................................................................................................... 33Modify Library object ............................................................................................................. 35Bits of Syntax .......................................................................................................................... 38SHADOW, MODEL ................................................................................................................. 38More about GDL 2D Commands ........................................................................................... 39POLY2, POLY2_ ...................................................................................................................... 40More 3D – Drilling Holes in Prisms ....................................................................................... 40Global Variables ..................................................................................................................... 41Globals in Action .................................................................................................................... 43Value Lists ............................................................................................................................... 43Attribute Definitions ............................................................................................................... 44Status and Masking values ..................................................................................................... 45Polylines ................................................................................................................................. 46Special mask/status values ..................................................................................................... 46zzyzx? ...................................................................................................................................... 46Try Polylines yourself! ............................................................................................................ 47Curvy 3D commands – bPRISM_, REVOLVE! ........................................................................ 48Fire Extinguisher .................................................................................................................... 49Simple Sash Window.............................................................................................................. 50Simple Curvy Window ........................................................................................................... 52Maths Operators ..................................................................................................................... 53

Page 9: Cookbook3_1

The GDL Cookbook 3

Properties – keep it simple! .................................................................................................... 54Bocaccio Chair – Prism masking ............................................................................................ 55Lattice Truss ............................................................................................................................ 56Lattice Portal – using Lattice Truss ......................................................................................... 58Raised Computer Flooring Tool ............................................................................................. 59Louvre Sunbreaker ................................................................................................................. 61Comment, Preview and Labels .............................................................................................. 62Planar 3D Elements ................................................................................................................ 63More 3D Elements – SLAB, SLAB_, cSLAB_........................................................................... 64Standard Lamp ........................................................................................................................ 65Picture Objects - Alpha channels ........................................................................................... 66Cutplane/Cutend .................................................................................................................... 69Tapering tube – with cutplane ............................................................................................... 70The 6.5 User Interface – part 1 ............................................................................................... 71Compare ArchiCAD 6.5 .......................................................................................................... 72The Magic of ROT – How to rotate objects in plan ............................................................... 73CUTPOLY, CUTSHAPE and WALLHOLE ................................................................................ 73CircleGrid – 2D ....................................................................................................................... 74Location-aware Capability...................................................................................................... 75People – outlines which face camera .................................................................................... 76Dwight’s Binary Hacker ......................................................................................................... 77Swivel Chair ............................................................................................................................ 79TUBE....................................................................................................................................... 81General Advice and warnings, all in one page ..................................................................... 82Rules of good conduct and safe passage in GDL .................................................................. 83Quality Control ....................................................................................................................... 84GDL Case Studies ................................................................................................................... 85GDL Cookbook : Questions to ask yourself .......................................................................... 87Appendix: True Azimuth finding and the IFCo chair ............................................................ 88

Discovery: Tips and TricksUse the GDL Manual! ......................................... 5Introduction to Tips and Tricks ............................ 5A Note on Spelling .............................................. 8DEL TOP or DEL NTR? ......................................... 8Typograpical note ............................................... 8Help files + Documentation folder .................... 14Advice Corner for GDL newbies ........................ 15Comma confusion? ........................................... 17Golden Rules for Subroutines! .......................... 18Building Signage: picture into the project ......... 20Multiply, don’t Divide! ...................................... 25LOOP Counter name ......................................... 27Hot Tip for rapid 2D Scripting ........................... 29Ghost Storey to print out? ................................ 30Typographical format for all PRISMs ................. 33What makes autoscripted objects stretchy? ...... 34Instant GDL! ..................................................... 36Analysing and Extending the 3D Script ............. 37Steal this routine.... ........................................... 37The Golden Rule: use the Origin ....................... 37Join a User Group – or make one! .................... 38Advice on 2D Scripting ..................................... 39Hotspots make Stretchy Objects! ...................... 39Are your HotSpots Stretchy & Squeezy? ........... 39Cursor control in 2D scripting ........................... 40

Long or Short Global names? ........................... 422D Crosshairs .................................................... 45Object Naming.................................................. 47Golden Rules for making Windows (and Doors) 50Rendering ......................................................... 62URL in the Comment field ................................. 63See your cursor! ................................................ 64Rendering picture objects ................................. 68Shadows in section/elevation ........................... 74ROT2 and DWG export ..................................... 74General Advice and warnings, all in one page .. 82Libraries .......................................................... 82Building the Model, Rendering ...................... 82Making Library Objects ................................... 82

Rules of good conduct and safe passage in GDL83Philosophy, Structure .................................... 83Typography and Layout, Maths ..................... 83Development of the Script .............................. 83Good scripting practice ................................... 84User Interface ................................................. 84

Quality Control ................................................. 842D scripting ...................................................... 84GDL Case Studies .............................................. 85Monitor and Card questions ............................. 86Light through walls ........................................... 86Modules – another type of ‘object’ ................... 86

Page 10: Cookbook3_1

The GDL Cookbook 3

Contents: GDL VoyagerVoyager Task list ....................................................................................................................... 1Some Useful guidelines ............................................................................................................ 1Tips and Tricks 10 page special ............................................................................................... 7Professional Standards in GDL............................................................................................... 17GDL Syntax – PUT, GET & NSP ............................................................................................. 18Advanced 3D Commands ...................................................................................................... 22TUBE....................................................................................................................................... 22TUBEA .................................................................................................................................... 23MESH ...................................................................................................................................... 23COONS ................................................................................................................................... 24MASS ....................................................................................................................................... 25RULED, SWEEP, PYRAMID .................................................................................................... 26EXTRUDE ............................................................................................................................... 27Polylines explained fully ........................................................................................................ 28Advanced 2D – FRAGMENT2 ................................................................................................ 31Fragment Tester ...................................................................................................................... 32Master Scripts .......................................................................................................................... 33POLY2_A, POLY2_B, SPLINE2 ............................................................................................... 33Modifying Parameters – 2D Car ............................................................................................. 34Input / Output ........................................................................................................................ 35Arrays ...................................................................................................................................... 36Arrays in action ....................................................................................................................... 37GDL Macros ............................................................................................................................ 38Maths Primer ........................................................................................................................... 39The Binary System – for Voyagers ......................................................................................... 43Obscure Commands – ARMC, ARME ..................................................................................... 44Ridge & Hiptool ...................................................................................................................... 45AngleRod – Useful stretchy tool object with TUBE ............................................................... 45Stair – Parametric, with handrails........................................................................................... 47Theatre in the Round Seating ................................................................................................. 49Spiral Staircase ........................................................................................................................ 52The Secrets of Labels – you can make your own graphic label ............................................ 53Label Arrays – show position ................................................................................................. 553D GDL –Building Elements – cWALL, bWALL ...................................................................... 56SPECIAL PRISMs ..................................................................................................................... 56LIGHT ..................................................................................................................................... 57More Cutting ........................................................................................................................... 58More Complex Window ......................................................................................................... 593D Text ................................................................................................................................... 61Glazing Assembly ................................................................................................................... 62Curvy topped Window ........................................................................................................... 63The 6.5 User Interface – part 2 ............................................................................................... 67Command Statements in the User Interface (UI) ................................................................... 69You want a Pictorial Value List? .............................................................................................. 71UI Design Guide ..................................................................................................................... 72UI Interface – all the bells and whistles ................................................................................. 73Fire Extinguisher revisited: 6.5 ............................................................................................... 76Let’s make a Door! .................................................................................................................. 77Anglepoise Lamp .................................................................................................................... 83Recursive Tree ........................................................................................................................ 85Tree questions ........................................................................................................................ 87Kitchen Chair .......................................................................................................................... 88Northpoint .............................................................................................................................. 91Some more GDL Syntax – Strings, REQUEST, IND, SPLIT .................................................... 92Long Handrail – Swing the Cat! .............................................................................................. 93

Page 11: Cookbook3_1

The GDL Cookbook 3

CONE-shapes ......................................................................................................................... 95RhombiCubOctahedron ......................................................................................................... 96Helix and Spiral forms ............................................................................................................ 99DXF conversion .................................................................................................................... 103Desktop Clock ...................................................................................................................... 107Analog Clock ........................................................................................................................ 108Fountain ................................................................................................................................ 109Curtains! ................................................................................................................................ 110Spiral Handrail (Swing the Cat again!) ................................................................................. 112Curved Windows – the hidden secrets ................................................................................ 114Stretchy Edging Tool ............................................................................................................ 117Boundary Survey Tool.......................................................................................................... 118Storey Sensitivity .................................................................................................................. 119TEXT and DATA GDL Add-ons – The secrets of File I/O.................................................... 120TEXT & DATA GDL Add-ons – Variable type issues ........................................................... 127Saving Parameter Sets .......................................................................................................... 128Custom Zone Stamp ............................................................................................................. 132Lattices – Winged Truss – 1 .................................................................................................. 134Lattices – Winged Truss – 2 .................................................................................................. 136Building Lattices ................................................................................................................... 137Catamaran ............................................................................................................................. 142Squiffle – revisited ................................................................................................................ 146Cable Macro .......................................................................................................................... 147Secrets of Wrapping Textures – COOR VERT and all that................................................... 148Create a CYCLORAMA for your VR Panorama .................................................................... 150VR rendering with backgrounds .......................................................................................... 152Let’s make a background ..................................................................................................... 152Cast Shadows with Alpha Channels..................................................................................... 153Cast shadows with Alpha Channels and do it with GDL..................................................... 155Animated Flag....................................................................................................................... 156Bendy Bar! Reinforced Concrete assistant .......................................................................... 158Curvy Roof ............................................................................................................................ 160String Parsing ........................................................................................................................ 162String Wrapping .................................................................................................................... 163Hider – 2D whiteout ............................................................................................................. 163Arches and Waves! ................................................................................................................ 164Multilingual Object ............................................................................................................... 167Cellular/Castellated Steel Beam ........................................................................................... 169Arched Cellular Steel Beam.................................................................................................. 171Hyperbolic Paraboloid ......................................................................................................... 175Tents? – the big question ...................................................................................................... 178Making Choices – binary decomposition ............................................................................ 183Gourd with COONS ............................................................................................................. 184Furniture Legs! – and how to make them ............................................................................ 187Calculate Menu ..................................................................................................................... 189Special Menu ........................................................................................................................ 192Master_GDL.GDL ................................................................................................................. 193Make your Building Grow! ................................................................................................... 193Tips and Tricks 4 page special ............................................................................................. 194How do they do that? ........................................................................................................... 198Developing with API ............................................................................................................ 203Developing with GDL .......................................................................................................... 203Look at the APIs – Profiler .................................................................................................... 204Appendix: Page turning in the UI + Master End.................................................................. 205Index: Discovery .................................................................................................................. 206Index: Voyager ..................................................................................................................... 207

Page 12: Cookbook3_1

The GDL Cookbook 3Voyager: Tips and TricksSome useful guidelines ....................................... 1Redefining Magic parameters ............................. 7Picture Objects .................................................... 8Squiffle ............................................................... 8PICT or TIFF or JPEG? .......................................... 9Rendering – Speed ............................................. 9Preview images .................................................. 9Use the GDL Manual! ......................................... 9The Digital Architect ........................................... 9FormZ ................................................................. 9Roof Cutting ....................................................... 9Rendering into Photo ........................................ 10Recording contract drawings, long term ........... 10Stationery File – keep your settings .................. 10True Line weights in 2D .................................... 10Printing in EPS .................................................. 10Pens changing when opening DWG files .......... 10Transferring favourite settings .......................... 10Making scripted objects stretchy or squeezy .... 11Servers with Teamwork – try iMac! .................. 11Tracing Scans .................................................... 11Compression Advice ......................................... 11Wirelines in Rendering ...................................... 11Bounding Boxes in 2D ...................................... 12Batch Rendering Stills ....................................... 12Animation / Flythroughs ................................... 12Vertical Stretchy Objects – zzyzx ...................... 13Protecting your Scripts ...................................... 13DWG 2D Import – Layers .................................. 14Rendering – textures ........................................ 14DWG Export advice ........................................... 14Memory Management ...................................... 14Memory Settings .............................................. 15DXF Import 3D .................................................. 15Varying Line Hardness ...................................... 16Writing with Acrobat ........................................ 16Remove that annoying Error message .............. 16Objects available on the Internet ...................... 16Syntax errors with CALL & PICTURE ................. 16Emptying the buffer .......................................... 21TUBE+TUBEA Mental Health Warning! ............ 22Hot MESH Tip! .................................................. 23Freeform surface making .................................. 24Do it with PUT & GET ....................................... 24Masking codes .................................................. 25Extrude vs. Prism .............................................. 27Lost your Toolbar? ............................................ 30A practical use for FRAGMENT2... .................... 30Oddity of PUT & GET ........................................ 353D View to Symbol ........................................... 35Golden Rules for macros: .................................. 38Remember: ‘SOH CAH TOA’ ............................... 39Maths Tips and Tricks ....................................... 40ArchiCAD Training, and PEN Errors ................... 43Dynamic Line numbers! .................................... 44Advertising Feature........................................... 44Hotspots – 3D No show .................................... 48

Section Fill ........................................................ 49Teamwork Problem ........................................... 58Show the Blade! ............................................... 58Calculate the volume of a Mesh ....................... 59Writing for older versions ................................. 59Curved top windows, CUTEND time saver ........ 65Turning Pages in the UI ..................................... 73Visual GDL and coloured script ......................... 74Mental Health Warning! [UI] ............................ 75Laurent’s Advice on UI ...................................... 75Using another monitor...................................... 84Tree questions ................................................... 87Autosizing text in 2D ........................................ 90Getting Strings to work correctly ...................... 98Why do you need to do a Helix? ....................... 98Rules for Curved Windows/Doors ................... 114Beams are groovy! ......................................... 124GSM file naming ............................................. 125Faithful old objects no longer so? ................... 126GDL Toolbox ................................................... 126Modify EPS line weights ................................. 127Move them hotspots! ..................................... 133Building Lattices ............................................. 137Doing it with Alpha Channels : think BIG! ...... 141Fonts or what? ................................................ 145Architects can create Web sites ...................... 147Deliberate Errors ............................................. 147No ‘On Error’ is an error: FIX!! ........................ 167Delete unwanted layers .................................. 168‘Quote marks’ ................................................. 168Artlantis – 3 Questions ................................... 172Setting Standards: use a Module .................... 176Reasons to use ArchiCAD-Talk: No. 1 .............. 177Hide window symbol? .................................... 177Cookbook is for life, not just for Christmas! ... 191Speed up your Rendering ................................ 194Top Maths Trivia – Find the Circle Centre ........ 194ArchiCAD-Talk on the Web! ............................ 194FAQs on the Internet ....................................... 1952 ArchiCADs for the price of one! ................... 195MASS – terrain modelling ............................... 195Putting Roads into the Mesh tool ................... 195ArchiCAD-Talk on the Internet ........................ 195Use Acrobat! ................................................... 195Server advice .................................................. 195Walls in conversion work ................................ 196Battered Walls ................................................ 196Use ArchiGuide!.............................................. 196Digital Cameras and Kodak CD ....................... 196Using Comments ............................................ 196Quicker Section Elevations .............................. 196Putting an ArchiCAD render into a photo ....... 197Crashes on Interface and Parameter scripts .... 197What about ArchiFORMA?.............................. 197Making Patches scaleable ............................... 197Lost your Toolbar? – revisited ......................... 201A use for MASTEREND_GDL ........................... 205

Page 13: Cookbook3_1

The GDL Cookbook 3

Note to readers

The Cookbook started off as a set of web pages in 1997,and was a website. So many users asked for it in printed

form that since 1998, it has now been available as a book.In December 98, the GDL Cookbook became ArchiCAD

6.0 compatible. The GDL Cookbook 2 of June ‘99 was amajor rewrite with many exercises modified or added, withthe theory-based Primer dissolved amongst the exercises toform a more progressive delivery of the information requiredto get you going with GDL. This is GDL Cookbook 3, withmany improvements over Cookbook 2, such as moreArchiCAD 6.5 material, longer and better explanations oftechniques, and explorations into many areas not coveredby the previous books.

The book is available in Acrobat format on the enclosedCD. With AC 6.x, if put into your Documentation folder, itwill appear in your ‘Help’ menu.

Acknowledgements

I should like to thank: Howard Gill, my partner in LiftOffcourses; Richard Swann for the idea of writing the sec-

tions on Theory; Dick Morgan for the idea of holding a Voy-ager course, and Chris Phillips for the idea of making it intoa book; Sally Nicholson-Cole for keeping the office goingwhile I do anything except working for ExMicro; my stu-dents for challenging me with difficult tasks which sharpenmy skills; all the participants of the ArchiCAD-Talk confer-ence who display unfailing patience in putting up with mymany emails; John Stebbins, Kimon Onuma, DwightAtkinson and others for their ceaseless support for the Cook-book and the GDL culture; Sanjay Patel of GDL Technologyfor his unfailing support and encouragement; Apple for pro-viding me with G3 technology! The University of Notting-ham for paying half of my salary so that I can be paid forwhat I enjoy doing most - teaching ArchiCAD! Finally,Graphisoft in Budapest for ArchiCAD itself.

David says,

Now that you have started withthe Cookbook, I do request you toleave me with emails to say howyou are getting on. This will bemost encouraging, and will repaythe many hours spent preparingGDL examples, Pagemaking,bookbinding, packing & posting,all to provide you with this‘doorway’ into a higher level ofskill. The Cookbook improves withencouragement and constructivecriticism. I am always willing todispense advice to Cookbookowners, so please, register yourpurchase.email:[email protected]

David Nicholson-Cole teaches Architectureat the University of Nottingham. This involvesa lot of ArchiCAD and GDL. David is thefounder of ExMicro Ltd (Apple Resellers),Marmalade (CAD & DTP); a director of the-object-factory.com; a GDL consultant towebscape.com; a founder and evangelistwith the GDL Alliance. He is available as aconsultant to architects who want to useArchiCAD as more than just a drawing tool.He has travelled extensively teaching GDLin Europe, North and South America, the Mid-dle and Far East. David and friends put onthe ‘ArchiCAD University’ event, a weekendlearning festival of ArchiCAD, each Septem-ber. When not using ArchiCAD, David likesbeing on his BMW Motorbike, or sailing onhis yacht-share off the Suffolk coast.

About the Guest AuthorsLaurent Godel is Swiss, lives in Barcelona, and is awell known contributor to ArchiCAD talk and otherGDL talking places. He is part of the GDLA and theArchiCAD University team. Known as the ‘gdlguru’in GDL circles, he is a expert on File I/O, and hascreated many utilities with GDL that most us uswouldn’t have thought of doing and wouldn’t be ableto do even if we did!

Frank Chin lives in Brunei and has provided Davidwith some useful criticisms of the Cookbook. He hasprovided a valuable contribution on Texture map-ping (Flagpole) and Ballistics (Fountain).

Phil Cannon has been doing GDL longer than any-one in the UK, and provided the Tree model.

Alfred Man was one of David’s students and workedthrough everything in Cookbook 1 in a week – itchanged his life. He now has a career in GDL andAPI development.

Dwight Atkinson MAIBC is an Architect and PublicArtist, living in Vancouver, Canada. He is highly popu-lar with the ArchiCAD University crowd for his ex-trovert personality, and expertise with photo-rendering, GDL and Photoshop.

Trevor Grant is an English architect who likes thechallenge of using GDL for experimental work.

Mick Kingsbury is an English architect, who alsoteaches at Nottingham University.

Laszlo Vertesi is one of the senior technical team atGraphisoft, Budapest.

Geoffroy Magnan is a Belgian architect.

Steve Campbell is an architecture graduate work-ing in Seattle WA on housing.

Bill Rattenbury of New Zealand is the author of‘Project Framework’ published by Graphisoft.

Oleg Shmidt of Ryazan, Russia is an expert GDL,C++ and API programmer.

About the Author/Editor/Publisher

DNC in Tokyo, July 2000

Page 14: Cookbook3_1

The GDL

Cookbook 3

The SOURCE of all that

is good in GDL

Part 1

GDL Discovery

Page 15: Cookbook3_1

1.1

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

had just done, or doing tasks that would undo onesyou had just done. You can write the sequence as aseries of pictures, or as written commands. That’s allthere is to it!

Which language would you use? For cookery, youwould speak in English, or French or Spanish, but youwould use similar food ingredients. For GDL, you usethe language of BASIC, and your ingredients are com-mands to produce primitives like BLOCK, CYLIND andCONE; and you can go on to make more complexshapes like TUBE. BASIC is the easiest of the majorprogramming languages, devised in the seventies, andpredominant on micros during the eighties. BASIC iseasy to learn.

Graphisoft must be thanked for choosing BASIC asthe model for their programming language. We can allwrite a few lines of code, and see 3D objects springingup into existence. It’s fun! It’s intellectually challeng-ing! One’s capabilities are vastly increased – in the ‘olddays’ of programming, BASIC could build menu drivenprograms for dull things like accounts and calculations,many of which were far easier to do in spreadsheets.Now, with GDL, towers, chairs, bridges, space struc-tures, buildings and trees can all grow from your key-board.

INTERFACING – GDL objects can behave slightlyintelligently in that they can know storey, scale,

frame number, object’s location, current pen, cameraposition and so forth, and behave accordingly. If theyare windows and doors, they can know current wallthicknesses and materials.

Introducing GDL(Geometric Description Language)

GDL COMMANDS – in their raw state are available to you in the GDL manual. It is difficult to

understand their use and syntax until you have to ap-ply them for real. Therefore, the cookbook approachin this book gives you an easier way of learning themby doing small projects, a bit at a time. The cookbookmethod is based on small projects, growing in com-plexity and a critical look at what we have learned fromit. This is analogous to the process of architectural edu-cation. The GDL explanations in this cookbook runssystematically through all the 2D and 3D commandswith small examples of the commands at work.

3D ORGANISATION – You may not be able to buildsomething in every detail, but you look at it, and

decide what parts of it need to be included. You alsodecide how the object will behave if it is to be stretchedor hinged, and what 3D primitive shapes – blocks, cyl-inders, cones, surfaces – would best produce the ob-ject.

PROGRAMMING – A program is just a sequenceof instructions. You can read instructions to some-

one over the telephone, you can struggle through theinstructions for setting the controls on your new video,you can explain a cookery recipe to a friend, or planthe most efficient way of mowing the lawn. There iseven a program required in making a cup of tea! In allthese cases you use a program, even if you didn’t thinkof it as a program. Suppose you write down the se-quence of tasks, you would be sure to get them intothe right order. You would try to avoid doing tasks you

Working with GDL consists offour main areas of knowledge

IN the early days of ArchiCAD, the forerunner of ArchiCAD (RaDar) ran on a Hewlett Packard as

a 3D Piping design solution. Yes, the original Graphisoftteam designed 3D piping for nuclear power stations!Then they got more and more interested in the prob-lem of wrapping buildings around the piping. Gradu-ally they moved into architecture.

Not having a mouse or windows, the ancestor ofArchiCAD was GDL-based – a scripting language toproduce 3D form. The arrival of the Apple Lisa fol-lowed by the Macintosh enabled programmers to putthe building plan into one window, the building toolsinto another (to form a palette of clickable buttons),coordinates in another, and so on.

ArchiCAD as we now know it became visible – click,drag and click. Designers could drop walls and otherbuilding elements into a plan window, stretch them tofit and change their properties; view the 3D results inanother window. GDL survived as a speciality, evolv-ing in its own way as a means of building library ob-jects.

GDL COMMANDS– produce 3D and

2D entities – like CONE,BLOCK, SPHERE, TUBE,POLY, ARC, REVOLVEand so on.

3D ORGANISATION– look at the object

analytically and under-stand what 3D shapes itcontains and what rulesthey follow.

PROGRAMMING– the organization

of the script in a struc-tured way, observingrules of syntax.

INTERFACINGwith ArchiCAD –

to enable the object torespond to conditionsin the main project.

Page 16: Cookbook3_1

1.2

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

So, you think you can’tprogram...

NEXT, you look at each Operation and realise thatnone of them are single Actions. Each operation

consists of a number of Actions which might includeError Checking. For example, if the teapot contains lastnight’s teabags, then Wash Teapot. This might requirequite a lot of IF statements, followed by the Actionstaken as a result of the IF statements.

W ELL you can! Squirrels can program, birdscan program, spiders do it, small children do it

– in that they plan a series of actions, they try to getthem in the right order, they correct their own mis-takes when they make them, and they achieve a result– perhaps a hoard of nuts, a nest full of eggs, a web, ora Lego model.

The British Standards Institute recently (Sept ‘99) re-ceived the ‘Ig Nobel’ Prize for Literature in that theywrote BS.6008: Method for Preparation of a Liquor ofTea, and took 5000 words to do it, going into the mi-nutest detail! We will not go quite so far, but let’s usetea making as an example of human programming. Let’swrite down a series of ‘Operations’ involved in mak-ing Tea. Without going into too much detail, list thesequence of operations to someone who knows theobvious things like how to turn on taps. Anybody read-ing this (above the age of 10) should be able to recitethe following list in the right order.

Now because we are going to teach a computer howto make tea, you need to rewrite the list giving eachOperation a number (with a colon), and use an excla-mation mark to make each Operation name into a La-bel. For a human, you might number each task 1, 2, 3,etc, but for computers it’s easier to use larger numbers(because later, you could insert extra things you hadn’tthought of, like getting the sugar lumps.)

The finalprogram formaking teaGoes around until kettlefilled: 2 IF statements

A single line way of writingtwo IF statements

People are ‘integer’ quanti-ties; but this makes doublysure that you can make teafor 2.

For the ‘parameter’ of tea,you could let the user selectfrom a list of choices.

In the event of a majorproblem you might have tojump back to the start.

100: !Fill Kettle with water200: !Boil water300: !Get teapot400: !Fill teapot with bags500: !Fill with water600: !Get cups700: !Wait until ready800: !Pour out900: !Add Milk1000:!Serve Tea 2

1. Fill Kettle with water2. Boil water3. Get teapot4. Fill teapot with bags5. Fill with water6. Get cups7. Wait until ready8. Pour out9. Add Milk10.Serve Tea 1

100:!Fill Kettle with waterIF kettle (empty) THEN (Fill kettle with water)IF kettle (filled) THEN CONTINUE:!Boil water

200:!Boil waterIF water (boiling) THEN (turn kettle off) ELSE (boil water)

300:!Get teapotIF (number of people) less or equal to 2 THEN (GET smallteapot)IF (number of people) greater than 2 THEN (GET largeteapot)IF teapot (dirty) THEN (wash out teapot) UNTIL (clean)IF teapot (clean) THEN (swirl hot water) UNTIL (warm)IF teapot (warm) THEN (Fill teapot with bags) !continue

400:!Fill teapot with bagsLET teatype=USERCHOOSE(EarlGrey,Lapsang,Camomile,Tetleys)IF teapot (large) THEN add 2 teabag USING teatypeIF teapot (small) THEN add 1 teabag USING teatype

500:!Fill with waterPOUR water INTO teapot UNTIL (full)IF (not enough water) THEN GOTO 100:PLACE teacosy UPON teapotSTART timeclock USING seconds

3

Continued next page

Depending on the level of knowledge or stupidity ofthe machine, you instruct it appropriately. For exam-ple we assume here that the machine knows how toturn a tap or a kettle on. In the same way, GDL knowsthat Cylinders are round and that Cones are taperedand round without us having to define ‘roundness’mathematically.

Page 17: Cookbook3_1

1.3

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

700:!Wait until readyIF TIMECLOCK less than 120 seconds THEN WAIT

800:!Pour outREPEAT (on the teatray) IF fullness=0 THEN POUR (a cup) UNTIL fullness=7/8 UNTIL (enough cups for everybody)

900:!Add MilkLET milkcondition=USERCHOOSE(with milk,without milk) REPEAT (for each cup on the teatray) IF milkcondition=(with milk) THEN (add milk to cup) UNTIL (each cup tested)

1000:!Serve Tea1100:!Tea too hot, pour into saucer and drink from that !...vicar is shocked!

OK, we can’t all be perfect. The British Standard says put the milk in thecup first, and of course, I haven’t tested to see if the users have chosen sugar,

or want spoons, saucers or biscuits. And what happens if there isn’t enough tea foreveryone? Then you have to loop back and top up the teapot, or even reboil thekettle. This could be built into the program. That level of detail and error correctionwould make the program more professional and user friendly.

I hope this shows the sort of thing you can do, and has persuaded you that youcan indeed write a program.

This was going on while youwere getting the cups.

Another repeating ‘Loop’

Another example ofgetting the parameter fromthe user’s choice.

Now this isn’t written inBASIC, and it isn’twritten in GDL, but it’sclose to both of those two,and shows thatprogramming can be likewriting in English in aslightly mathematicalstyle.

4

How do you make an Object?Look at it as if through half closed eyes.....See it like this in your mind’s eye, to reduce the objectto what you feel is essential about it, and then you ask...

Can you draw it in 3D on paper?If you can sketch it in 3D, you are well on the way tounderstanding how you would build it in GDL, andthen you ask...

What are its primitive forms?Most things can be simplified to the simple shapes ofcylinders, blocks, and cones; furthermore, you canperceive tubes, surfaces, prisms and lathed elements;and then you ask...

Does it need to LOOK right, or BE right?Is this a quick little object that adds authenticity to a3D rendering but doesn’t need to be accurate? – or is itrequired to look good in detailed sections and plans ina construction drawing? And then you ask...

What Level of Detail (LOD) does it require?If it’s for a rendering, you may be seeing it fleetinglyduring a flythrough, or requiring it for an Artlantiscloseup. For a construction detail, it could be scalesensitive so that it shows detail at 1/20 and 1/50 butsimplifies at 1/100 and 1/200. Your object may be mak-ing too many polygons if it is curvy. Consider LODconstantly; and then you ask...

Could it be 2D only?Some objects are only required for the 2D drawings.People, trees and furniture could be 2D entities thatappear only in plans sections and elevations; perhapsyou needn’t bother with the 3D; and then you ask...

Does it need to be stretchy?We are all familiar with autoscripted objects beingstretchy. But does it really need to be stretchy? Or canthe stretchiness be controlled to make the object stretchsmartly? And then you ask...

Will it be an Object, or a Tool?It may be a single piece of furniture. But if it’s a clad-ding panel, fencing, handrail or similar, it may be moreakin to a Tool, whereby if you stretch it, you get moreand more objects. And then you ask...

How smart does it really need to be?If it is a tool and it is an investment, you can make itsmart – know the 3D rules of its existence, how to be-have when stretched. But some objects can be so smartthey can be annoying to the user, and can take toolong to develop. And then you ask…

Does it need to appear in listings?This is increasingly important with manufacturers jump-ing to the realization that they can make libraries oftheir products in GDL, not just in DXF. The object mayneed to have accurate names and serial numbers inthe property scripts and smart value lists to ensure thatthe name/number corresponds to the object. And thenyou ask...

Can complex problems be solved with textures?Recognise when 3D forms or surfaces are so complexthat a texture will solve them better then modelling –for example leaves, tiles etc. And then you ask...

Have I got the ability to make it?If not, then here’s the chance to learn new tricks!

(so manyquestions...)

Page 18: Cookbook3_1

1.4

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Property Script: here you can write Componentsand Descriptor commands if the object is to be in

a schedule.

Parameter Script (a.k.a. Value List): this is themeans of creating Pop-Down menu selections in

the main parameters box; also for locking or alteringparameters.

Comment: is a small text field in which you canwrite a small set of instructions to your user on

how to use the object, or could place a copyright state-ment/ signature.

Preview Picture: is a window containing a pastedin bitmap image of a view of the object. It tells the

user what the object will look like in its setting, andcould come from Artlantis Render or an ArchiCADphotorendering. This becomes the Icon of the objectin the settings box finder.

Parameter table: we also fill out the table ofparameters by hitting the New button, and filling

in the small details. A, B and ZZYZX are ‘obligatoryparameters’ – they already exist – but we can makemany more.

The Components and Descriptors buttons are usedwhen you build a ‘Property Object’.

User Interface Script: This enables you to builda Custom dialog box with your own text fields

and images, with buttons and input fields for the userto enter parameters. It is great for complex objectswhere the user might need more explanation on theuse of the object or visual choices of style and form(AC-6.5 onwards).

Master Script: use this for housekeeping taskssuch as reading in Value lists, setting up Param-

eters, checking user Errors, defining Materials, settingFlags and so on. Information in the Master Script canbe used by the 3D Script, the 2D Script and the Proper-ties Script. If you didn’t use a Master Script, you wouldhave to write all these things time and time again.

2D Symbol: is a window into which you can pastea 2D image, or draw using 2D tools, but it will only

be displayed if there is no 2D script. With GDLknowlege, you are better to write a 2D script.

2D Script: this can be used simply to tell GDL todraw in 2D whatever it finds in 3D (Project2), or

whatever is in the 2D Symbol window (Fragment2).You can (and should) use it for writing a parametricallyorganised script to draw what the object will look like.By designating Hotspots, the 2D script can also gov-ern how stretchy the object can be. By leaving this scriptblank, the GDL object will display what ever is drawninto the 2D Symbol window. If you leave both blank,the object will not show in the project.

2D Full View: this is generated by the 2D Script.This will not show what is in the Symbol window

(unless commanded to.)

3D Script: the primary means of building para-metric 3D objects. If the object is simple, almost all

the work can done in the 3D Script.

3D View: is generated by the 3D Script – not to beconfused with the 3D window of the main project.

As you cannot place a camera in GDL, this is usually a3D axonometric view.

First Look at GDLFROM the File menu, open any 3D object and have a quick look

at the way the Parameter window is organised. A popdown menu(in 5.0 or 6.0) or a vertical button bar (in 6.5) allows you to view thescript and window types.

The main scripts and windows in GDL are these below.

For beginners, you only need to use the 2D and 3D scripts. If you press the greybuttons, the scripts appear in the main window. If you press the white buttons,the scripts appear in independent floating windows.

Byzanti
Highlight
Byzanti
Highlight
Page 19: Cookbook3_1

1.5

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

FIRST GET acquainted with the idea of the X, Y, Z universe that youhave to work in. All locations are defined in these coordinates. We have to

simplify our ideas of space so that poor idiot computers can understand where wewant the 3D cursor to go. If you want to move sideways, you move the cursor inthe X direction. If you move forward, you move it in a Y direction. If you move upor down, you move it in a Z direction. You can Rotate the cursor and the XYZworld gets rotated too.

• The ‘G’ (global) coordinates remain fixed at the Origin of the model. Whenyou bring an object into the project plan, this origin is what decides the heightof the object in the project. The origin should be planned carefully – preferablyat the base of the object, and at the axis of any symmetry or rotational axis thatyou perceive.

• The ‘L’ (local) coordinates are, in the 3D sense, the Moving Cursor in yourmodel – they travel with you, wherever you are drawing an component. Al-ways try to return the GDL cursor to the origin before you start out with anotherelement of the model.

Working in 3D space: 3D CursorJUST HOW do you write in GDL in 3D? Well,

when you are word processing, you move yourcursor to a location and start typing. Move the cur-

sor, and type again, and the new words appear at thenew position.

With GDL, you have a 3D cursor; you can movethe cursor; when you issue a 3D GDL command likeBLOCK or CONE, you will get a 3D object whereverthe 3D cursor happens to be. Move the 3D cursor to anew position and issue the same command and now itappears in the new position.

Thus to make a chair, you can move to each corner,plant a chair leg, then raise the cursor up to plant theseat and finally, move the cursor to plant the back ofthe chair.

When you have achieved a group of things (like abunch of chair legs), you have completed a task. Sonow return the cursor to the global origin. Now youcan depart and do another task, for example the seatof the chair.

When you have finished, you can do a small 2Dscript so that a 2D symbol will appear in the projectplan, save the file, and you are done.

G=Global OriginL=Local origin

G,L

The CartesianXYZ Universe

x

y

z

Introduction

THESE are spread through the GDL Cookbook like nug-gets of gold and are about ArchiCAD in all its forms, not

just GDL. In this edition, they are grouped somewhat moreheavily in the Voyager section. I first used them to fill spaceat the bottom of pages. When I want to expand on a topicin a later edition, I move the tip to another page to free upspace. Please email me any tricks you want adding.

The best place to find Tips and Tricks at their place oforigin is to be a member of the ArchiCAD-Talk list serverconference, on the Internet. Although I have tested out allmy own tricks here, many of the ideas for them startedfrom questions and answers on that conference. Try it!

Tips and Tricks for ArchiCAD users

Use the GDL Manual!

MOST ArchiCAD commands are covered in full invarious sections in the GDL Cookbook. But please note

that it is not the function of the Cookbook to replace theGDL Manual. You need to use both. You will find the GDLManual a lot easier to read now you have tried the Cook-book. You will also find sections of the Cookbook easier ifyou dip into the manual.

GDL is not just for 3D objects! Objects themselves can be 2D or 3D (furniture, buildingcomponents, utilities/productivity tools, trees

and people. GDL can make Windows and Doorswhich know how to cut holes in walls; Lamps, Zonestamps and Labels. They can be pure script (e.g. alist of materials); Macro object (e.g. door handle, tap,door); Property object, or Stairmaker part.

Page 20: Cookbook3_1

1.6

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

SPHERE is the easiest one of all –but the one most likely to cause youto have so many polygons that Archi-CAD will have trouble rendering it. Usestrict control of the surface resolutionwith RESOL commands.

If you do not specify resol, the resolvalue is assumed to be 36, whichmeans that the sphere will have 648faces! RESOL 10 is the smallest that stilllooks spherical.

ELLIPS produces a hemisphere, butby changing the height, it can bedistorted into a bullet shape. RESOLcan be used to make it look polygo-nal. ELLIPS is always solid.

If you want a hollow dome, youneed to use REVOLVE.

CYLIND drives a cylinder up theZ axis. If you want a cylinder at an an-gle, you first have to rotate the cursorwith a ROT command so that the Z-axis points in the desired direction.

Note that RESOL 6 or 8 can changeCylinders into hexagons or octagons.If you do not write a RESOL command,the cylinder will have 36 sides.

Your first 3D Elements

!Block Demonstration!Syntax:- BLOCK x,y,zBLOCK 0.3,0.2,0.25 ADD 0.1,0.1,0.25BLOCK 0.1,0.1,0.2 DEL 1

!Cylind demonstration!Syntax:- CYLIND height,radius CYLIND 0.2,0.05 ADDx 0.2 RESOL 6 CYLIND 0.2,0.05 RESOL 8 ADDz 0.15 ROTy 45 CYLIND 0.1,0.03

!SPHERE demonstration!Syntax:- SPHERE radius!RESOL sets the number of faces SPHERE 0.1 ADDx 0.2 RESOL 12 SPHERE 0.05 DEL 1

!ELLIPS demonstration!Syntax:- ELLIPS height,radiusELLIPS 0.2,0.06 ADDx 0.15RESOL 12ELLIPS 0.16,0.04

U NTIL you feel ready to progress to PRISM and other more powerful commands, get used tobuilding 3D GDL objects using the items on this page. These are the essential primitives of 3D building. It

is amazing how much you can do with these. These examples also demonstrate the simple-to-use cursor move-ment commands of ADD and ROT (see later for further explanation).

By the way, the single sphere on theleft, if saved as a DXF 3D file wouldrequire 21,000 lines of code todescribe it.

Some existing Graphisoft libraryobjects use BRICK – but it works tothe same syntax.

When you use any curved surface,always set the lowest resolution thatwill look acceptable – to reducerendering time.

BLOCK is the primary buildingblock of GDL, and with X,Y,Z dimen-sions for the parameters, you can’t getmuch simpler.

In GDL projects it is actually ratherlimited to use; you have to get the cur-sor to the lower left corner of a block,and you have no control over corners,lines etc.

By the way, if you want the cursor toreturn to the origin, you would haveto finish this script with a DEL 3.

Page 21: Cookbook3_1

1.7

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

ADD dx,dy,dz, ADDx dx, ADDy dy andADDz dz are the way to move the 3D cursor

from location to location. Most frequently, you add inone direction, X, Y or Z, but when you want to movein two directions or more it’s more economical to usethe ADD dx,dy,dz command to do 3 in one go. Thebest way to get the hang of these movements is tolaunch into typing in some of the exercises.

ADD2 dx,dy is the 2D equivalent of ADD, but is isnot as often used, because many of the 2D commandscan be issued without moving from the origin.

For example in 3D, you might go:ADD 1,1.5,0: CIRCLE 0.5: DEL 1

but in 2D it is:ADD2 1,1.5: CIRCLE2 0,0,0.5: DEL 1

but this can be shortened to:CIRCLE2 1,1.5,0.5

Starting with a plainELLIPS... (half a sphere) youcan make it shrink to anelliptical plan shape by MULxor can flip it vertically with aMULz.

3D & 2D Cursor Movement

!MUL DemonstrationELLIPS 1,1

!MUL Demonstration MULx 0.5ELLIPSE 1,1 DEL 1

!MUL Demonstration MULz -1ELLIPSE 1,1 DEL 1

MUL means Multiply – along the axis stated.So MULz -1 converts all references to Z to

negative, MULx 0.5 halves everything in the Xdirection – and so on. You can use a MUL x,y,zcommand and do three multiplications at once.

What MUL means in reality is that you can useit to change the scale of entire objects or parts ofobjects – all ArchiCAD Autoscripted objects useMUL to enable objects to be resized, or to bestretchy.

Objects can easily be mirrored by MULtiplyingby -1 around the mirroring axis. Symmetricalobjects are labour saving, as you build just half,then mirror around X, Y or Z.

MUL2 x,y is the equivalent command in 2Dscripting environment.MUL2 must be expressedin terms of x and y.

Above: the primitives all exist in the same 3D space.Below: after a few easy cursor movements, they are alldistributed correctly

PEN 1MATERIAL 'Whitewash'BLOCK 1.0, 2.0, 3.0CYLIND 1.0, 1.0SPHERE 1.0CONE 4, 0.5, 0.1, 90, 90

!Cursor MovementPEN 1MATERIAL 'whitewash'BLOCK 1.0, 2.0, 3.0 ADD 1.0,1.0,1.5 ROTy 90CYLIND 1.0,1.0 ADDz 2.0 MULz 0.5SPHERE 1.0 ADDz -2.0CONE 5, 0.5, 0.1, 90,90 DEL 5

Try making something very simple!

TRY writing something using the simple GDL com-mands you have just learnt. If you issue the com-

mands (BLOCK, CYLIND, SPHERE and CONE) you findthem all jumbled together at the origin and all being ahorrible colour. Immediately you can see that they lookbetter if you specify a PEN and a MATERIAL. Use aMaterial name that is in your Library.

This looks like nothing in the real world, so youhave to learn 3D cursor movement from day one. Witha few ADD, ROT and MUL commands, you can createsomething usable. It’s a case of lifting the cursor intoposition, issue the 3D command; either progress to thenext 3D object, or use DEL to return to the origin. Ex-periment with changing the dimensions and modifythe cursor movement statements.

Try changing the valuesof the ADD, ROT andMUL command to see

what happens. Click inthe 3D View window in

GDL

Try changing thedimensions of these

simple solids

Page 22: Cookbook3_1

1.8

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

DEL means “Delete the most recent CursorMovement command” – ADD, MUL or ROT.

DEL 2 means delete the last two.

DEL is the most important command of this page. IfADD and ROT are components of the engine, then DELis the braking system – just as important in the per-formance of your motorcar. If you go somewhere, youhave to be able to return!

If you do not control the cursor, your model will beunmanageable after a page of script. Therefore, useDEL to return to the Origin as often as possible.

One bad way to get back to the origin is to repeatall your moves backwards. For every ROTy 45, you doa ROTy -45, and so on, in reverse order. This is notgood! It is much easier to use the DEL command. TheROT, MUL and ADD commands are stored in a stack,and if you DEL 1, it knocks one off the stack. If youDEL 4, it knocks the previous 4 off the stack – in re-verse order. You can also DEL using a variable like DELnum.

If you use subroutines, DEL must match the numberof Cursor movements within a subroutine. Look at thesmall number of commands on this and the next pageto see how DEL is used.

The DEL command cannot run past the stack. If youDEL 2 when there is only one item to delete using DEL,you will get an error message.

DEL TOP removes all the Cursor commands– returns you to the Origin of the model by brute

force.

DEL TOP is useful because GDL does not declarean error when you use it, even if there is nothing toDEL. So you can put it at the end of a script, and notworry about an error occuring. However, it is far bet-ter to control the model by using DEL intelligently –with every subroutine – so that you never need to usethe DEL TOP command until the END statement.

DEL TOP is dangerous – apart from encouragingyou to program in a sloppy fashion, it can wipe outglobal commands (like ‘ROTx 90’ or MUL commandsto make the object stretchy) that existed at the begin-ning of the script.

ROT means Rotate the Cursor around an axis.You use it in the form of ROTx, ROTy or ROTz.

You use them one at a time. You use them in the orderthat logic tells you – the order is vital. Rotation is nor-mally positive if it is in the anti-clockwise direction. Ifyou want to rotate clockwise, you can rotate a nega-tive quantity such as ROTz -90.

There is a combined ROT command, but it is notused in the way that you use the combined ADD andMUL commands. The ROT command rotates the ob-ject around a vector – defined as the line connecting0,0,0 to a point defined by an X,Y,Z definition. It isunexplained and unillustrated in the GDL manual, sohere is a simple example! It is very effective if the cir-cumstance arises where it is needed: when it is, youwill recognise its usefulness.

PEN 7:MATERIAL ‘zinc’ROT 1,1,1,-60BLOCK 1.0,0.5,0.8DEL 1

ROT2 is the equivalent in 2D of the ROTz command. One of the problems of 2D scripting is that

you dont have a visible cursor, so if you do a lot ofADD2 and ROT2 and MUL2, you need to imagine thecursor’s location.

Typograpical noteIn reading this you have already expressed a serious inter-est in GDL – so let’s bring in a good discipline at the start.

Write all GDL commands in UPPER case, and all vari-ables (parameter names) and comments in lower case. Themachine is not case sensitive, but you are, and when read-ing and debugging your scripts later, you will find it easierif you follow this advice.

If you find yourself working on GDL as part of a teamyou need to agree on a format, so this is a good rule tofollow. It is followed in the Cookbook.

A Note on SpellingSome of my friends in the USA and elsewhere must thinksometimes that the author of the Cookbook is quite illit-erate – I mean who could possibly spell ‘inquiries’ as ‘en-quiries’, ‘realize’ as ‘realise’, ‘color’ as ‘colour’, or ‘story’as ‘storey’?

Well there is english english and there is ameringlish.Remember the romantic song about ‘I say tom-ar-to andyou say tom-ay-to’?? Vive la Difference! For me to beconsistent, I am trying to stick to UK spelling conventionsand the Chambers English Dictionary.

DEL NTR( ) not DEL TOPNTR( ) is a neat way of counting how many cursor move-ments (‘transformations’) have been done. If you have aseries of subroutines all of which have to return to the ori-gin, you could consider using DEL TOP before each RETURNif you are too lazy to count the number of Cursor moves.However, if you have a couple of global moves such as aROTx 90 or a MULz at the very start, then you cannot useDEL TOP. DEL NTR( )-2 will have the right effect withoutnullifying those first two transformations. Mind you, it’seasier just to count and DEL the correct number.

Byzanti
Highlight
Byzanti
Highlight
Page 23: Cookbook3_1

1.9

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Your first object......a very simple Chair

FROM the File Menu, Select New Library Part->Object, and youwill get a new Library Part opened, and from this, you will be able to

pull up the 3D Script window.

3D ScriptThis simple chair is entirely composed of the BLOCK command. Move the3D cursor from place to place, drawing a Block in each place, and thenmove on. The syntax of Block is very simple, just BLOCK x,y,z. You definethe X, Y, and Z dimensions of the block and it always grows outwards fromthe bottom left corner of the block.

Notice that the stages of the script are marked with labels (or ‘com-ments’) which all start with an exclamation mark. When you look at thescript later, you will know what’s what if you have labelled frequently.

As you build each Block, you use the ADDx, ADDy, ADDz or ADDcommands to move the cursor to the next location, then build the nextBlock. After a group of commands is completed, get the cursor back to thestart before doing the next group, using the DEL command – this ‘undos’the number of ADDs that you have made. Make sure that at the very end,you have moved the cursor back to the origin of the model.

If you do not specify a material, your objects will turn out all one colour,which can be disconcerting. So the PEN and MATERIAL command is oneof the first ones you learn. PEN 1 in my ArchiCAD 6.5 is black – set what-ever colour you want. If you do not have ‘Whitewash’ in your Materialslibrary, then find another material name to use for the chair.

This example is done in Imperial – to please all the American readers ofthe GDL Cookbook. All native GDL scripting has to be done in Metres (notmillimetres). If you wish to write in Imperial, you can, but each numbermust be clearly signified with Foot and Inch symbols. For Imperial users,the first things I suggest (apart from changing to metric) is to work entirelyin Decimal Inches, as this avoids spurious punctuation marks and mathsoperators such as in 1'-2 3/4".

2D SymbolThe ArchiCAD objects that are autoscripted from the Wall/Floor/Rooftools always have their own 2D symbol or script. When you write ascript yourself, you need to create the 2D symbol.

You can write a tiny script. Open the 2D-Script Window and use this‘killer command’: PROJECT2 3,270,2. It is very powerful and solvesyour need for a 2D symbol at a stroke. It draws a Plan view of the 3Dobject [3], with a camera angle of 270˚ [270] and it is in hidden line [2].Your 2D symbol will be given Hotspots by ArchiCAD.

Throughout the book I encourage you to write 2D scripts properly,so later we shall look at 2D scripting in GDL.

This simple chair starts life from itsfront right leg. It is valuable to doeach part in stages, and to move thecursor back to its origin at the end.

!Chair - 2D-ScriptPROJECT2 3,270,2

You want to do some-thing practical? Welltry this VERY simplelittle kitchen chairfor a starter. Turnover the page forsome guidance oncursor movement.

!Simple chair!3D Script - Imperial

MATERIAL "Whitewash"PEN 1

!LegsBLOCK 2",2",18" ADDx 16"BLOCK 2",2",18" ADDy 16"BLOCK 2",2",30" ADDx -16"BLOCK 2",2",30" DEL 3

!Seat ADDz 18"BLOCK 18",18",2" DEL 1

!Back ADD 2",16.5",24"BLOCK 14",1.5",12" DEL 1 !Back to origin

!Simple chair!3D Script - Metric

MATERIAL "Whitewash"PEN 1

!LegsBLOCK 0.05,0.05,0.45 ADDx 0.40BLOCK 0.05,0.05,0.45 ADDy 0.40BLOCK 0.05,0.05,0.75 ADDx -0.40BLOCK 0.05,0.05,0.75 DEL 3

!Seat ADDz 0.45BLOCK 0.45,0.45,0.05 DEL 1

!Back ADD 0.05,0.415,0.60BLOCK 0.35,0.035,0.30 DEL 1 !Back to origin

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 24: Cookbook3_1

1.10

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

HOTSPOT2 x, y places a Hotspot at thepoint x,y in the 2D symbol of the object. It lightsup when you select the object.

The purpose of HOTSPOTs are 4-fold: Toenable you to see objects when touched ormarqueed, to pick up the object, to make ob-jects stretchy, and to provide ‘gravity’ for snap-ping objects to line or to other hotspots.

LINE2 draws a line from one XY location toanother XY location – relative to your currentcursor position.

RECT2 draws a rectangle from one XY loca-tion to another XY location diagonally opposite– relative to your current cursor position andangle. RECT2 is always wireline (you can seethrough it).

PROJECT2 is a command that youMUST learn, even with your first scriptedObject!

Until you learn parametric 2D scripting, theeasiest thing is to write a short 2D script con-taining PROJECT2 3,270,2. This reads the 3DScript and draws whatever it can see, faithfully,in wireline or hidden line view. Be warned – itcould slow down the time it takes to draw thesymbol.

PROJECT2 should be learnt parrot fashion,you will use it many times!

Your First 2D Elements

Perhaps by now, you have noticed that every command in 2D scriptingends with the character ‘2’

U NLESS you have a 2D Symbol or a2D Script, your object will not appear on

the Project Plan! If you been using ArchiCAD’sconventional tools to make library objects, youhave been used to it making automatically gen-erated scripts, and automatically drawn 2D sym-bols generated from the view of the object.

!Typical short 2D Script for any 3D objectHOTSPOT2 0,0PROJECT2 3,270,2

PROJECT2 has interesting possibilities. For example, it can betold to display the object in the Project Plan in elevation oraxonometric form. Together with HOTSPOTs in the right places,you can make things stretchy in the vertical direction. Or youcan use it for a quick view of the elevation of the object tomake sure that you have set it up correctly.

Complex objects may be very slow to draw in 2D if you use thePROJECT2 command. A 2D script using LINE2 and accuratelyreflecting the trigonometry of the object without showing ex-cess detail may be perfectly adequate for the 2D symbol. Youcould offer the user an option to show greater detail if the planis larger than 1.50 or 1/2”-1’ scale.

Project2 demonstratedFrom the single object, you can get many rep-resentations on the floor plan.

Note that -7, -8 and -9 are the sameas their positive equivalent, justupside down!

3,270,2 4,270,2 5,270,2 6,270,2 7,270,2 8,270,2 9,270,2 -3,270,2 -6,270,2

Byzanti
Highlight
Page 25: Cookbook3_1

1.11

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

RADIUS is even more useful thanRESOL because it gives you 3 RESOLcommands in a single line. Someobjects such as a curved handrailhave two curves to resolve, the curveof the handrail and the curve of thetubing. Some curves are so small(such as holes drilled into a steelplate, or thin cables) that even if theywere RESOL 3 they would lookgood.

You state RADIUS in the form:RADIUS rmin, rmax

Any curve equal to or less than ‘rmin’will render with 6 faces. Any curveequal to or more than ‘rmax’ willrender with 36 faces. Any curve be-tween the two will render with avariable number of faces, on a slid-ing scale between 6 and 36 – similarto my example of the sliding scaleRESOL command above.

RADIUS cannot be higher than 36faces, so for very large curves com-bined with small ones, use TOLER.

Curvature Control

RESOL is used extensivelythroughout this Cookbook as a wayof controlling the resolution of cur-vature of curved surfaces such asSpheres, Cones and Cylinders.RESOL simply tells GDL how manysurfaces there are to be in 360˚ worthof surface.

The default resolution is 36, so asingle sphere will have 648 surfacesright from the start. Get it down tothe lowest practical quantity – oreven lower. If you are Photo-render-ing the resolution can be set evenlower. It is a good tip to set resolu-tion to an odd number – 5, 7 or 9look more cylindrical than the pat-ently hexagonal look of RESOL 6.RESOL cannot be less than 3.

RESOL can be controlled by a vari-able, for example RESOL 6+10/ddwill make the resolution higher asthe distance to camera ‘dd’ reduces.If the resolution is stated as a realnumber – eg 6.35, it is alwaysrounded down.

TOLER is an interesting way of set-ting Resolution of curvature, and themost powerful. TOLER is the dis-tance from the actual arc of thecurve, and the distance you are will-ing to allow the chord of the curveto exist away from the curve. GDLwill recalculate the resolution tomatch the object. For example, aTOLER of 1 mm (1/25”) is ideal fortubular furniture and does a goodjob on curves. It’s even better onvery large structures where a maxi-mum of 36 needs to be exceeded.

TOLER could be set using variablesor IF statements, just like RESOL orRADIUS. TOLER takes, perhapsmore processor time than RADIUSand RESOL but is more powerful.

Note of Warning – RESOL, TOLERand RADIUS cancel each other outif used, so decide which one youwant to use for a model, or for acomponent of a model.

M OST of the workload of the processor during rendering is working out the values oflight and shade on each surface (polygon) in the model. If it is trying to work out Shadows, it’s also

working out the outline of the object and what the shadow will do when falling on each polygon. Fewerpolygons means faster rendering. An excess of polygons will lead to excessive rendering times, or it maycripple the model altogether – not enough RAM to finish! Sometimes, the object you are doing may not be visible(such as a nut or bolt) so why give it 36 or more polygons, especially when there could be thousands of nuts andbolts in the model? So control the curvature!

2D Symbol For the Simple Chair, we used a PROJECT2 command– the killer command that does most of the 2D work foryou! Throughout the book, I encourage you to write2D scripts properly. Scripted 2D symbols are faster forArchiCAD to draw, and they put you into the drivingseat – enabling you to decide how they shall look. Let’slook at how to write a 2D Script. Please Find and Openyour Simple Chair model.

This example is done in imperial and metric. Startwith Project2, and make sure that your new lines fol-low the outline correctly.

Build the whole chair from rectangles and a line.RECT2 defines a rectangle from the X,Y location of thebottom left to the X,Y location of the tip right. LINE2 issimilar, joining two X,Y locations together. Leave theold Project2 as a comment in case you need it back.

!Chair - 2D-Script

!Imperial

!PROJECT2 3,270,2HOTSPOT2 0,0

!SeatRECT2 0,0, 18",18"

!LegsRECT2 0,16", 2",18"RECT2 16",16",18",18"

!BackLINE2 0,16", 18",16"

2D script for the simple chair

!Chair - 2D-Script

!Metric

!PROJECT2 3,270,2HOTSPOT2 0,0

!SeatRECT2 0,0,0.45,0.45

!LegsRECT2 0,0.4,0.05,0.45RECT2 0.4,0.4,0.45,0.45

!BackLINE2 0,0.4,0.45,0.4

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 26: Cookbook3_1

1.12

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

ELBOW is for a curved tubular bendobject. It always grows up the Z-Axis,

following the course of the X-Axis. Thealpha angle can be anything from 0 to 360.

The number of polygons can be aproblem – the curvature can be control-led with the RESOL command. This is animportant issue – if you have a low resol,the curvature of the tube looks unfortu-nately angular. However, if you set a highresol, you have too many surfaces on theelbow, and it will take too long to render.

The best solution to the resolutionproblem with the ELBOW is to use theRADIUS command – in which you sepa-rate the resolution of the surface of thetube itself from the resolution of the curvethat it follows. If the ELBOW is very large,use TOLER.

Later in the Voyager course you canlearn how to make curved tubes usingTUBE, but this requires a lot more expe-rience.

The illustration of three ELBOWsshows what a clumsy tool is RESOL.The Elbow can become sadlypolygonal, or even straight. UseRADIUS.

!ELBOW Demonstration!Syntax:- ELBOW rad1,alpha,rad2ELBOW 0.12,90,0.03 RESOL 12 ADDy 0.1ELBOW 0.16,90,0.04 RESOL 6 ADDy 0.1ELBOW 0.20,90,0.05 DEL 2

!ELBOW Demonstration!Syntax:- ELBOW rad1,alpha,rad2ELBOW 0.12,90,0.03

‘alpha’ is the sweep angle of the Elbow.

CONE is like a cylinder in which theradius can be varied at the top and

bottom.

It also includes a cutting command, todecide if the top should be cut square(90,90 degree cuts) or cut like a ship’s fun-nel, at an angle. The angles are alwayscut along the X-axis, and must be posi-tive.

The number of faces on a Cone canalso be controlled with the RESOLcommand

!CONE demonstration!Syntax:- CONE height,radius1,! radius2,cut1,cut2 CONE 0.2,0.06,0.03,90,90 ADDx 0.15 CONE 0.2,0.06,0.03,40,140

END is one of the first thingsI write, after I have written a Ti-

tle of the object, the Date and myName. It is because everything infront of END is the 'Executive script'and everything after END is goingto be a useful Subroutine that needsto be stored until used. Even themost complex of objects need be nomore verbose than the examplehere. It is immensely easier to de-tect errors or make changes if thescript is written as subroutines. Puta line of dashes after the END state-ment.

!Swivel Chair!3D Script

PEN 7GOSUB 50:!Error CheckingGOSUB 300:!Foot of ChairGOSUB 400:!Vertical ShaftGOSUB 500:!SeatGOSUB 600:!Back

END:!-----------------

50:!Error CheckingIF height>0.9 THEN height=0.9RETURN

300:!Foot of Chair!etc etc!...........

L INE numbers are alwayswritten with a colon (e.g.

'250:'), and should be followed by atext comment label (e.g. '!Chairlegs'). They do not have to be insequence, but it helps you if they are.

Early forms of BASIC required anumber on EVERY line, which iswhy numbers were spaced withlarge increments e.g. 10:, 20:, 30:, 40:etc. – enabling you to insert extraones later. Now you have freedomto write without numbers. When youuse subroutines, there is nothing tostop you using large numbers like100:, 1000:, or 10000: – they aremerely labels.

END and Line numbering

More 3D Commands

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 27: Cookbook3_1

1.13

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

!Simple chair Mark 2!3D Script!GDL Discovery Course!with Parameters

wid=A !Widthdep=B !Depthp=1/25" !One pixel [or it can be 1 mm]

!LegsMATERIAL lmatBLOCK fsec,fsec,shigt-fsec ADDx wid-fsecBLOCK fsec,fsec,shigt-fsec ADDy dep-fsecBLOCK fsec,fsec,shigt-fsec ADDx -(wid-fsec)BLOCK fsec,fsec,shigt-fsec DEL 3

!SeatMATERIAL smat ADD p,p,shigt-fsecBLOCK wid-p*2,dep-p*2,fsec DEL 1

!Back ADD 0,dep-fsec,shigt-fsec ROTx -recangMATERIAL lmat BLOCK fsec,fsec,bhigt-shigt ADDx wid-fsec BLOCK fsec,fsec,bhigt-shigt DEL 1MATERIAL smat ADD fsec,0,(bhigt-shigt)/3BLOCK wid-fsec*2,fsec,(bhigt-shigt)*2/3 DEL 3

The Good ChairMake your first simple chair into a PARAMETRIC object

THE very simple chair was an example ofGDL that works – but it isn’t smart, isn’t para-

metric, and isn’t structured. So let’s look at waysof improving it. In so doing, you will learn theprimary techniques in making GDL move fromObject-making to Tool-making.

First, we will make it parametric. Click on your sim-ple chair, and ‘Open Library Object’, and you get themain parameter building window (as right for v 6.5).You can make new parameters by clicking the ‘New’button. These will give you new parameters of Length,named C, D, E, F and so on. Create parameters andchange their Variable names to sensible ones like ‘fsec’and ‘shigt’ according to the parameter table here (right).The Name here is what the User will see when usingthe dialog box that you are now creating. Put in nomi-nal Values for each parameter. In this example, they arein decimal inches.

You must decide whether a parameter is a Dimen-sion, a Number, a Material, a Pen colour or whatever.Do this by holding the mouse down on the small sym-bol; the selection palette pops up, and you can selectone type. Only use ‘Length’ for dimensions, becauseArchiCAD changes these according to your dimensionalsystem settings. For numbers which remain constant,use ‘Real Numbers’ or ‘Integers’. For materials, use thelittle cube and sphere logo. The others you will use moreas you progress with GDL.

3D ScriptTake the 3D script of the Simple chair, and change allthe 2” to ‘fsec’ (frame section). Continue to work throughall the dimensions changing them to parameters. As adesign improvement, let’smake all the legs the sameheight, and then have thechair-back permitting aninclination angle, so theleg components of theback of the chair gets writ-ten when we do the back.Because the seat height is‘shigt’, the height of all thelegs is ‘shigt–fsec’. Do asimilar small calculationfor the width and depthADD commands, allowingfor the frame thickness.

Delete the PEN com-mand – for simple objects,the user can set pen col-our in the Settings dialogbox.

Leave the 2D script as before, with the PROJECT2 orthe RECT2 routine. We will return to this chair later towork on the 2D script and to learn about Subroutines.

Parameters can be: Dimension(based on your system preferences,metric or imperial), Angle, Realnumber, Integer, Boolean choice,Text, Material, Line type, Fillpattern, Pen colour, Separator (whitespace), or Title (bold font).

Note that the use of ‘p’for a pixel of 1 mmsaves having to type

0.001 all the time. Byshrinking the size of

the seat by 1millimetre (1/25”) we

avoid a renderingproblem between seat

and legs

We are using Aand B for the

chair, so convertA and B to widand dep early

in the script

Here, we moveinto position,

rotate thecursor, then do

the upper legsand the back as

one operation,changing

Materials as wego

!Simple chair!3D Script Mark 1

MATERIAL "Whitewash"PEN 7

!LegsBLOCK 2",2",18" ADDx 16"BLOCK 2",2",18" ADDy 16"BLOCK 2",2",30" ADDx -16"BLOCK 2",2",30" DEL 3

!Seat ADDz 18"BLOCK 18",18",2" DEL 1

!Back ADD 2",16.5",24"BLOCK 14",1.5",12" DEL 1 !Back to origin

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 28: Cookbook3_1

1.14

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Tubular Handrail

EARLY on, it’s good to take a break from thetyranny of BLOCK, and try something a bit

more elegant. In this library object we look at:

• Handling cylindrical entities –CYLIND and ELBOW

• Using RADIUS to control curve smoothness• Using HOTSPOTs in 2D

ParametersAsk the user to enter small dimensions for tubing inthe form of Diameter, not in Radius. People alwaysthink of handrails and other round things in ‘diameter’.Your program can easily convert Diameter to Radius.As the handrail dimensions can be altered, A and B arenot used in this script or in the parameters box – butthey could be.

Angle – You can think of the angle in terms of theangle formed by two lines. But a tube bender, or GDLprefers to think of the ‘sweep angle’ formed by thetube, from the straight.

Radius – You want the main curve to be as smooth aspossible, but don’t want the surface of the tubing tohave 36 faces as it will take too long to render. TheRADIUS command allows you to control the surfacesof small and large curves, and to relate it to the actualtube radius. (See RADIUS in the explanation of curva-ture and in the GDL Manual.) It is confusing that GDLuses the word RADIUS for this purpose, but we haveto live with that now.

When you only want to control one set of surfacecurves, such as for cones or cylinders, you can use thesimpler command RESOL.

PEN and MATERIAL – If you make the material zero,then the PEN colour will make the whole surface to bethat colour.

If you want to ‘hand’ the finished handrail, i.e. Mir-ror it, then you can do that in the object settings box,later.

The handrails can be grouped together to form usefulstructures which would be difficult to do in any otherway.

The Origin for thisHandrail starts

drawing the tubefrom one end, and

proceeds to ‘worm’ itsway around the bend,

along the tube.

!Curved Handrail system!3D Script Mk2

trad=diam*0.5 !TubeRadiusRADIUS trad*0.5,trad*4

!prelimsMATERIAL matlPEN pcol

!Make it! ROTx -90CYLIND len1,trad ADDz len1ELBOW radc,angb,trad ADDx radc ROTy angb ADDx -radcCYLIND len2,trad DEL 5

END:!------------------

Help files + Documentation folder

IT is most helpful with ArchiCAD 6 that the manuals arenow available on-line in the Documentation folder, in

your ArchiCAD folder. In fact, you can write any documentyourself, save as Acrobat file, and put it in that folder.They appear in the HELP menu.

The search command with Acrobat makes it easier touse the GDL manual (easier than the paper version!) So itmay be easier to enjoy using your GDL manual. You canput the GDL Cookbook.pdf into the Help Menu.

Dimensional settings

EVERYBODY works in different dimensions depending ontheir country and regional building standards. The First

Chair was hard coded (written into the script). The slightlyBetter Chair was in imperial. This Tubing above is in metric,in metres. Quite a lot of the exercises here are in metric, inmillimetres. If you are not sure, open a NEW Library objectand look at A and B. If A is 1.00 you are in metres, and if Ais 1000 you are in millimetres. You have to have a projectfile open in the background while you work in GDL to getthe navigator palette to work correctly, and to set the di-mensional environment. If you modify dimensional settingsremember to set the number of decimals you can display.

Byzanti
Highlight
Page 29: Cookbook3_1

1.15

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

!Handrail 2D scriptPROJECT2 3,270,2HOTSPOT2 0,0

!First Tube ADD2 0,len1HOTSPOT2 0,0

!Round the bend ADD2 radc,0 ROT2 -angb ADD2 -radc,0HOTSPOT2 0,0

!Second tube ADD2 0,len2HOTSPOT2 0,0 DEL 5

2D ScriptAs the user can change the handrail details, you can-not use a standard symbol. You need to write a 2Dscript. For quick-to-draw objects, issue the PROJECT2command as here.

Hotspots: This handrail is a slippery object to pick upbecause the ‘Bounding box’ hotspots are going to bepositioned well away from the actual rail. You need toplant HOTSPOTs in the 2D script. Turn off Boundingboxes. The 2D cursor can be moved about in a similarway to the 3D script, using the ADD2 and ROT2 com-mands, until you find the end of the tube.

Tubular Handrail: continued

3D ScriptConvert the diameter to Tube radius. Issue the RADIUScommand based on trad.

Set the Material and Pen colours.

Starting from the end of the first tube, use a ROTx -90 to lie the handrail down horizontally (or it will growupwards). Do the first Rail by pushing out a cylinderhorizontally, then move to its end by adding along theZ axis – which is now horizontal. You can push theELBOW round the corner, as it grows along the Z axis,which is already in the right direction. Then go roundthe bend – go to the centre of the curve, rotate by theangle, and move to the start of the second tube. Pushout the final cylinder.

This script is too short to justify a strict approach tostructured programming, but you should still use theDEL command to bring your 3D cursor back to theorigin before writing END.

Using the principles of the script for this simple li-brary object, you can assemble handrail and tubingstructures of great complexity.

If you used A and B to make it stretchy, you wouldhave to work backwards from the curve radius to de-cide what the straight tube lengths would be.

Notice how the cursor movement commands areindented. When you have a long run of them, it makesit easier to count them up.

Tips and TricksAdvice Corner for GDL newbieson 4/7/00, Sarah Elliott (Graphisoft_HU) wrote:What are the most important things you tell the people whoattend your GDL classes about object making?

DNC Replies:I tried to think of three, but could only think of five!First thing is....•Dont Panic!!•Its not as difficult as you expect once you are into it, andwhen you get an error message, read the message, look atthe script; have you spelt the parameters right? Are yourcommas in the right place? Try excluding part of the scriptto see if other parts work. GDL has few bugs, for beginners;there are none to speak of; so its a relief to know that theerror will be found through hard logical thinking.Second thing is....•Always have pen and paper handy•If you can't draw it on paper, you can’t write it in GDL. Draw-ing it out on paper will put your mind at ease to concen-trate on the logical process of actually building it. For manycommands such as prisms and revolves, half the job is doneif you have drawn it out, preferably marking the origin andnumbering each point along the profile.

Third thing is....•Think in parameters•Always try to work (and think) in parameters not in num-bers – its easy to develop your own lingo of 'wid', 'dep','len', 'hit' and 'thik', and easier to write in these terms know-ing that a simple change in the parameter value will modifyyour object easily.Fourth thing is...•Steal from ArchiCAD•Some objects are so complex that the parametric methodabove is harder than beating your head against the wall.You may be better sketching them out in the ArchiCADfloorplan and then dragging them and dropping into thescript. You may have to settle for making them parametricby stretching and mirroring.Fifth thing is....•Structured GDL is best•The moment it gets more complicated than one page full ofscript, convert the script to subroutines, so that each part ofthe model is a tiny object in its own right. This also saves onrepetitive typing, and makes it easy to isolate errors.First published in Graphisoft Newsletter, Summer 2000

Byzanti
Highlight
Byzanti
Highlight
Page 30: Cookbook3_1

1.16

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Why use StructuredProgramming?

FOR SMALL MODELS, you can write BLOCKthis, CYLINDer that, CONE the other and finish

up with simple models – the scripting may not be el-egant, but it works.

However, if you make the model bigger, you willproduce a script of spaghetti-like complexity. If youstructure your 3D script with more discipline, you canbuild models of great complexity without losing trackof what you are doing – and you are able to repair it oramend it without despair. Professional programmersdespise BASIC because they associate it with amateur-ishly written, unstructured code, that only just works,that cannot produce merchantable applications, thatcan only be debugged by the original writer, and soon. The virtue of systems like PASCAL, LISP and ‘C’ isthat programs are 'object oriented', modular, structured,and so on. Perhaps this is why AutoCAD uses Lisp,and why MiniCAD uses PASCAL for their equivalentsof GDL.

But listen! BASIC, as used in GDL, does everythingthat is needed to produce 3D objects, and is perfectlycapable of being written in an 'object oriented', modu-lar, structured way, that can be debugged by otherpeople and which can produce library objects that areof merchantable quality. It's just the way you do it!!

3D Model Analysis

SCRIPTING is easier if you understand the 3Dnature of the object. All that really matters is that

you analyse the object accurately, which you must doregardless of the language you are using or thinkingin. For architects and designers who are in the busi-ness of 3D, this should be the easiest part.

So, What is StructuredProgramming?

IN the context of GDL, it means taking a very disciplinedapproach to model building, in particular these three rules

ANALYSE the model to understand all aspects of its

symmetry, repetition and es-sential geometry.

MAINTAIN strict controlover the location of the

3D cursor. Return to the ori-gin after each operation.

ORGANISE the script intoa number of subroutines

that reflect the 3D organisa-tion of the object.

The universal language of 3D is the 3D primitive –the Block, Cylinder, Cone, Sphere, Extrusion etc. Slabshapes are flat blocks, and wall shapes are tall thinblocks.

At the next level of 3D interpretation, you have slabswhich curve, holes drilled, surfaces rounded or cham-fered, extrusions taken through curved or angular path-ways, saddle shapes, lathed objects, elements repeatedaround axes, and many such variations.

At yet another level, you must identify elementswhich might change, like lights which come on, ele-ments that must be able to slide or rotate, or to disap-pear if they are too detailed, which might need ran-dom numbers, or do something special.

Think these out on paper: if you cannot draw theobject freehand in pencil, then you probably cannotscript it.

Origin and 3D Cursor

GDL gives you a 3D Cursor – a bit like theblinking cursor in Word or Excel. Whatever you

type will appear where the cursor is blinking. In GDL,if you move the cursor 2 metres upwards, and rotate itby 45 degrees, then the next thing you type will occurthere, at that angle.

Likewise, every model has an Origin – it’s like the‘top of page’ in a word processing document. As a re-sult of your ADD, MUL or ROTate commands, the 3Dcursor departs from that origin; you can then draw anobject, and then either goes on to draw something else,or you return it to the origin. If you want to keep con-trol of the model, you need to return to the origin be-fore you tackle the next part of the model.

Look at the scripts in the GDL Cookbook, and you will see a constant re-iteration of the value of Structure in programming

Byzanti
Highlight
Page 31: Cookbook3_1

1.17

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

• What investment value does your object reallyhave? Will it be used once, for your eyes only, orcould it be used dozens of times in coming years bymany people? Imagine someone else using the li-brary object, and ask yourself, which aspects of themodel really need to be parametric? What happensif the user enters negative quantities or angles? Howmany choices should the user be offered?

• Where should the model origin be? This is thepoint that usually defines the object’s height and lo-cation in the project model. It would help if it was ata centre of symmetry or rotation. Can you take ad-vantage of symmetry? – you could build half or quar-ter the model only, and then multiply or mirror therest.

• Can your object be subdivided into ‘tasks’ orelements? Take a swivel chair: this has axes of sym-metry, elements which repeat themselves, elementswhich are clearly lathed round an axis, elementswhich curve or twist, elements which hinge or bend.If you modify parameters such as length and height,do elements which elongate also have to thicken?Will they then become larger than the element theyjoin on to, or punch through it? Is there a logicalsequence to the assembly? Do the elements have‘sub-elements’? For example,with the Swivel chair,you have: multi-toed foot (with coned floorpads),central shaft (with adjusting handle), swivelling up-holstered seat (nice and curvy), upholstered backrest(also curvy), and support for the back rest (metallicwith adjusting handle.)

• Are there hinging or sliding elements? In howmany planes do they hinge or slide? Is there a suc-cession of moving elements, such as in the humanarm? (in which, you get rotation as well as hinging!)

• What elements are repetitious and can be donewith loops? Are some quantities unknown? Per-haps they will be generated after the user has en-tered a parameter – e.g., the number of rungs of aladder depends on the height and slope of the lad-der, assuming a regular spacing.

• Which commands (in GDL) would best achievethe result? If you analyse the model into primitives,are the elements formed from cylinders, cones,prisms, tubes, extrusions, cut objects, blocks orspheres? There are frequently more ways than oneto ‘cook your fish’.

• What maths or circle geometry problems areinvolved? How may arcs or circles are there, andcan you locate their centres, and calculate their ra-dii? Are curved shapes circular, elliptical or parabolic?

• Can you estimate the required ‘level of detail’accurately? Do you really need to show planar glaz-ing fittings, or handles on the doors? Could you getaway with using 2D elements in the 3D model? Isyour level of detail (LOD) likely to generate too manypolygons?

• Are you planning to animate the model at somestage? If so, is it worth considering writing objectsthat hide themselves or reduce their level of detailwhen the camera is a long way away??

These need thinkingabout...

PENPEN sets the pen colour. This can be changed duringthe execution of the script, so that different parts ofthe model can be drawn separately.

On PEN, there are some points to note: PEN musthave a value. You cannot have PEN zero. PEN 1 givesyou Black line in AC6.0 and earlier, but you need PEN7 for black in AC 6.5 – an immediate illustration of thebenefit of making your object parametric.

Another good reason is that people can modify thePEN palette and the pallete values can be re-assignedin colour and line thickness. This can have mischie-vous effects on your model. It is best therefore not tohard code the PEN colours, but to make them param-eters so that the user can select them.

It is not essential to set Pen colour for simple ob-jects as the pen colour can be set by the user in themain Object Settings dialog box. But if the object iscomplex make use of the PEN command to controlappearance of different parts of the object.

Material obtained from PenPEN can be used as a convenient way to create brightcoloured surfaces. If you set MATERIAL to zero, thenthe PEN colour becomes the surface colour. This is whymost of your first efforts at modelling come out asGREEN, BLACK, PINK or another colour – the materialis becoming the same colour as the default pen colourif no material has been specified.

Comma confusion?In some countries, it is common to write decimal points ascommas e.g. 1,25. In other countries it is common to writethousands with commas for example, a million is 1,000,000.If you have a localised ArchiCAD, this is how numbers may

appear in the parameters box. But in GDL, the scripts are hardcoded so only one convention can be followed. Dots are usedto form the decimal point, and commas are used to separatenumbers. Many of the errors in your early efforts in creativeGDL will be with misplaced dots and commas. Be rigorouslycareful with them.

Byzanti
Highlight
Byzanti
Highlight
Page 32: Cookbook3_1

1.18

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

For further reading on the syntax of BASIC, it is worthconsidering getting a book on BASIC. Although theseare probably more difficult to find in the 21st Centurythan books on C++, there must be some in librariesand well stocked bookshops. If not, you will have tolearn from the GDL Cookbook!

The ‘Subroutine’

THE subroutine is a short portion of script thatperforms an action, and then finishes with the com-

mand RETURN, which tells GDL to go back to theGOSUB command that it came from; and then to con-tinue with the program. Subroutines live in the regionfollowing the END command. A subroutine starts witha number so that you use that number when you writethe GOSUB command – e.g. GOSUB 200.

The subroutine should behave like an elementalobject in its own right. If you want to move the ele-ment sideways, or swivel it, you apply those move orswivel commands to the cursor, and then GOSUB thesubroutine.

Here is a typical subroutine, numbered 250: Thenumber must always be followed by a colon and youshould add a comment line after the number, so thatyou know what the subroutine is actually doing. Ineach subroutine, there must be exactly the right numberof DELs to ensure that the cursor returns to the sameplace as it was at the start of the subroutine.

About Subroutines...

THE essence of structured programming inGDL is that 3D models should consist of sub-

routines which reflect the 3D nature of the model.The other point of using subroutines is to avoidever having to type out complex GDL commandsmore than once.

The ‘Executive Script’

THE first part of the script (as far as the ENDstatement) can be called your ‘executive script’.

This is the main controlling script, that decides on whatwill be drawn, and in what order. When GDL reachesthe END statement, it stops.

After the END statement, you carry a lot of usefulbaggage, called Subroutines. Each element of themodel could be a subroutine. They can only be used ifthey are called by the executive script, or by anothersubroutine. The END statement prevents them frombeing read accidentally.

It is a good idea to keep the executive script shortand decisive. When you want to repair, modify or ex-tend the model, you will know exactly which subrou-tine to go to.

Golden Rules forSubroutines!• Subroutines are always written after the END statement.END is essential – you must never accidentally run fromthe executive script into the subroutines.• Subroutines always start with a Line Number, and fin-ish with the statement ‘RETURN’, otherwise, GDL will acci-dentally run into the next subroutine.• The subroutine must be entirely self contained – the 3Dcursor must finish up exactly where it was at the start ofthe subroutine. So you DEL all the ADD, ROT and MUL com-mands within the Subroutine. Never use DEL TOP for thispurpose.

• Never GOSUB the subroutine you are already in, or GDLwill go on trying to do this for ever (Cmd-period to stop).• Never use a GOTO command to jump out of a subrou-tine – you will get quite lost!• Subroutines can GOSUB other subroutines: For example,in the human body, an Arm is an object written with a sub-routine; but the Arm will need another subroutine to drawthe object called Hand, and the Hand will need one for eachof the objects called Finger.• The 2D, 3D and Properties scripts can use Subroutines;but do not jump to one in another script from the one youare in! Note, You cannot use END or Subroutines ina Master Script.

!Swivel Chair - 3D executive script

GOSUB 50 !Error CheckingGOSUB 300 !Foot of chairGOSUB 400 !Shaft of chairGOSUB 500 !Seat of ChairGOSUB 600 !Back of ChairEND !-------------

250:!Two Spheres subroutineSPHERE 0.1 ADDx 0.2SPHERE 0.05 DEL 1RETURN A typical Subroutine

Re-read these rulesfrequently when yourfirst attempts do not

work correctly!

A typicalExecutive Script

The example here is what you should be aiming to-wards. Every GOSUB command is telling GDL to GOand run the SUBroutine of that line number.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 33: Cookbook3_1

1.19

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

!Simple chair Mark 3!3D Script!GDL Discovery Course!Using Subroutines

wid=A !Widthdep=B !Depthp=0.001!One millimetre pixel

GOSUB 100:!LegsGOSUB 200:!SeatGOSUB 300:!Back

END:!------------------------

100:!LegsMATERIAL lmatBLOCK fsec,fsec,shigt-fsec ADDx wid-fsecBLOCK fsec,fsec,shigt-fsec ADDy dep-fsecBLOCK fsec,fsec,shigt-fsec ADDx -(wid-fsec)BLOCK fsec,fsec,shigt-fsec DEL 3RETURN

200:!SeatMATERIAL smat ADD p,p,shigt-fsecBLOCK wid-p*2,dep-p*2,fsec DEL 1RETURN

300:!Back ADD 0,dep-fsec,shigt-fsec ROTx -recangMATERIAL lmat BLOCK fsec,fsec,bhigt-shigt ADDx wid-fsec BLOCK fsec,fsec,bhigt-shigt DEL 1MATERIAL smat ADD fsec,0,(bhigt-shigt)/3BLOCK wid-fsec*2,fsec,(bhigt-shigt)*2/3 DEL 3RETURN

F IND the Simplechair we made ear-

lier. We shall try to ‘struc-ture’ it. The first practicalstep to making your scriptmodular (or structured) isto learn how to use subrou-tines.

Here, we try changingthe script from the raw (butparametric) script into sub-routines. It is an easy pro-gressive change.

First number the groupsof commands. Each onewill become a subroutine.Make sure that in eachgroup, the number of DELsis right in that the cursorgoes back to the origin eachtime. Use 100’s to incre-ment the numbers of yourgroups.

Next, put in the ENDcommand, clearly markedwith a comment markerand a row of dashes. Thissignifies the end of the mainpart of the 3D script (the‘executive script’).

What follows now is a series of Subroutines whichhave to be called with a GOSUB command. Put theword RETURN at the end of each subroutine. Now,in the Executive script, write GOSUB followed by theLine number and a copy of the name of the subrou-tine – do it as I have done here.

If it doesn’t work (you get errors) it’s due to forget-ting the colon after the line numbers, or forgettingEND or RETURN. Perhaps you didn’t get the numberof DELs right. Go over my example until you get itcompletely right.

Whenever you are in doubt, go back to the page onSubroutines, and thoroughly check through theGolden Rules on Subroutines.

Improving the Seat routineIn the Simple chair there is an unpleasant clash ofmaterials for seat and leg at the rear of the chair. Theroutine with ‘p’, a one millimetre ‘nudge’, improvesthe appearance.

2D ScriptBecause the Chair is able to recline at different angles,it is more difficult to write a script in 2D and may beeasier to just use PROJECT2 3,270,2. You would needtrigonometry to work out where the back appeared inthe 2D plan. Put in A-B Hotspots as shown, and yourchair will become S-T-R-E-T-C-H-Y!

!Simple chair Mark 2!3D Script!GDL Discovery Course!Using Parameters

wid=A !Widthdep=B !Depthp=0.001!One millimetre pixel

100:!LegsMATERIAL lmatBLOCK fsec,fsec,shigt-fsec ADDx wid-fsecBLOCK fsec,fsec,shigt-fsec ADDy dep-fsecBLOCK fsec,fsec,shigt-fsec ADDx -(wid-fsec)BLOCK fsec,fsec,shigt-fsec DEL 3

200:!SeatMATERIAL smat ADD p,p,shigt-fsecBLOCK wid-p*2,dep-p*2,fsec DEL 1

300:!Back ADD 0,dep-fsec,shigt-fsec ROTx -recangMATERIAL lmat BLOCK fsec,fsec,bhigt-shigt ADDx wid-fsec BLOCK fsec,fsec,bhigt-shigt DEL 1MATERIAL smat ADD fsec,0,(bhigt-shigt)/3BLOCK wid-fsec*2,fsec,(bhigt-shigt)*2/3 DEL 3

!Chair - 2D-Script HOTSPOT2 0,0 HOTSPOT2 A/2,B/2 HOTSPOT2 A,0 HOTSPOT2 A,B HOTSPOT2 0,BPROJECT2 3,270,2 !The object!

The four mainones are forstretching, andthe middle one isfor picking up

Converting a scriptinto subroutines

Page 34: Cookbook3_1

1.20

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

W HEN we talk about ‘programming’ we are often

thinking of the ability of our script totell the computer to follow a path,make decisions, follow courses of ac-tion based on those decisions orupon pre-ordained rules, and thusdisplay a level of ‘articifial intelli-gence’.

The IF statement is the essentialmechanism by which computersmake decisions – whichever lan-guage they are working in.

IF statements can stay on one line,or can refer to a long sequence ofcommands. Examples are given here.

ENDIF means that it has reachedthe end of the long version of the IFstatement.

ELSE Finally, you could have twocomplicated tasks to do, one if the IFcondition is true, and the other if it isfalse. You use ELSE to help decidewhether to do one task or the other.In this case, ELSE must be on a lineby itself.

Nested IFStatementsAs the GDL parser encounters eachIF... THEN, it remembers it, and as itencounters each ENDIF, it signs it off.So you can ‘Nest’ many IF.. THEN..ENDIFs inside each other, and themachine keeps count accurately.You may lose count though, so Idon’t encourage excessively com-plex nests.

IF s=13 THEN ADDz 1.2 GOSUB 250 nq=1 DEL 1ELSE ADDx 0.3 GOSUB 150 DEL 1ENDIF

IF s=13 THEN GOSUB 250

This is the simplest example ofan IF statement. If the IF condi-tion is ‘false’ (i.e. ‘s’ is not equalto 13), then the program contin-ues to the next line.

IF p>13 THEN n=1 ELSE n=0

This is an extension of the IF state-ment; if the first IF condition is not‘true’ then it will take an alternativecourse of action. In this example,one is setting a flag called ‘n’ to val-ues of 1 or zero.

IF s>13 OR s<26 THEN GOSUB 250IF nq=1 AND s<13 THEN GOSUB 150

Long IF Statement

In this example, there are so many things to doas a result of the IF statement that it can no longerfit on one line. So you leave the first line with a‘THEN’ hanging off the end of the line. Every-thing on every line after that will then work ifthe IF statement is true. If the IF statement is false,GDL ignores the whole group, until it reachesthe ENDIF statement – logically. If there is analternative action required (in case the first IFstatement is false, then you can use the ELSEcommand to make it do something else.

Elsewhere in the Cookbook, you may find examples of ‘Nested’ IF...THEN... ENDIF statements – where one entire IF... ENDIF statement isinside another. You may also find examples, as above, where a‘Boolean’ choice is to be made, using AND and OR.

IF... THEN... ELSE... ENDIFOr.... how machines make decisions

IF Curr<0 THEN IF closd=1 THEN PRINT "Holes not allowed" END ELSE closd=1 ENDIF ELSE IF Curr>=900 AND Curr<1000 THEN S900X=CurrX-OrX S900Y=CurrY-OrY ELSE IF int(Curr/2)%2 THEN IF int(Curr/64)%2 THEN StatusE=2 ELSE StatusE=0 ENDIF

ELSE StatusE=1 ENDIF IF int(Curr/4)%2 THEN StatusP=-1 ELSE StatusP=1 ENDIF IF Curr>=4000 AND Curr<=4100 THEN GOSUB 4000 ELSE SHX[PtCount]=CurrX-OrX SHY[PtCount]=CurrY-OrY SHM[1][PtCount]=StatusE SHM[2][PtCount]=StatusP PtCount=PtCount+1 ENDIF ENDIF ENDIF

This small chunk ofa script by one of theworlds most expertGDL artists, OlegShmidt reveals howcomplex you can getwith nested IF...ENDIF statements

Building Signage: putting a pictureinto the projectLennox Boyd wrote:I wish to place an external sign on a building. How is thisdone?Mike O'Brien <[email protected]> writes:1. Create a picture file as a pict file on the Mac, or .bmp onWindows (jpeg or tif will also be acceptable).

2. Put your picture file into one of your library files and re-load the libraries. It has to be in a loaded library to work.3. Open the Library Object Settings box (doubleclick on thechair button). Select the ‘picture 65’ library object (in sec-tion 01 of the library objects) and type in the name of yourpict file in the parametric place (called ‘picture file name’).4. Place the library object on your floor plan.5. Photorender. The picture only shows when youphotorender. Otherwise the frame is empty, and you see arectangle in 3D.

Page 35: Cookbook3_1

1.21

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

BAD Chair example

Do not type thisscript in!!....it’s an example of the untidy kindof scripts you write when you firststart writing GDL scripts.

Let’s notice the goodpoint(s) first:• The script results in a chair!

Therefore, it is not all bad!!

Criticism of Script• The script is ‘sequential’ instead of being or-ganised into a modular structure. For example,in this script, the entire leg is written once, andthen it is written all over again, nearby. This iswasteful, and difficult to edit later. The legs, be-ing the same, should be repeated in a neater way,either using a LOOP or a SUBROUTINE.

• The PEN colour should also be a parameter incase pen colour 1 is not what the user wants.

• Make even more use of COMMENTS, INDENTSand CARRIAGE RETURNS in the script to make iteasier to understand. Indents are used in this ex-ample, but there is no logic to them. Indent cur-sor movements.

• The Model starts from the bottom left corner,although it would be better with a symmetricalobject to start from the Centre line.

• The material for the legs is specified after theyhave been drawn. They will turn out green!

• The entire script is written in lower case. Al-though lower case is easier to read, it is more dif-ficult to pick out commands from comments andvariable, and it is therefore more difficult to editthe script. ALWAYS use •UPPER• case for com-mand words and •lower• case for comments andvariables.

• The script makes occasional use ofmultistatement lines using the colon: – eg addy -.03:roty -5 on one line. This is legal syntax, but isbad because you will have problems debuggingthe script.

• It is bad to write numbers in the form .03. Al-ways give low numbers a leading zero, e.g. 0.03.

• It is not parametric. The script specifies all ma-terials and dimensions very specifically – whereasyou should provide the user with all the param-eters they need in the dialog box. All these mate-rial names have changed in ArchiCAD 6.5 on-wards, so they will not be recognised.

• At the end of the script, no attempt is made tobring the cursor back to a final resting place atthe origin.

• Although the author brings the cursor back be-fore beginning the next operation (most com-mendable!), there are far easier ways to do it; in-stead of wriggling backwards in reverse, use theDEL command.

• PROJECT2 is quite legal in the 2D script but it isalways better to try a real script with RECT2 andLINE2 commands. Also, you should add in someHotspots.

The side elevation shows thatit still works, even though it isa bad script!

This cookbook is allabout learning to used

‘structuredprogramming’

techniques.It is easier to learn from

mistakes than fromsuccesses – so please

look at the criticisms onthis page when you have

tried some scriptsyourself.

If you make mistakeswith a sequential scriptlike this, you get tangleslike the one here – and

you find it very difficultto disentangle the

distorted framework.

IF you are working at home, you may havelooked through pages in the GDL Cookbook. Look

at the script on this page, and CRITICISE! Come backto it later for another read when you have done morescripting.

IF you have been on the Lift-Off course, theprinciples of Structured Programming and good ty-

pography will have been explained to you by now.

! Tubular Steel chair! badly written GDLPen 1! Draw Legsblock .03,.03,.45block .45,.03,.03addz .45block .45,.03,.03addx .45roty 5block .03,.03,.45roty -5addz -.45: addx -.45addy .45block .03,.03,.45block .45,.03,.03addz .45block .45,.03,.03addx .45roty 5block .03,.03,.45roty -5addz -.45: addx -.45addy -.45Material "Chrome"!Seataddz .48Material "LimeStone"!Seatblock .45,.48,.05addx .44addz .15!Backroty 5addy .03block .05,.42,.28

!2D ScriptPROJECT2 3,270,2

Byzanti
Highlight
Byzanti
Highlight
Page 36: Cookbook3_1

1.22

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

slenr=colht/colwid !Slenderness RatioIF slenr>24 THEN PRINT “Warning, Column Slenderness Ratio is:”,slenrENDIF

PRINTPRINT is a way of getting GDL to tell you or the user something – usedin pointing out errors, or in debugging. The warning box only showswhen you display in 3D.

My advice is not to use it unless you have a very important object,and a very important message to tell the user. If you do it for common-place objects like windows, the user could be faced with 20 or 50 iden-tical shouting warning boxes, and would not know which object waswrongly set.

Using the PRINTCommandPRINT is most useful during the writ-ing and debugging process, for exam-ple, to see if the result of a Trigono-metrical calculation is giving the rightresult. Execution of the 3D script ishalted at the Print command, so it’sa good way to test something evenwhen it isn’t fully working.

It’s also useful if you lack a pocketcalculator capable of Trig or complexfunctions. Type in a quick expressionand get the answer.

Steps in 2D – Dimension ToolYOU might think the GDL Cookbook was only

about 3D modelling – Not so! 2D scripting can beuseful for practical work.

This dimension tool is simply a dimension line withtwo witness lines, but it is stretchy (or you can type inthe dimension) and allows Metric and Imperial, and achoice of tick marks.

ParametersThe Font size in millimetres is based •absolutely• on the plotting orprinting size, and disregards the scale of the drawing. (You can buy acommercial dimension tool from the author which include autosizingfonts.)

Here, we try using Boolean parameters, which allow a simple binarychoice between OFF or ON. These are sent to the GDL script as beingzero or one. A better solution is to use a Value list (Pop down menu)which we get onto in a few pages.

2D ScriptThe Hotspots are key to making it stretchy. The IF... ELSE.... ENDIF state-ments illustrate how alternative actions can be taken. Note also that aline that ends in a comma is assumed to continue on to the next line. (Ihave to keep scripts narrow so they fit the page!)

Finally, for the TEXT2 display, it is always necessary to define thefont and style of the text, so this is jumping you ahead a little. Type it inas you find it for now, and have a look ahead at the pages in the manualand here on DEFINE STYLE. This method forces TEXT2 to display anumber (signified by the ‘%’ sign) to be in Metres or in Feet+Inches, andthe 0.8 forces it to a precision of 1/8”.

!Dimensioning Tool!2D script!Hotspots - Stretch&PickupHOTSPOT2 0,0HOTSPOT2 A,0HOTSPOT2 A/2,0HOTSPOT2 0,-BHOTSPOT2 A,-B

!Dim_Line & Witness LinesLINE2 0,0, A,0 !Dim_lineLINE2 0,-B, 0,B*0.2LINE2 A,-B, A,B*0.2

!Dimension markersIF marks=0 THEN LINE2 -A/100,-A/100, A/100, A/100 LINE2 A-A/100,-A/100, A+A/100, A/100 ELSE CIRCLE2 0,0,A/100 CIRCLE2 A,0,A/100 ENDIF

!TextDEFINE STYLE "diasty" "Geneva", fsize,5,0SET STYLE "diasty"

IF units=0 THEN TEXT2 A/2,0,STR('%0.8 ffi',A) ELSE TEXT2 A/2,0,STR('%m',A) ENDIF

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 37: Cookbook3_1

1.23

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Tubular Steel Chair

HERE is a different chair – but rendered in round tubes– like the original Breuer chair.

This chair is a useful starting exercise in

• Handling straight and curved tubular sections• Keeping track of many 3D cursor moves• Structuring the program in the form of subroutines• Using Symmetry and Mirroring

ParametersTake a copy of the previous chair and let's change it radically – using cylindersand tubes – add some extra parameters for Seat thickness, Pen colour and aBoolean option to change the 2D view of the object.

We are going to make the origin in the centre front of the chair, go out halfa width, draw one leg, all in subroutine 100. Then repeat that on the other side(mirroring the first). Then finish off with the seat and back, all in subroutine200. The steel of this tubular chair meets at the bottom. It could also do at thetop, but I am trying to keep this simple!

Master ScriptUse this now, for the first time. It’sfor parameters etc. that are neededby both 2D and 3D scripts.

‘Crad’, ‘trad’ and ‘clen’ are exam-ples of ‘internal parameters’. Thismeans a parameter that is notchangeable by the user in the nor-mal dialog box. The best place forthese is in the Master Script. The au-thor of the script can tweak the valueof ‘crad’. ‘clen’ is calculated on thefly.

3D ScriptTo simplify matters, the curved bendradius ‘crad’ is 3 times the tube ra-dius. We also add the RADIUS com-mand to control the two curvaturesof tube bend and tube surface. Itdramatically shortens the time takento render just one chair – imagine alecture room or café filled with suchchairs!

Aim for this...

Worm your way round the tube

!Tubular steel chair!Master Script

wid = A !<-these could bedep = B !<-in Master scripttrad = fsec/2 !Tube radiuscrad = trad*3 !Curv radiusbhit = bhigt-shigt !back ht.sinr = SIN(recang)

!Tubular steel chair!3D Script

PEN pcol RADIUS trad,trad*2

GOSUB 100: !Leg MULx -1GOSUB 100: !Leg DEL 1GOSUB 200: !SeatGOSUB 300: !Back

END!----------------------

If you are a bit adventurous, you couldtry making a larger curve radius, leaningthe front tubes of the frame, and closingthe frame at the top of the back.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 38: Cookbook3_1

1.24

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Tubular Steel Chair: continued

All these ROTs and ADDs arenecessary to get the cursor to the rightposition for the chair back.

300:!Back for Cyl chairMATERIAL smat ADDx -wid/2+fsec ADDy dep-crad ADDz shigt-sthik+crad-trad ROTx -recang ADDz bhit/3BLOCK wid-fsec*2,sthik, bhit*2/3-crad DEL 5RETURN

200:!Seat for Cyl chairMATERIAL smat ADDx -wid/2 ADDz shigt-sthikBLOCK wid,dep-crad,sthik DEL 2RETURN

This uses the same numberingsystem for the subroutines in thesimple chair

Axial Symmetry: Because of the symmetry of a round tube chair,you can see the great advantage of starting from the Centre Line,doing only one leg, and then mirroring that whole leg. The MULcommand multiplies everything in the direction of the axis. SoMULx -1 makes the leg draw itself.

100: Starting from the centre back of the chair, you ‘worm’ yourway round the tubular frame, issuing Cylinder and Elbow com-mands as you go. Almost always, you have to issue a ROTz to getthe next Elbow to grow in the right direction – it always wants togrow over the X-axis.

The way of getting round the final corner is the same as for theHandrail. The height of the vertical leg cylinder is tricky, so it iscalculated on a line of its own, then used as ‘clen’ in the script.

Upholstering the chair200: and 300: The Seat is easy to place (BLOCK command) butthe Back is more difficult. Maneouvring up to the right place forthe Back of the chair (which rests *between* them) proves to be abit tough.

We could move in just three moves, not seven; but I advise youto keep your moves separate when it is this complicated. Whenyou look at the script later, it is easier to see how the figures werearrived at.

100:!Cylindrical LegMATERIAL lmat ADD 0,dep,trad ROTy 90CYLIND wid/2-crad-trad, trad ADDz wid/2-crad-trad ROTz -90ELBOW crad,90,trad ADD crad,0,crad ROTy 90CYLIND dep-crad*2,trad ADDz dep-crad*2 ROTz -90ELBOW crad,90,trad ADD crad,0,crad ROTy 90!(Work out cylinder height)clen=shigt-crad*2-trad*2-sthikCYLIND clen,trad ADDz clenELBOW crad,90,trad ADD crad,0,crad ROTy 90CYLIND dep-crad*2,trad ADDz dep-crad*2 ROTz 180ELBOW crad,90-recang,trad ADDx crad ROTy 90-recang ADDx -cradCYLIND bhit-crad,trad DEL 18RETURN

2D True Viewusing Project2

!Tubular steel chair!2D Script

PEN pcolHOTSPOT2 -A/2,0 !StretchyHOTSPOT2 A/2,0 !hotspotsHOTSPOT2 -A/2,BHOTSPOT2 A/2,BHOTSPOT2 0,B/2 !Pickup

PROJECT2 3,270,2

2D Scripted View

worm your wayround the

tubular frameissuing

cylinders orelbows as you

go, andadjusting your

3D cursor ateach junction

This is a classic ‘stretchy script’ foralmost any object. Other objectsmay have their origin in the centreor the corner, so you can adjustthe A and B references in theHotspot statements.

2D ScriptIf the chair was not stretchy, you could do aPROJECT2, place the chair on the plan, Explode it,copy the lines and arcs, and paste into the 2D Sym-bol window of the chair. To be sure of it working,type FRAGMENT2 ALL,1 into the 2D Script. This isbecause objects which have had a script and laterhave a symbol seem to steadfastly ignore this fact.‘Fragment’ forces them to pay attention.

As the user can change the chair style and size,you need to write a short 2D script. For quick-to-drawobjects, just issue the PROJECT2 command as here.You need to organise a ‘nest’ of Hotspots at each cor-ner and one in the middle to make sure the chair willstretch correctly.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 39: Cookbook3_1

1.25

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Refinement of the 2D scriptA properly written 2D Script may take longer to write,but for a complex or and investment object, it savesmasses of time in the redraw process of the projectplan – this is especially important with furniture.

Boolean Choice: If the user decides to have a trueplan of the object in the 2D symbol, they can opt for aTrue View, alternatively, they can have a simplified 2Dscripted symbol. Create the ‘truvu’ parameter.

The hotspots remain in the same place. But younow have a long IF statement allowing a choice: use aProject2 or draw the chair with easy 2D commands.

For the scripted symbol, draw rectangles, for thelegs and the seat; and one rectangle whose Y dimen-sion is determined as the function of the back heightand the SIN of the back slope.

How does one know how to use Trigonometry todetermine XY locations? Well the GDL Cookbook hasreminders of easy trigonometry, which is all you needto know! It is best to do a diagram on paper of whatyou are trying to achieve.

!Tubular steel chair!2D Script

PEN pcolHOTSPOT2 -A/2,0 !StretchyHOTSPOT2 A/2,0 !hotspotsHOTSPOT2 -A/2,BHOTSPOT2 A/2,BHOTSPOT2 0,B/2 !Pickup!PROJECT2 3,270,2 !Test

IF truvu THEN PROJECT2 3,270,2ELSE

100:!LegsRECT2 -wid/2,0,-wid/2+fsec, dep+bhit*sinrMUL2 -1,1RECT2 -wid/2,0,-wid/2+fsec, dep+bhit*sinrDEL 1

200:!SeatRECT2 -wid/2,0, wid/2,dep-crad

300:!BackRECT2 -wid/2,dep-sthik+bhit*SIN(recang)/3, wid/2,dep+bhit*SIN(recang)ENDIF

Tubular Steel Chair: continued

GOTO is something that I never use, as itthe worst thing that you can do if you believe in

the structured programming approach. You can issuea command such as: ‘GOTO 250’, and it will jump tothat numbered line. It doesn’t care if the number ispart of a subroutine, it doesn’t check as to whether it isalready in a subroutine. It just jumps, even if it is ille-gal. Chaos can be the result.

GOSUBs are OK because they return after they havecompleted; they remember where they came from.GOTOs have no way to return safely; the execution ofthe programme carries on like a runaway horse.

Early Graphisoft library objects are littered with doz-ens of GOTO’s, perhaps to discourage users editingthe scripts.

You can even omit the THEN, or omit the GOTO – aslong as one of them is present. But why am I telling youthis? It’s just bad to use GOTO except in emergency.

The use of Subroutines, Loops and IF.. THEN.. ELSEcommands should give you ways of getting roundevery possible situation where you might want or needto use GOTO.

Before the FOR... NEXT Loop was invented, onecould make something that behaved like a loop, usingGOTO. But now, there should be no need for it in cleanscripting.

If the GOTO is going to a location so close that it iswithin ‘eyeshot’, i.e. when viewing the script the desti-nation can be seen without scrolling, then I would re-luctantly accept its use – just (if the numbering systemwas rational and sequential).

The wickedness of GOTO

Tips and TricksMultiply, don’t Divide!Processors find it much easier to multiply than to divide.To divide once can take perhaps 32 cycles of a processorstime, whereas a multiplication can take 1, 2 or 4 cycles,depending on which processor we are talking about, andwhether it is optimised for floating point or integer. Soalthough it may be easier on the eye to write an expres-sion like'LET len=wid*3/4', it may process faster in the form 'LETlen=wid*0.75'. Seriously, the time difference would onlymatter on extremely long scripts. You are better off writ-ing efficient code, by using polylines and clear structure.

p=0if p GOTO 1PRINT "hello'1:END

p=1if p THEN 1PRINT "hello'1:END

recang

bhit

we want thisdimension: it isbhit*SIN(recang)

When you get further, I advocate the use of POLY2instead of RECT2, so you can define fill pattern andmake the chair opaque in plan.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 40: Cookbook3_1

1.26

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

FOR... NEXT LoopsThe inexhaustible workhorse of GDL

FOR k=1 TO n: NEXT k

FOR non-programmers, the FOR... NEXT Loopseems at first perhaps the greatest challenge. It is

in reality your strongest friend, because it has tremen-dous capacity for work. With a few economical linesof script within a FOR... NEXT loop, huge lattices orstructures can be created.

When you want to repeat an operation, there willbe more than one way in which you can repeat it. Thinkof music. On your guitar, you can strum a chord tentimes, at your own speed – so NUMBER is the control-ling parameter. On the other hand you could strumthe chord continuously until the conductor tells you tostop. Try changing the interval of the strum. In this caseTIME is the parameter – the frequency of each chord,and duration of the total will determine how manychords get played. In the 3D world, DISTANCE can be

FOR k=1 TO 4 CYLIND 2,0.2 !Pole ADDx 2 NEXT k DEL 4

FOR dist=0 TO 3.0 STEP 0.5 ADDx dist CYLIND 2,0.2 !Pole DEL 1 NEXT dist

Let’s plant 4 poles at 10 metre spacing

IN this script we nominate ‘k’ to be a counter – thevalue changes from 1 to 4. Every time that GDL reads

through the loop, it increases the value by 1. So thefirst time, k=1 and it draws the pole, moves sideways10 metres, then encounters the NEXT k command. Atthis point GDL asks itself if ‘k’ has reached 4 yet. If ithas not yet reached 4, it goes back to the first line, andruns through the loop again – until it finishes.

As you have moved 4 times, you have to issue aDEL 4 command at the end to get back to the origin foryour next action.

As a matter of discipline, always try to use i, j, k, m, orn for loops based on round numbers (integers). Neveruse these variables for anything else, especially not RealNumbers like dimensions. If your loop is based on realnumbers, use p, q, r, s or t, or something like ‘dist’.This tradition dates from the days of Fortran, but it isgood, in that it reduces the risk of getting in a muddle.

Let’s plant an unknown number of poles

WE don’t know how many poles there will be –let GDL work that out for us – until we run out

of road. We have three metres of road to plant. In thiscase, ‘dist’ acts as a distance dimension. Do not use ‘k’here. It is best to associate ‘k’ in your mind with inte-ger counters, not with ‘real numbers’. In the first runthrough the loop, ‘dist’ is zero, so the cursor moveszero, plants a pole, then returns to the origin – andthen does it again with a new value of ‘dist’. For this,the loop needs to be told the ‘stepping’ rate of eachcycle in the loop. If no stepping rate is given, it as-sumes you mean a value of One. Here, you want tostep half a metre each time.

As you have been using DEL inside the pole plant-ing loop, you do not need to finish with a DEL. Moreo-ver, you do not need to worry about how many polesto plant. When it has planted 7 poles and reached adistance of 3.0 metres, it realises that if it plants an-other, it will go to 3.3 metres, which is too far. There-fore, it stops at 3.0 metres run.

a parameter – where spacing and total distance coulddecide how many floor joists get laid.

In the FOR statement on the left, read it to yourselfin slow, elongated english. Using a counter called ‘k’,for values of ‘k’ starting with 1, Do What Has to beDone, then go round again, incrementing ‘k’ by 1 toits next value until it reaches a value of 4. When ‘k’reaches 4, you have finished, so continue to the rest ofthe script.

NEXT: In every case, NEXT must be followed by thename of the variable. In a more complex model, youcould have some FOR...NEXT loops nested inside eachother, and it is important that GDL knows which loopyou are referring to.

LOOPS: Some Golden Rules• Loops can be based on Distance, Angle or Number.• Do not change the value of the variable that is being usedas the counter or the end of the loop while in the loop.

• Once you are in a loop, you must never branch out of it,except to use a Subroutine. GOSUBs are perfectly safe. GOTOcommands are quite forbidden, unless you go to a label in-side the loop.• If you don’t know exactly how long the loop will be, useREPEAT... UNTIL, or WHILE ... DO... ENDWHILE

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 41: Cookbook3_1

1.27

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Other types of Loop

Stretchy Beam ToolMain value of thisexercise:

• To make things stretchy –do this whenever possible.

• Using a dual 2D script – Ifit is difficult (tilted) THEN usePROJECT2, ELSE when it iseasy (untilted) use a 2D script.

THIS is a useful little object that I give to my students, and it makes 3Dmodelling in ArchiCAD almost as easy as using good old ModelShop of

years gone by. It is simply a stretchy rectangular object that can be dropped intothe plan, stretched into shape, set material and height. Put several of them to-gether, save them and you have a new Library object without having to use GDL!It’s a great way to knock up pergolas, frames, furniture etc. – easier than usingSlabs and Walls. I made a glass Elevator car entirely out of BeamTool – with lotsof detail – and a group of my students built an entire timber framed house!

3D ScriptDo it with BLOCK. If you wanted to be able to varythe top, side and bottom colours, you would have todo it with a cPRISM command.

2D ScriptThe HOTSPOT commands give the object stretchiness.When the object tilts, you can no longer use RECT2 soyou use an IF...ENDIF statement to generate a PROJECTview of the object.

End noteIf you do this with SLAB instead of BLOCK, you canturn it into a Rafter tool, with sheer edges.

!Beamtool!3D-Script

MATERIAL bmatPEN bpen

ROTx tiltBLOCK A,B,higt DEL 1

!Beamtool!2D-Script

HOTSPOT2 0,0 HOTSPOT2 A,0IF tilt THEN PROJECT2 3,270,2ELSE RECT2 0,0,A,B HOTSPOT2 0,B HOTSPOT2 A,BENDIF

REPEAT...UNTIL / DO WHILEOTHER commands related to loops areREPEAT...UNTIL, and DO WHILE and WHILE... DO...ENDWHILE. I have found REPEAT... UNTIL to be thebest way of running a loop where only a trial-and-er-ror approach will work. For example, if the end valueof the loop is constantly changing (if it’s generated asa random number) or you want to go on doing some-thing until you exceed a certain value, then useREPEAT...UNTIL.

Example of REPEAT UNTIL: In Music, you might beplaying something very modern where you strummedthe guitar at random intervals – and finished after afixed time of twenty minutes. This is a REPEAT UNTILloop. Everybody will be very grateful when 20 mins isup. Every time you played the piece, the total numberof chords played would be different and could becounted.

Staying with the Music, WHILE... DO occurs while avalue remains unchanging, and if something happensthat changes that value, then you can escape from theloop. For example, while people stayed to listen, youcould play. You can’t forecast the rate of walk out. Butplay you do WHILE the audience stays.

SLAB 5,higt, 0,0,0, A,0,0, A,B,B*SIN(tilt), 0,B,B*SIN(tilt), 0,0,0

Alarm note!If you use a variable for STEP in FOR... NEXT and forget togive it a value, the loop will be stepping zero each time.ArchiCAD may never recover. Alt-Ctrl-Del will be your friend!

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 42: Cookbook3_1

1.28

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Stretchy Joist ToolThis little joist tool is useful and the exercise dem-onstrates :

• Making objects stretchy

• An OBJECT becomes a TOOL

• Using a FOR NEXT Loop to convertstretchy object into a multiple stretchy object

T HE ArchiCAD Toolkit provides floor slabs,but these may appear too ‘plastic’ in nature. Even

though the slab can contain a theoretical content ofjoists and insulation and boards, this is difficult to seeon anything but sections. This joist tool object is forpeople who want their model to display visible struc-ture. This is a development of the BeamTool that wasin an earlier exercise.

3D ScriptAt the beginning of a new object, I tend to just knocksomething out that works before I introduce structure,and typographical formality. So this is a first stab at ascript, where you get a single joist working. I recom-mend that you use quasi english variable names, hencethe conversion of ‘B’ to ‘jlen’.

ParametersThink about the parameters that you would want yourobject to offer to the user. If you want the object to bestretchy, the overall dimension is the primary consid-eration; the actual number of joists will be worked outby your script.

A and B are used for the plan area.

The joist details are also entered.

As this is a practical tool for building, you can offer anoption to provide a final joist if the room is not an ex-act multiple of the joist spacing.

3D Script: continued: Now is the time to tidy upand formalise the script. First, put in the title, signatureand date. Add some titles for sections of the script.

Two more ‘Internal’ parameters are now needed.One is the actual number of joists in the object (thiswould be useful for properties scripting, but not neededfor 3D). The other thing is to find out how much spaceis left after you have put in a ‘round’ number of joists,in case there is room to put in a final joist. This is sim-ply ‘A’ minus the number of joist_spacings times thejoist_spacing.

Use a FOR... NEXT LoopThe joist we first put in can now be ‘wrapped up’ in aFOR-NEXT loop which spaces out the joists at the re-quired spacing. Each joist is drawn, and the cursor re-turns to the origin before drawing the next joist – theLoop is stepping in Distance, not counting the joistsone by one.

Note that on the first run through the loop it movesa zero distance, but as you have issued an ADDcommand, you still need the DEL command.

!Joisting/Boarding Tool!Discovery Course

!Settings--------MATERIAL jmatPEN jpen

!Parameters------ jlen=B numj=INT(A/jspa)+1 remj=A-INT(A/jspa)*jspa

!Main Joists-----FOR k=0 TO A STEP jspa ADDx k BLOCK jwid,jlen,jdep DEL 1 NEXT k

MATERIAL jmatPEN jpen

jlen=B

BLOCK jwid,jlen,jdep

Number of joists andthe remaing spacefor the last joist

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 43: Cookbook3_1

1.29

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

IF.. THEN.. ENDIFThis is an example of an IF.. THEN.. ENDIF, wherethere is more than one condition in the IF statement,and more than one line resulting from the IF state-ment. If the left over space is more than twice the widthof a joist, then this routine puts an extra one in. Theeasiest way to do it with precision is to go to the end –to A – and then step back the thickness of one joist=A-jwid.

3D AssemblyNow you can assemble quite complex groupings, andthe JoistTool can also be used for floorboarding – infact for any parallel, linear assemblies. Single joists,such as the trimmer here can be created simply bysqueezing the JoistTool to the thickness of a single joist.

ArchiCAD 6.x allows an degree of editing in 3D axoview, so it will become easier to use stretchy tools likeJoistTool. You can use the sectional view to get parts ofthe assembly working perfectly.

2D ScriptYou now have a 3D Tool that you can place into theProject Plan, and stretch to fit. But it must have a 2Dsymbol. Initially, your 2D script could be just PROJECT23,270,2 because the model is dynamic.

If you leave it at that, it will work, but the ProjectPlan will slow down as the model size increases dueto the time required to work out hidden line 2D Planviews of the 3D objects. I always script in 2D if it isgoing to be practical and time saving.

Your object will not be properly stretchy unless youadd the HOTSPOT2 script routine. Some objects arestretchy using the ‘bounding box’ hotspots. Howeverthe above script guarantees stretchiness, providing thatA and B are used as dimensions.

End noteThe same tool can do vertical studs (posts), handrailverticals, rafter tools, fencing and floorboards.

For a studding tool, to avoid confusing the user, youmight use an almost identical script and store it in thelibrary as vertical posts with different default param-eters and preview window.

!Stretchy Joist Tool!2D Script

HOTSPOT2 0,0 HOTSPOT2 A,0 HOTSPOT2 A,B HOTSPOT2 0,BPROJECT2 3,270,2

!Stretchy Joist Tool!2D Script

HOTSPOT2 0,0HOTSPOT2 A,0HOTSPOT2 A,BHOTSPOT2 0,B!!!!PROJECT2 3,270,2

jlen=Bnumj=INT(A/jspa)+1remj=A-INT(A/jspa)*jspa

FOR k=0 TO A STEP jspa ADD2 k,0 RECT2 0,0,jwid,jlen DEL 1 NEXT k

IF finj AND remj>jwid*2 THEN ADD2 A-jwid,0 RECT2 0,0, jwid,jlen DEL 1 ENDIF

!Put in last joistIF finj AND remj>jwid*2 THEN ADDx A-jwid BLOCK jwid,jlen,jdep DEL 1 ENDIF

Space at the end needs filling– use this routine

Hot Tip for rapid 2D ScriptingLeave PROJECT2 in action until you are sure that your scriptworks perfectly. In fact leave it there permanently, with com-ment marks. This is in case you need to edit or check the 2Dscript.• In fact, you can copy your 3D script and paste itinto the 2D script window.Change the ADD x,y,z commands appropriately, to ADD2 x,y(throw away the Z value). ADDx and ADDy can be changedto ADD2. MUL can be changed to MUL2. Moves in the Z

direction can be deleted if they will have no effect on theplan view.

As there is no height in 2D, you can change a BLOCKcommand to a RECT2 command:- for example, BLOCKjwid,jlen,jdep becomes RECT2 0,0, jwid,jlen.

Loops can use the same counters, and you use DEL tocancel Cursor movements just like you can do in 3D scripts.

Disable the Project2once you get thescripted versionworking

This 2D script uses theidentical loops andstructure to the 3Dscript, only some of thenames are changed

RECT is transparent,so if you want opaquejoists, use POLY2 witha white fill.

Page 44: Cookbook3_1

1.30

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Domino House: Loops

THIS Domino House type frame structureis a practical demonstration of the FOR...

NEXT Loop. The resulting object could be usedin site models to depict framed buildings sur-rounding your own (much better) scheme.

FOR... NEXT is a way of achieving repetitionwithout having to retype the script for the columnson each floor. Simply by setting a counter running,and then doing an operation every time that coun-ter is incremented (until the counter reaches its end)you may finish with something very complex.

Doing it without LoopsFor example, in this script, you can build a two orthree storey building by naming each slab, ADDz-ing to get to the next floor, doing another slab, andso on.

!3D ScriptPEN 1MATERIAL matldepth=bdep*bays+clszwidth=bwid*bays+clsz

!Do one floorBLOCK width,depth,clsz

!Do one columnBLOCK clsz,clsz,ftfh-clsz

!Jump a floor ADDz ftfh-clszBLOCK width,depth,clszBLOCK clsz,clsz,ftfh-clsz

!Jump another floor ADDz ftfh-clszBLOCK width,depth,clszBLOCK clsz,clsz,ftfh-clsz

DEL 2

3D Script: Reasons to do it with LoopsThis doesn’t sound too bad, but imagine doing it for all thecolumns on every floor! An even bigger benefit of theFOR...NEXT loop is that the loop can be parametric – socan the range of the counter and the stepping increment.

In a building like this, there is so much repetition thatyou really will need to learn to use FOR... NEXT Loops tocope with the number of columns and floors involved.

!3D ScriptPEN 1: MATERIAL matldepth=bdep*bays+clszwidth=bwid*bays+clsz

!Do onefloorBLOCK width,depth,clsz

!Do one row of columnsFOR k=1 TO bwid+1BLOCK clsz,clsz,ftfh ADDx bays NEXT k DEL bwid+1

ParametersLooking at this building, you can make every as-pect parametric – the total width and depth of thebuilding can be calculated in the script.

Notice that in the parameter box, one takes careto ensure that things which are INTEGERs, such asnumber of Bays and floors are shown as Integers.

The advantage of a parametric structure is sim-ply that it can be any width, length, height, col-umn size and spacing, floor to floor height. In anUrban Design model, this could be a good way todo surrounding buildings; better than trying to buildthem fully, or put them into the model as boringsolid slab blocks. All one needs is an option to in-stal Glass to complete this model.

Notice here how the cursor is lefthanging past the end of thebuilding.

FOR...NEXT Loops in actionLook at the above way of doing a loop. If there are threebays in the building, you want to draw four columns.

In this loop, you draw a BLOCK (which is the column);then you move the cursor, draw another block and so on,until they are all drawn. At the end of this process (seeillustration), the cursor is hanging off the end of the build-ing and you have to issue a DEL bwid+1 command to getthe cursor back to the origin.

Ghost Storey to print out?How do I get to show the Ghost storey on my printouts?1. Copy the whole storey (what you want to see)2. Paste to an empty storey3. Select All and Explode (convert to 2D)4. Set the Pen colours as appropriate (consider doing thatbefore exploding) perhaps to very light grey.5. Select All, Group, then Copy (or cut)6. Move to storey you want to print, and Paste. Move toback.Alternative 5 and 6: Select All, Copy, create New LibraryObject, Paste into 2D Symbol window. Use that.

Page 45: Cookbook3_1

1.31

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

!3D Script

PEN 1: MATERIAL matldepth=bdep*bays+clszwidth=bwid*bays+clsz

!Do one floorBLOCK width,depth,clsz

!Do 1 row of columnsFOR k=1 TO bwid+1 ADDx bays*(k-1)BLOCK clsz,clsz,ftfh DEL 1 NEXT k

Another, neater way of doing a loopIn the first loop on the previous page, the cur-sor worked its way from one side of the build-ing to the other, drawing blocks and movinguntil it reached the end – like a creature layingeggs. I prefer a different method whereby thecursor always stays at the corner of the build-ing, darts out to draw each column one at atime, and then darts back to the start; then dartsout to do the next one – a bit like a chamele-on’s tongue leaping out over increasing dis-tances to catch flies!

Therefore, in this Loop, you issue the cursor ADD command BEFORE you draw the BLOCK. Since you want tostart with a Block/column, the first ADD command must be equal to zero – which you get by multiplyingbays*(k-1). You DEL 1 within the loop, which means your cursor jumps back to the origin for every column. Thisis far tidier, and there are no DELs to do after the loop is finished.

Notice how the cursor stays at thecorner except when darting out todo another column.

!Domino House demo!For... Next Loops!3D Script

PEN 1: MATERIAL matldepth=bdep*bays+clszwidth=bwid*bays+clsz

!Do one floorBLOCK width,depth,clsz

!Do all the columnsFOR n=1 TO bdep+1 ADDy bays*(n-1)

!Do one row of columnsFOR k=1 TO bwid+1 ADDx bays*(k-1)!One ColumnBLOCK clsz,clsz,ftfh DEL 1 NEXT k

DEL 1 NEXT n

Nested For.. Next LoopsYou will want to repeat that set of columns throughout the floor. Havingalready done the front row, you can repeat the loop for the middle row andend row. Instead of repeating the loop, you could put another loop aroundthe loop! It is called ‘nesting’.

If you do this, be sure to use a different counter name – in this case, Ihave used ‘n’ and ‘k’. I have used the ‘tidy’ method of drawing the loop. Andyou can now see why the tidy method is better. If you use the other method,you risk getting confused as to the best place and number to DEL. This nowrepresents a complete ‘Storey’ module – which could be looped verticallytoo – No reason why you cannot have three nested loops!

Modify the script you have beenworking on so that it looks like this –the result should look like a wholefloor of the building, with columns.

Add in Titles at the start of the script.When you make the final modifica-tions in the next stage, you will havethe whole building.

!Domino House demo!For... Next Loops!3D Script

PEN 1: MATERIAL matldepth=bdep*bays+clszwidth=bwid*bays+clsz

!Do all the floorsFOR m=1 TO snum ADDz ftfh*(m-1)

!Do one floorBLOCK width,depth,clsz

!Do all the columnsFOR n=1 TO bdep+1 ADDy bays*(n-1)

!Do 1 row of columnsFOR k=1 TO bwid+1 ADDx bays*(k-1)BLOCK clsz,clsz,ftfh

Now Loop the Floors...You can now add in another loop around thefirst two, using the counter ‘m’ which will re-peat the floors for as many floors as you havein the building.

Finally, you could add a Glass sheath.

DEL 1 NEXT k DEL 1 NEXT n DEL 1 NEXT m

!Do the Roof ADDz ftfh*snumBLOCK width,depth,clsz DEL 1

!GlassMATERIAL “Glass” ADD clsz/2,clsz/2,0BLOCK width-clsz, depth-clsz,ftfh*snum DEL 1

2D script: As this is a sim-ple rectangle, with col-umns, use

PROJECT2 3,270,1

which will show a wirelineview of the house, reveal-ing the columns.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 46: Cookbook3_1

1.32

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

PRISM is for a polygonal shaped objectwhich has the same colour all over, no hol-low faces or curved surfaces, and no holes.

The local origin can be anywhere, butthe prism is always built up the Z-axis, offthe X-Y Plane.

You should declare the MATERIAL prop-erty before hand.

PRISMs can have *negative* thicknessvalues and grow *down* instead of *up* theZ-axis.

PRISM_ (prism underscore) gives you thepower to control the faces and to includecurves and holes by using masking values.For now, just put 15 after every XY loca-tion; later in the Cookbook, the role of*masks* is explained in more detail.

You can finish off the final coordinatewith a 15, or if you plan to add holes, youcan put a negative number (–1 will do)which tells GDL that you have finisheddrawing the outline.

With curved edges (Polylines), you canuse PRISM to produce Cylinders and ovals.

cPRISM_ (coloured PRISM underscore)is identical to PRISM_ with the addition ofa line to describe the materials of the topsurface, bottom surface and side surface.It also uses masking codes for the edges,and supports polylines (curves) and holes.

When you make a library object by theconventional method from the floorslabtool, ArchiCAD always does floor slabs ascPRISM_s in the 3D script.

More 3D Commands – Prisms

SOONER or later, you have to produce shapes which cannot be done with Blocks and Cylinders.Prism can form complex outlines in 3D. PRISM (and its variants) is the most common 3D statement in

creative GDL. I use PRISM in preference to using BLOCK, even for rectangular objects. Because you enter theXY locations of the points, you can stay at the origin and the PRISMs can happen according to their XY locations.It is always best to draw the Prism out on paper before you enter the XY coordinates, numbering all thepoints.

PRISM (and its variations) isperhaps the most commonly used3D command in GDL

!PRISM Demonstration!Syntax:- PRISM number,height,! x1,y1, x2,y2,...etcMATERIAL "Sandstone"PRISM 9, 0.2, 0.00,0.00, -0.10,0.30, 0.10,0.30, 0.10,0.40, 0.20,0.40, 0.20,0.10, 0.15,0.10, 0.15,0.00, 0.00,0.00

Note, that by adding 1000 to the 15,you can create interestingtangential curves. This is your firstview of the power of Polylines

!PRISM_ Demonstration!Syntax:- PRISM_ number,height,! x1,y1,15,! x2,y2,15,...etcMATERIAL "Sandstone"PRISM_ 9,0.2, 0.00,0.00,15, -0.10,0.30,15, 0.10,0.30,15, 0.10,0.40,15, 0.20,0.40,15, 0.20,0.10,1000+15, 0.15,0.10,15, 0.15,0.00,15, 0.00,0.00,-1

Note that by changing 15 to 13 (or writeit as 15-2), you can effect subtlechanges in the appearance of thecurved surface. The vertical lines in thecurve can be hidden This is explainedin the section on Masking.

!cPRISM_ Demonstration!Syntax:-! cPRISM_ topmat,botmat,sidmat,! number,height,! x1,y1,15,! x2,y2,15,...etccPRISM_ "Sandstone","Pine","Zinc", 9,0.1, 0.00,0.00,15, -0.10,0.30,15, 0.10,0.30,15, 0.10,0.40,15, 0.20,0.40,15-2, 0.20,0.10,1015-2, 0.15,0.10,15, 0.15,0.00,15, 0.00,0.00,-1

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 47: Cookbook3_1

1.33

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Car Park BarrierThis useful exercise illustrates:

• Using a PRISM to keep a rectangular objectaxial with a cylinder

• Having articulated elements in the model

• Using the FOR... NEXT Loop to repeat objects

• Using IF... THEN... ELSE... ENDIF

• Using Subroutines to ensure modularity

• Using PEN command to set colour of object

This library object could be used in designing a cam-pus or car park. In a flythrough, the bar could lift asthe camera passes.

ParametersAs the barrier changes its plan shape, you cannot useA and B. Fill in the remainder of the parameters. Toavoid excessive complexity, I have not made every-thing parametric, only the things that matter in this ex-ercise.

3D ScriptThe first part of the script (until the END command)could be called the ‘executive script’. Always title yourscripts. Use RESOL to set a limit to the curvature of thebar.

Because this model has moving elements, set outfrom the beginning to use subroutines. Remember towrite the END statement before you write the subrou-tines.

100: First the Post is built. You should start by specify-ing Material and Pen. For this post, we make use of thePRISM – far more useful than BLOCK, although moredifficult to write, at first. PRISM allows you to locatepoints anywhere on the X-Y plane, whereas BLOCKalways ties you to the local origin. The hinge is a cyl-inder.

200: The object which includes the bar is a Cylinderfirst, and then a colour circle is placed at the halfwaypoint on the bar, and finally, the script includes a coun-terweight, using a Prism command. Ensure that the rightnumber of DELs is used within the subroutine.

This is an object oriented approach. The arm iswholly contained in a subroutine so that it behaveslike an object. Returning to the main script, you justhave to raise the cursor to the height of the hinge, is-sue a rotation command, and then call the subroutinewith a GOSUB command. Hey Presto! it appears in theright place.

!Barrier w lifting bar!3D Script

RESOL 12

GOSUB 100 !Post

ADD 0,-0.3,0.9 ROTy rotarmGOSUB 200 !Arm itself DEL 2

END !-----------------

100:!Main Post objectMATERIAL bmatl: PEN 1PRISM 4,1.0, 0.15, 0.15, -0.15, 0.15, -0.15,-0.15, 0.15,-0.15 ADDz 0.9 ROTx 90CYLIND 0.4,0.05 DEL 2RETURN

they do not line up, force the commasto line up, using your spacebar.• When you have a problem with Prism,it is often because you have made anerror with the commas. That is whereyou should first look for errors.• Prisms close themselves. The Prismin the examples has 8 sides and 8points, but I advise you to get into thehabit of joining the first point to the

last, making 9 point XY coordinates inall. This is because when you insertholes or openings, or write out XY listsfor other forms such as extrude, youneed to close all prisms and other 3Dforms by return to the starting point.

• Indent the XY numbers – it is mucheasier to read and repair.• Write the word PRISM in upper case.Only use an underscore form of prismif you need to make use of masking,curves or holes.• Tabulate the numbers using the com-mas to line up the list of numbers. Ex-press numbers in the 0.00 format, sothat all the commas line up. Even if

Tips and Tricks – Typographical format for all PRISMs

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 48: Cookbook3_1

1.34

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Stripy Arm– using the FOR... NEXT loopTHIS is a good example of the need for a repeatingloop – for example where we need alternating colourstripes on the bar. It is also an example of the IF...THEN... ELSE... ENDIF in action. First of all, add aBoolean choice to the parameter box offering the usera plain or stripy arm.

200: Next, take the CYLINDER command out of sub-routine 200: and replace it with a GOSUB 250. TheGOSUB becomes as much of an object as the CYLINDcommand was before – another example of the objectoriented approach,

250: Assuming that the ideal stripe length is approx0.3 metres, the script calculates how many stripes couldbe in the bar length. It rounds that down to an integernumber, and works backward from that number tocalculate what the exact stripe length should be. Nowrun a FOR...NEXT loop to draw the stripes. A little ‘flag’called stcol keeps track of which colour stripe we aredrawing. As it draws each stripe, it multiplies stcol by(-1), which changes its value from -1 to +1. When stcolis negative, the stripe is white, and when positive, it isred.

By using the counter ‘k’ in the FOR NEXT loop aspart of the calculation, it is possible to DEL after draw-ing each coloured cylinder, before hitting the NEXT kcommand. In these cases, you usually multiply the dis-tance to be travelled by (k-1), one less than the coun-ter.

2D ScriptAs the model articulates, you cannot use a standardsymbol, you need to write a 2D script. Issue thePROJECT2 command as in the previous examples.

200: !Swinging ArmMATERIAL bmatl: PEN 1GOSUB 250:!StripyArm ADDz blen/2 ROTx 90MATERIAL 0: PEN ccol CYLIND 0.01,0.2 !Disk DEL 2 ROTy 180MATERIAL bmatl: PEN 1PRISM 4,0.5, !Weight 0.1, 0.1, -0.1, 0.1, -0.1,-0.1, 0.1,-0.1 DEL 1RETURN

250:!Stripy ArmIF stripy=0 THENMATERIAL bmatl: PEN 1 CYLIND blen,0.03ELSEMATERIAL 0 stnum=blen/0.3 !num of stripes strsp=blen/INT(stnum) !length stcol=1 !Set a ‘flag’FOR k=1 TO stnum stcol=stcol*(-1) !Toggle flagIF stcol>0 THEN PEN 91 ELSE PEN ccol ADDz strsp*(k-1) CYLIND strsp,0.03 DEL 1 NEXT kENDIFRETURN

Right: This iswhat it should

look like.

Material and PensTo make an item a bright colour, set Material to ZEROand the object’s colour will then follow the PEN col-our. This is easier than having to create many materi-als of different colours.

For this reason, it’s a good idea not to tinker aboutwith the colour palette, at least not the top line of thepalette – if you are likely to be using Pen colours to setobject colours.

200: !Swinging ArmMATERIAL bmatl: PEN 1 CYLIND blen,0.03 !Arm ADDz blen/2 ROTx 90MATERIAL 0: PEN ccol CYLIND 0.01,0.2 !Disk DEL 2 ROTy 180MATERIAL bmatl: PEN 1PRISM 4,0.5, !Weight 0.1, 0.1, -0.1, 0.1, -0.1,-0.1, 0.1,-0.1 DEL 1RETURN

! Name : temp! Date : Wednesday,May 5,1999! Version : 6.00! Written by ArchiCAD!MULX A/ 8.599127MULY B/ 5.354173MULZ ZZYZX/ 0.2ADD 0.012093,5.922268,0.2RESOL 36GLOB_SCRIPT_TYPE = 3

What makes autoscripted objects•Stretchy•?

EACH new object is allocated a value for A, B and zzyzxdepending on its size when first made. The first three

active lines of an autoscript are MUL commands: so that if auser stretches it to make a different value of A, B or zzyzx,the object will be stretched in that dimension. The BoundingBox hotspots always fit A and B, thus making them controlstretchiness.

If new object is stretchedto 10 metres wide, its

width is multiplied by 10/8.599127 thus making it

fit the new size

Byzanti
Highlight
Byzanti
Highlight
Page 49: Cookbook3_1

1.35

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

THIS exercise is a demonstration ofhow to modify a library object

autoscripted by ArchiCAD.

First, using slab tool, you knock out a shape,like this. My first recommendation is to buildit as CLOSE TO, or ON to the origin of themain model as you can. Better still, use ‘snap-to-grid’. That means that one of the points inthe slab script will be 0,0.

Procedure for ArchiCAD 5.x andwhich can also be used for 6.xPosition the camera using 3D Projection Set-tings so that it views it orthographically in planwith the camera at 270 degrees.

Note that many models, like slab built win-dows or trussed rafters require you to position the cam-era as if looking from north of the object, inelevation. You should get a view like the one below,either in Hidden Line mode or in Shaded mode.

While viewing the 3D image, use the File Menu todo a Save As... and save it as a Library Object (.GSMobject). You will see a box asking if it is an Object, aWindow or a Door. Why they don’t ask you if it is aLamp, I don’t know – if you want to make Lamps, youhave another stage to go through to convert it. Tickthe ‘remove redundant lines’ box. If you hide redun-dant lines, only the visible top lines will be saved.

You are asked if you want to save as Editable or asNon-editable Binary data. Never save as Binary if youwant to edit the object. The File will take far more spaceon disk, and loses all parametric qualities except forsize. A Binary file has all been compressed into onelump of data. This can be advantageous for complexobjects as they will render more reliably and carry allmacros with them. But that isn’t the case here.

So I hope you will save this in EDITABLE form.

Modify Library object

Procedure for ArchiCAD 6.x: If the object is builtflat on its side on the ground, like a window or trussedrafter, use the procedure for AC5. If the object is theright way up, then select the group of elements, thenfrom the File Menu, Save Special... as an ‘ArchiCADobject’. You save it to your library, and you can thenopen it from the File menu and modify it, perhaps con-vert it to a window or a lamp, or just tweak it.

I recommend that you always use the AC6 procedureif the object is seen in plan. It is quicker and easier,and guarantees that the object will be an Editable Ob-ject. Even better, the object is fully 2D scripted withPOLY2 and HOTSPOTs, whereas the other methoddraws a 2D Symbol instead. If the object is going to beon its side, then you can still use the AC5 3D-basedmethod.

Whichever method you have used, Save it, andthen drop the object into the Project floor plan– then Open Library part.

Page 50: Cookbook3_1

1.36

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

! Name : tempbin - BINARY OBJECT! Date : Wednesday, May 5, 1999! Version : 6.00! Written by ArchiCAD!MULX A/ 8.599127MULY B/ 5.354173MULZ ZZYZX/ 0.2ADDX 0.012093ADDY 5.922268BINARY 1,1

! Name :temp - Editable Object! May 1999

ADD 0.012093,5.922268,-zzyzxPEN 1MATERIAL “Pine”PRISM 7, zzyzx, -0.012, -0.568, -0.012, -5.922, 5.991, -5.922, 5.991, -3.618, 8.587, -3.618, 8.587, -3.197, -0.012, -0.568DEL TOP

! Name : temp! Date : Wednesday,May 5,1999! Version : 6.00! Written by ArchiCAD!MULX A/ 8.599127MULY B/ 5.354173MULZ ZZYZX/ 0.2ADD 0.012093,5.922268,0.2RESOL 36GLOB_SCRIPT_TYPE = 3GLOB_CONTEXT = 3GLOB_SCALE = 100GLOB_NORTH_DIR = 90.0GLOB_FRAME_NR = -1GLOB_EYEPOS_X = 299.259GLOB_EYEPOS_Y = 165.035GLOB_EYEPOS_Z = 1.7GLOB_TARGPOS_X = 289.381GLOB_TARGPOS_Y = 184.934GLOB_TARGPOS_Z = 1.7GLOB_HSTORY_HEIGHT = 2.9!!Slab-001PEN 1ADDZ -0.2GLOB_LAYER = "Floors"GLOB_ID = "Slab-001"GLOB_INTID = 3BODY -1cPRISM_ "Pine","Pine","Pine", 7, 0.2, -0.012093, -0.568094, 15, -0.012093, -5.922268, 15, 5.991071, -5.922268, 15, 5.991071, -3.618351, 15, 8.587034, -3.618351, 15, 8.587034, -3.196507, 15, -0.012093, -0.568094, -1BODY -1DEL 1

This is what you get if yousave as Binary. You can do

nothing with it, except toinsert a ROT or MUL. It has

no parameters apart from A,B and zzyzx (height)

3D ScriptThese MUL commands allow the object to be stretchy.If your object is fixed in size and not stretchy, deleteall the MULs and delete zzyzx from the parameter box.Leave the ADD commands in place, unless you buildyour object over the Project Origin.

• These long lists of Global Variables are simply ahousekeeping record of the conditions prevailing atthe time the object was made – current drawing scale,eye position etc. These can all go.

• As the first object is based on a floorslab, there isadditional housekeeping in the form of the GVs forthe slab – current layers etc. These can all go. BODYcommands can go.

• Finally, you should replace the DEL 1 command atthe end of the script with a DEL TOP. If not, leave eachDEL 1 or DEL 2 in place until you get more used totinkering with object scripts.

• Finally, if you really want to cut deep with the prun-ing knife, you can change the CPRISM_ to a PRISM_,thus enabling you to remove the references to materi-als. You need to place a MATERIAL command beforethe prism.

• You can cut even deeper by removing all the mask-ing values, and the underscore, to make it a bare PRISM.Do not do this if you want to add holes or polylines, orto retain different coloured surfaces on the prism.

2D ScriptAmazingly, this is even more verbose with Global Vari-ables than the 3D script. These can all be cleared out.You are left with a matching ADD command, a POLY2to outline the PRISM shape, and a nice bunch ofHotspots for each point in the slab.

This is whatyour

Autoscripted3D Scriptlooks like

This is whatit can look

like aftersome

pruning

If you are a fanatical pruner,you can even truncate the XY

coordinates to 3 decimal places– this speeds up 3D drawing.Make sure the start and end

points are the same.

Because thelocations are

stored inmillionths of a

metreaccuracy, you

are causing theArchiCAD

parser mustspend longer

readingthrough all

that data andbuilding the

object.

Change height of 0.2 to zzyzx

Tips and Tricks: Instant GDL!

EVERY element in ArchiCAD can be expressed in GDL,which is the underlying language of ArchiCAD. If you

want to see what •anything• looks like in GDL, try this andbe amazed.

Arrange your project window so it occupies half thescreen. Open a New Library object file and arrange theempty floating 3D script window so it occupies the otherhalf (click the white script button to make it float).

Now select any part of the Project, grip the part(s) by anedge and Drag’n’Drop into the 3D script. Instant GDL!!

You can do the same with any group of 2D elements,Drag’n’Drop into the 2D script window. It’s brilliant! Mostcomplex 3D items such as EXTRUDE, REVOLVE and the pro-files for TUBE and SWEEP use the same syntax as a POLY2.So you can copy the XY data from a POLY2 command andpaste it into the 3D script for a complex 3D command.

This technique only works satisfactorily if some part ofthe objects to be dragged are on the main origin.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 51: Cookbook3_1

1.37

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Analysing and Extending the 3DScriptThis is very simple example – you might go a lot fur-ther, for example, make the Pen parametric, addingparametric Materials, drilling holes in the prism, or ed-iting the dimensional data outlining the prism, or du-plicating the prism into a stack of repeated prisms, incase it is part of a shelving system.

If the script is really very long, then you can use theFind and Replace Feature quite effectively. It mustspeed up reading of the script if you can remove a lotof the clutter. Search and replace all instances of“GLOB_” with “!”..... and more besides. You can alsoinsert useful comments above PRISMS to identify whatthey are.

The Golden Rule: use the OriginOne of the most important rules to remember is to try to buildthe original object ON THE MASTER ORIGIN of the Project. Mov-ing the origin somewhere else doesn’t work. You have to do iton the original origin. To move a temporary origin back to theoriginal, click once on the temporary origin, hit delete, and itwill restore the main origin.

With AC5, autoscripted objects always have a verti-cal parameter called V_SCALE, and in AC6, this is called‘zzyzx’. There is no reason why AC5 users cannot re-name the height factor ‘zzyzx’ and thus make theirobjects more useful (and stretchy) when they upgrade.

Leave the ADD commands in place. If you had builtthe slab literally ON THE ORIGIN, you could deletethese too.

• You could add an extra pair of lines:MATERIAL M_PEN L_

to make the object conform to the pen and materialselectors in the main settings box. This is making useof Global Variables. However, if your object containsseveral objects of different materials and pen colours,you are best to include those in the script, and to tickthe box to use the ‘Object’s own Settings’.

Steal this routine....This procedure is quite convenient even for hardenedGDL users. It is good for knocking out complicatedshapes, without having to work out the XY locationsyourself.

Put up a 2D image of the object you want to make(like the Fire engine above or a Bus), explode it, andtrace over the main body panels with the slab tool.Drag each slab into the 3D script window, label eachone, and then reorganise each prism with the correctthickness and material.

Once you have got the hang of this technique, youcan ‘steal’ the X,Y locations in Slab/Prisms to definemany other things, such as the pathway of a tube, orthe locations of glazing bars.

!Name : temp

ADD20.012093, 5.922268PEN 1POLY2_B 7,1,0,0, -0.012093, -0.568094,1, -0.012093, -5.922268,1, 5.991071, -5.922268,1, 5.991071, -3.618351,1, 8.587034, -3.618351,1, 8.587034, -3.196507,1, -0.012093, -0.568094, -1HOTSPOT2 -0.012093, -0.568094HOTSPOT2 -0.012093, -5.922268HOTSPOT2 5.991071, -5.922268HOTSPOT2 5.991071, -3.618351HOTSPOT2 8.587034, -3.618351HOTSPOT2 8.587034, -3.196507HOTSPOT2 -0.012093, -0.568094

This is thetidied up 2D

script. theoriginal auto

script is farto long to

print here!

This powerfulFire enginemodel was builtin a day usingthe techniquein this section:stealing prismsfromArchiCAD. Alittle bit of GDLknowledge isused toorganise detailslike the glassand the doorsHere you see itsitting on itspile ofconstructionalprisms.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 52: Cookbook3_1

1.38

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Example of modifying library objectsThis curved 3D truss can be made in about 60 seconds, based on an algorithm that parses the outlines of aPRISM (saved as an ArchiCAD object just by clicking out a piece of floorslab). The user just has to copy thePrism’s XY locations, and paste them into the 3D script; the remainder of the script just has to read them in. Prearranged routines decide how to organise the tubular steel framing.

Tips and Tricks – Join a User Group – or make one!

GRAPHISOFT are always willing to listen to constructive criticism or wishlists. But users’ voices are more effective if youare a member of a user group; also, you might find from the more experienced users that many of the things you want

are already possible. If there isn’t a group around, then form one with friends, locally. Register the group with Graphisoft inyour country.

Another major group you could join would be the GDL Alliance, a truly international collection of GDL writers. Youcould email the GDL Cookbook author for details of the UK group, or about the GDLA.

SHADOWSHADOW – sometimes you must turn off shadow ren-dering even when the rest of the object is shadowed –for example glazing fittings – which if curvy and cast-ing shadows could prevent ArchiCAD ever finishing arender. In a model of a car, you can speed up render-ing by issuing a SHADOW OFF command before draw-ing hubcaps or door handles.

SHADOW ON and SHADOW OFF could be used inIF statements – for example, if the object is further than50 metres from the camera location then do not castshadows.

Example:IF dd>30 THEN SHADOW OFF ELSE SHADOW ON

MODELMODEL – sets a viewing mode for the model, or partsof the model. Normally, if you want the whole modelto be wireline, hidden-line surface, or solid shadedsurface, you can change it in the main menus of Archi-CAD. The benefit of the MODEL command is that youcan single out parts of the model to draw differentlyfrom the rest.

For example, in a tree model, you might want thetrunk and branches to have a clearly outlined form,yet make the leaves to be drawn as shaded surfacesonly, with no edge lines. Another example could bean atrium roof glazing structure, where, with a BooleanYes/No command in the dialog box, the glazing couldchange from shaded to transparent wireline.

Syntax:MODEL WIRE: MODEL SURFACE: MODEL SOLID

Bits of Syntax

All these car body shapes (in Motorist) have been made by draggingslabs from the Floor plan into the 3D Script and then reorganisingthicknesses and materials, and applying cutplanes and small detailsas required.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 53: Cookbook3_1

1.39

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

More about GDL 2D Commands

Modifying Objects

UNDER AC5, autoscripted objects used to begive a drawn symbol, and some code in the 3D

script made them stretchy. In AC6+, autoscripted ob-jects are fully scripted as a mass of LINE2s andHOTSPOT2s.

This can sometimes be a pain, and I often deletethe whole lot and replace them with a PROJECT2 com-mand. This is essential if you intend to alter or rotatethe object in the 3D code. If you are willing to, you arebest to rescript it in a much simpler, more usable, para-metric form.

Another method is to place it in the Project FloorPlan window with a Project2 command active, Explodethe object, then Copy the 2D symbol thus created andPaste it into the 2D symbol window of the object. Addthe command FRAGMENT2 ALL,1 to the 2D script.Retain Project2 until you get the symbol and drawingaligned. Then delete Project2. You can add Hotspotsmanually to the 2D symbol. If the symbol is too full oflines, replace them with Fills, much tidier.

Advice on 2D Scripting

WHENEVER you can, and if you have the skill,always try to write a 2D script with a para-

metric or complex object.

2D scripting is good because...

(1) of the speed of drawing in the project plan. WithPROJECT2 AC must do a 3D hidden line projection ofthe object before drawing it.

(2) a Symbol, which could be the alternative, is notparametric.

(3) the 2D script can itself be highly parametric, errorchecking, informative, and scale aware.

If it is too complex to script in 2D, and too slow togenerate a PROJECT2 image from the 3D script, con-sider using symbols called by the FRAGMENT2 com-mand.

HOTSPOT2 x,y should be used in every 2D script:

Picking Up: to enable you to pick objects up.

Snapping To: they also give a point that adjoiningobjects can ‘snap-to’, which could be useful for ob-jects which need precise location – like lecture theatrechairs, or gutters to walls.

Making Stretchy: if you use A and B as dimensions,the Hotspots at the outer corners may enable you tostretch the object. Stretchy objects are among the mostuseful and user friendly objects.

If the Hotspots are written as illustrated here, and if Aand B are parameters of the 2D and 3D forms of theobject, then the object will be STRETCHY!

TEXT2 is for adding text to an object’s symbol. Apartfrom being able to label the object, the object can useit to display a level of intelligence, e.g. flashing up atext warning if the object has bad parameters, or dis-playing the final size of a stretched object, the pitch ofa stretched staircase, or the serial number of a manu-facturers component.

It is only worth using if you are first prepared tolearn how to DEFINE STYLE; if you do not, you willhave no control over the size of the text, or how itplots at different drawing scales. The text can be adapt-able to different scales, including not displaying itselfat all when it would be too small to read (e.g above 1/200)

See the ‘Fire Extinguisher’ exercise for an example ofDEFINE STYLE.

Are your HotSpots Stretchy &Squeezy?IF you want objects to be Squeezy as well as Stretchy, youneed to utter your HOTSPOT2 commands <BEFORE> thecommands which actually draw the 2D objects. Otherwise,objects may stretch, but not reduce in size correctly.

You must also provide some hotspots that are not onthe stretchy corners or you will have trouble picking upyour object – it may stretch every time you try to drag it!

If you do a good set of hotspots, remove the boundingbox hotspots. In AC6.x, hit the ‘Details’ button in the ob-ject building window and cancel the checkbox.

Stretchy: A typical listingof HOTSPOTs when theOrigin of the model is at thebottom left.

Stretchy: A typical listingof HOTSPOTs when theOrigin of the model is atthe centre of the model.

Hotspots make Stretchy Objects!

HOTSPOT2 0,0HOTSPOT2 A,0HOTSPOT2 A,BHOTSPOT2 0,B

HOTSPOT2 -A/2,-B/2HOTSPOT2 A/2,-B/2HOTSPOT2 A/2, B/2HOTSPOT2 -A/2, B/2

ADD2 1.6,0.9HOTSPOT2 0,0DEL 1

!The same resultHOTSPOT2 1.6,0.9

You can send a Hotspot directly to a location, e.g.HOTSPOT2 1.6,0.9 or you can write it the long wayas:

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 54: Cookbook3_1

1.40

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Cursor control in 2D scriptingADD2, ROT2 and MUL2 are the Cursor movement commandsin 2D scripting. ADD2 and MUL2 always have to be speci-fied with X and Y in the same command. e.g. ADD2 1.50,0will do the equivalent of an ADDx in 3D.

Unfortunately, you do not see a visible cursor. One trick is touse the CIRCLE2 0,0,0.01 command as a substitute cursorand keep pushing it along just in front of the cursor move-ment command. e.g. ADD2 1.50,0 CIRCLE2 0,0,0.01

CIRCLE2 Draws a circle which you can controlby location and radius.

!Syntax: CIRCLE2 x,y,radiusCIRCLE2 0,0,0.5

ARC2 draws a circular line, which you can controlby location, radius and angles (in degrees). Anglesstart from the Horizontal and move in an anticlock-wise direction.

!Syntax: ARC2 x,y,radius,startangle,endangleARC2 0,0,0.5,90,180

POLY2POLY2 simply draws a polygon – asequence of lines – a lot more eco-nomically than a series of LINE2 com-mands. It can be filled or empty.

POLY2_POLY2_ (underscore) is an en-hancement of POLY2 – you can con-trol the line drawing of each part ofthe polygon; you can use ‘polylines’(curved elements) and drill holes.POLY2 and POLY2_ can be filled witha fill pattern. The figure must be closedfor this to work. For any poly to befilled, you must specify one more thanthe number of points – the first pointis repeated as the last point. The

What is Framefill?0 means draw nothing, 1draws the line, 2 drawsthe fill pattern but no line,4 means close the Polygon(if not already closed).

Any additive combi-nation of these can beused – e.g. 3 is the sum of1 and 2 so you get the linesand the fill pattern, 6[2+4] results in a closedfilled polygon with noline!, 7 [1+2+4] gives youeverything.

Framefill attribute is normally left as ‘1’ for unfilled Polygon drawing.However, you can vary this with 7 permutations. If you wish to controlPen Colours of the Fill, then you must use POLY_2A and POLY2_B.

!Syntax POLY2 n, framefill,!x1,y1, ..... xn,yn

PEN 1SET FILL 'Earth'POLY2 9,3, 0.00,0.00, -0.10,0.30, 0.10,0.30, 0.10,0.40, 0.20,0.40, 0.20,0.10, 0.15,0.10, 0.15,0.00, 0.00,0.00

More 3DDrilling Holes in Prisms

P RISMs may not be ableto have holes through them, but

the addition of an Underscore makesPRISM_ which can have holes andcurved lines.

With PRISM_, you end each XY lo-cation with a 15. The trick with holesis that you must end the descriptionof the outline by repeating the firstpoint as the last point with a -1, thenbegin a new set of XY points, also with15, and then use a -1 to end that hole.You can have as many holes as youlike as long as you follow that se-quence. The end point of each groupof points must be the same as the startpoint.

My tip for hole making is to express the number ofpoints as I have done here, e.g. 9+7, not as 16. Thisway, you can remind yourself how many points makethe outlines, and how many are in the hole – and howmany holes you have. Put a linefeed between the listfor the outline, and the one for the hole.

!PRISM_ Demonstration! including Hole!Syntax:- PRISM_ number,height,! x1,y1,15,! x2,y2,15,...etcMATERIAL "Sandstone"PRISM_ 9+7,0.2, 0.00,0.00, 15, -0.10,0.30, 15, 0.10,0.30, 15, 0.10,0.40, 15, 0.20,0.40, 15, 0.20,0.10, 15, 0.15,0.10, 15, 0.15,0.00, 15, 0.00,0.00, -1,

0.00,0.05, 15, -0.07,0.25, 15, 0.15,0.25, 15, 0.15,0.15, 15, 0.10,0.15, 15, 0.10,0.05, 15, 0.00,0.05, -1RETURN

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 55: Cookbook3_1

1.41

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

GLOBAL Variables are current conditions and settings of your project. They are known byArchiCAD. GDL objects can, at any time, interrogate them and make use of the information.Under Archi-

CAD 6.0 and 6.5, you have many more Globals available than with AC5, although many of the new ones are notusable for 2D and 3D model building (they are for listing). Meanwhile the following are the GV’s you couldusefully use. For the rest, check the GDL manual.

GLOB_SCALE Drawing Scale, (formerly known as(f.k.a.) A_) Use this to determine how complex a 2Dscripted symbol will be. For example, at scales up to1/20, you show rebates in door jambs, at 1/50 you canshow them as rectangles, and beyond that, they arerendered as simple door swings. this can reduce thetime of screen redraw and plotting times. TheFilestamp/Desktop clock in the Voyager cookbookdemonstrates how A_ can be used.

GLOB_HSTORY_ELEV (f.k.a. B_) tells the eleva-tion of the storey (the ‘home’ storey) that the object iscurrently placed on. This is important if you have astaircase, and want it to show on the home storey asthe start of a flight, and on the next as the end of thesame flight.

C_, D_, E_ F_, G_, H_, I_,K_, L_, M_, R_ areall vital for windows and doors. They will not fit cor-rectly into walls unless you use these.

WALL_THICKNESS (f.k.a. C_) is the most vital GVin window making! WALL_MAT_A (f.k.a. G_) is thewall material on the side opposite to the opening side.This can vary from opening to opening placed in thesame wall. I standardise this to be the internal wall sur-face (opposite the ‘hotline’ of the wall). WALL_MAT_B(f.k.a. H_) material of the wall on the opening (orHotline) side. WALL_MAT_EDGE (f.k.a. I_) materialof the wall reveals. By lucky coincidence, if you use acPRISM_ to build a window surround, you can startwith CPRISM_ G_,H_,I_,.... Isn’t that easy to remem-ber!

MATERIAL SYMB_MAT : PEN SYMB_VIEW_PEN

MATERIAL M_ : PEN L_L imitations to Globals: Certainthings cannot be found from Globals and may

have to be found using the REQ and the REQUESTcommands.

Most globals are numbers; REQUESTs are usually usedfor returning Strings (of letters). An example of RE-QUEST is current System Time and Date. Another isthe object’s own name and label.

GLOB_FRAME_NR (f.k.a. N_) current framenumber in animation or flythrough,GLOB_FIRST_FRAME (f.k.a.O_) first frame index inflythrough, and GLOB_ LAST_FRAME (f.k.a.P_) lastframe index in flythrough are useful for making ob-jects change during an animation. (see the ‘GrowingBuilding’ in Voyager).

S_ to Z_ could be freely used as variables, and wereneeded in all versions of ArchiCAD before 5.0, becauseit was easy to run out of simple alphabetic letters forvariables. But now, you must NEVER use these. Al-though GV names are now in a long format, the OLDones are still valid, and old Global Variable names arestill recognised. Many new ones have been created andthese may come back into use.

SYMB_VIEW_PEN (f.k.a. L_) is the default pen ofthe library part.

SYMB_MAT (f.k.a. M_) is the default material of thelibrary part.

A script like this below will reduce the number of pa-rameters in your dialog box by two, as the user cannow click on the pop-up selectors provided byGraphisoft in the normal object settings dialog box.The object is forced to use the material and pen thatare selected in the object settings box.

MoreGDLSyntaxIntroducingGlobal Variables

Byzanti
Highlight
Byzanti
Highlight
Page 56: Cookbook3_1

1.42

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

A~ to J~ are useful (essential!) in getting windowsand doors working in 3D and drawing in 2D correctly.Windows are somewhat of a black art and are the sub-ject of a special exercises in the Discovery and Voy-ager course.

The following are most useful for Location Awareobjects:

GLOB_EYEPOS_X, GLOB_ EYEPOS_Y, &GLOB_EYEPOS_Z (f.k.a. K~, L~ & M~) tell theobject where the most recent camera is located.

GLOB_TARGPOS_X, GLOB_ TARGPOS_Y,& GLOB_ TARGPOS_Z (f.k.a. N~, O~, & P~)tell the object what the camera is looking at – the‘target position’.

SYMB_POS_X, SYMB_POS_Y,SYMB_POS_Z (f.k.a. X~, Y~ & Z~) tell the objectwhere the object itself is in the overall project.

These are useful for getting things to face the cam-era, or change as the camera approaches..

SYMB_ROTANGLE (f.k.a. W~) is the rotationalangle of the object. No matter how you rotate the ob-ject, it will always face the camera if you use the algo-rithm illustrated on this page.

GLOB_CSTORY_ELEV,GLOB_CSTORY_HEIGHT,GLOB_CH_STORY_DIST (f.k.a. Q~, R~ & S~)tell you how objects relate to the storey displayed inthe Project Floor Plan window.

GLOB_SCRIPT_TYPE and GLOB_ CON-TEXT (f.k.a. T~) returns information on the Archi-CAD window, or view that you are currently using. T~used to do both. Now, you can know if your object isbeing executed in a particular Script or in a Window(Elev or Plan or 3D) and modify it accordingly. This isextremely useful for complex objects. If GDL is read-ing the 3D script and knows that the object is actually

being generated in 2D at that moment (in a Project2command) you use subroutines to draw planar 3D el-ements (instead of solid ones) in the script. See a laterexercise on this (Lattices-1).

GLOB_NORTH_DIR (f.k.a. U~) gives the direc-tion of Project North; you could tell where the Sun is –for solar panels or shading devices. With U~ (and find-ing from the user the time, date and Latitude, you canwrite a script to calculate the quantities of sunlight fall-ing on Solar panels, Walls, Windows, etc, and can getsun breaking devices like louvres to change their an-gle during an animation. It is not yet possible to findout (by Request or Global) the Lat. and Long of a site.

My ‘Stardome’ (a model of the visible Universe) findsthe northpoint (U~) and rotates accordingly.

SYMB_MIRRORED (f.k.a. V~) is useful if you havea scripted 2D symbol, and want to ensure that Hotspotsand text in objects still appear the right way round andin the right place, even when the symbol is mirrored.When you tick the ‘mirrored’ checkbox in the Objectsettings dialog, the 2D symbol and the hotspots willbe mirrored for you. However, you might want theProperties script to know that the object has been mir-rored – for example in specifying right or left handeddesking units in interior layouts.

More GlobalVariables

Long or Short Global names?THE AC6.0 and 6.5 manuals explain GVs a lot better thantheir predecessors. However, I preferred it when Globalswere based on short names. When you use them with longnames, you always have to check the manual that youhave spelt them correctly!

The classic Location awareness subroutine. Theadjustment to dkx avoids a divide by zero error. Ifazimuth is critical there is more to it than this, but thisroutine is good enough for trees and people.

!Location Awareness!with camera global variablesdkx=K~ - X~:IF dkx=0 THEN dkx=0.001 dly=L~ - Y~ dmz=M~ - Z~

dr =SQR(dkx^2 + dly^2) !Plan distancedd =SQR(dkx^2 +dly^2 +dmz^2)!Distanceazi=ATN(dly/dkx) !Azimuth

IF facecam THEN ROTz 90+azi-W~

These two illustrations come from theHelp pages on Syntax and GDL whichare available in ArchiCAD 5.0. Help inArchiCAD 6.x is provided through WebPages and Acrobat files. These imagesmay be old, but they present a verysimple route to using Global Variables.

RTFMAfter you have been through these pages, you may find themanual easier to read!However, it is more likely that after you have tried a fewexercises, you will also find these pages easier to read.Do everything one step at a time!

Page 57: Cookbook3_1

1.43

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Globals in ActionAs an example of using Globals, here is a tiny 2D Script

THIS little object is a stretchy pointer/labeller, whereby no matter how muchyou rotate the entire object, the round box with the line in it remains upright.

If the object is ‘mirrored’ then V~ is 1, else V~ is zero. W~ is the angle of rotation of theobject. Two simple IF statements enable you to decide which way to rotate the circle. Ifyou want tighter code then you can reduce the number of lines (see below). It is notessential to use ‘tight code’ because the GDL parser is quite happy to read two linesinstead of one. It’s a matter of professional satisfaction – as you get better at GDL you aimto tighten up your code.

!Circle CIRCLE2 0,0,B/2 LINE2 -B/2,0,B/2,0 DEL 1

!Pointer Linepsiz=B/10HOTSPOT2 B/2,0 LINE2 B/2,0,A,0!Arrow POLY2 3,1, A-psiz*2,psiz, A,0, A-psiz*2,-psiz

!2D Script!Demonstrates!control of rotation

!Stretchy Hotspots HOTSPOT2 0,0 HOTSPOT2 A,0 HOTSPOT2 0, B/2 HOTSPOT2 0,-B/2

!This one-line routine!keeps the circle levelIF V~=0 THEN ROT2 -W~IF V~=1 THEN ROT2 W~

Here is another way of doing it – shorter – by usingan ELSE in the IF statement:IF V~ THEN ROT2 W~ ELSE ROT2 -W~

Here is the shortest way of doing it – by using theGlobal as a flag (whose value is either 0 or 1); youcan then apply a trick which changes 1 and 0 to 1and -1 (see TIPS:Maths Tricks of the Trade.)ROT2 W~*(V~*2-1)

Value Lists

I WROTE in earlier versions of the GDLCookbook how much I wished that ArchiCAD could

support Popdown menus in GDL – Lo and Behold,in AC 6.0 onwards we did have popdown menus! –but the method for making these lie in an unexplainedpart of the manual – called VALUES.

Value Lists are now one of the most desirable fea-tures of GDL. You can make objects even smarter byoffering the user a list of options in words or numbers,in the same way that you are offered materials and pencolours. This makes the user’s decision more informed,and makes it less possible for them to make an error. Ifyour popdown menu offers three distinct choices forthe shape of an object, the user cannot mistakenly en-ter a fourth and wrong choice.

There are many examples throughout the Cookbookof value lists at work. Value lists are written in the Pa-rameter script or Master script (in 6.0, they can be writ-ten in their own script window). You then need someIF statements in the Master script to decide what to dowith the user’s choice.

Words or Numbers work well in value lists, but Ifind that wordy value lists are more helpful to the userin describing the purpose of their choice – from whichnumbers may be the consequence.

For example, for a smart car model, you can script apop-up menu saying ‘Saloon’, ‘Coupe’, ‘Estate’, ‘Con-vertible’ and your script can interpret that and use anIF statement to set a flag of values 1, 2, 3 and 4. Thesenumbers can be used in subroutines to produce thecorrect shape of car.

An even better innovation in 6.5 is the availabilityof Pictorial Value Lists which can work in a customdesigned dialog box (the ‘user interface’) – you canoffer the user a scrolling set of picture tiles of the sortthat you may have seen if you have used the recentDoor and Window libraries from Graphisoft.

GDL objects can now be much friendlier to the user,and for the developer, there is less need to write errorcatching routines.

See the Value List example inthe Fire Extinguisher!

VALUES 'fxtype' 'Water','Halon', 'Powder','Foam','CO2'

A typical script for a Value List, and the result

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 58: Cookbook3_1

1.44

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

DEFINE FILL is a nightmare as you have to define Fill patterns inbinary, valuing each dot. The same command also includes routines todefine the fill by vectors. But then if you don’t have a fill, all your objectscould have transparent 2D symbols and look wrong. For the moment,here is a very useful routine for making a pure white fill. In other casesyou can have a user parameter, asking the user to specify the fill for the2D symbol. For this definition, the number of zeroes is very important.

DEFINE FILL 'nofill' 0,0,0,0,0,0,0,0, !count the 11 zeroes!0,0,0

Attribute Definitions

DEFINE

ONLY a Masochist could possi-bly enjoy DEFINE FILL and

DEFINE LINE_TYPE; but DEFINESTYLE and MATERIAL are essentialparts of your vocabulary. Once de-fined, you can command GDL to usea Style, Material etc, by the commandSET. In fact, you do not need SET;just saying MATERIAL followed bythe name will be sufficient.

DEFINE STYLE is essential if anyTEXT2 is to be included in a 2D sym-bol – followed by the SET STYLE (orjust ‘STYLE’) command for short).

It is even more important if youhave more than one line of text, andif you intend to print or plot the plans,because you can control the positionof the text, and the font plotting andprinting height.

Once you have a correct workingstatement like this one, you can copyit and paste it to your next 2D Script.In fact, keep it in your Scrapbook orNotepad for frequent use.

The ‘touchtone’ keypad symbolises theway that TEXT is located verticallyand justified horizontally.

Size Most dimensions in GDL are always assumed to be in Metres, butthis is one odd case where font height produced by the plotter has to bedefined in millimetres (even in the USA) For this reason, when you statethe font size in the parameter box, you must use use ‘real number’, or‘integer’, and not use the ‘length’ , because ‘length’ could be changed bythe dimension settings of the project. If font size is not stated, the TEXTwill not appear.

Anchor defines the position where the text starts writing. If you use ‘1’,it will be left justified, and above the point of text entry. If you use 2, itwill be centred, and if you use 3 it will be right justified. Larger numberschange the vertical position of the text. It’s like the keypad of a touchtonephone.

FaceCode is simply whether the text is plain, italic, bold etc. Codes are:

0=Normal, 1=Bold, 2=Italic, 4=Underline, 8=OutlineOutline, 16=ShadowShadow. Youcan combine the numbers.

See the Attribute Definitionexample in the FireExtinguisher!See Voyager for Define Textureand Line type

DEFINE MATERIAL is very im-portant if you want to carry materialswith your GDL object so that, whendropped into someone else’s model,will still have the correct colour andappearance. People often tweak theirmaterials and material index numberschange. ‘Whitewash’ and ‘StainlessSteel’ may have disappeared... Mercy!

In my smart car object, it is vitalthat red tail lamps and indicators lookright, and that the white bodywork ofthe police car does not look as greyas ‘whitewash’. The taillamps changefrom reflective red in daylight, tobrightly emitting red when the lightsare turned on.

DEFINE MATERIAL "Bright_Metal" 0,0.84, 0.83, 0.85, !Surface RGB0.95, 0.10, !ambient, diffuse0.95, 0.0,!specular,transparent57, !shining4, !transparency attenuation1,1,1,!Specular RGB0.0, 0.0, 0.0, !Emission RGB0.0 !Emission attenuationshmat=IND(MATERIAL,"Bright_Metal")

IF shodata THENDEFINE STYLE ‘display’ ‘arial’, fhigt,1,0 SET STYLE ‘display’ TEXT2 0,w2,’span’ TEXT2 0,0, tmod*(tnum-1)ENDIFRETURN

DEFINE MATERIAL "Metalpaint" 3,0.84, 0.83, 0.85 !Surface RGB

This is better thanMATERIAL 0: PEN ccol

This is definitely Voyager stuff so theexample is for reference.

To make your life easier, GDL haspredefined surface qualities, like ‘me-tallic’(3) so try this simpler definition:

2: Matte: non reflective3: Metal: shiny but non reflective4: Plastic: not shiny, but reflective5: Glass: transparent (with colour)6: Glowing: with colour7: Constant: horrid! no shading

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 59: Cookbook3_1

1.45

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

STATUS & Masking values –are one of the reasons why new

purchasers of ArchiCAD snap theGDL manual shut again, assumingthat they will never cope with GDL.But when they are explained, theGDL user rapidly recognises the val-ues of masking, and learns how toapply it.

Status Values apply to things whichare 2Dimensional in nature (even ifthey are 3D objects). All they cando is to say if a Line is to be drawnor missed out. POLY_ and POLY2_are the prime examples of 2D ele-ments that uses Status Values.

3D Scripts which define a 2D out-line for 3D form-making also useStatus values – for example, defin-ing a profile in TUBE, SWEEP andREVOLVE.

Masking Values apply mostly to 3Dobjects – elaborating the details ofhow to object is to appear in 3D –lines and surfaces.

For Planar elements the choice ofdrawing line edges is either Yes or No

For Prisms, there are 0-15 permutationsfor the status of edges. This is anexample of 13: no vertical lines visibleon the curved surface.

Status and Masking values

See the Masking example in theBocaccio Chair 10 pages ahead

Masking Values onPrisms

MASKING values are usedto define how a surface is to

be drawn on a 3D Prism. The Topsurface is always drawn. But the defi-nition of the side surface needs todescribe the actual face and all thelines surrounding the surface.

On Prisms, there are only 0-15permutations of lines and surface toeach facet of the prism. When youare not sure, just write 15 – that drawseverything.

If you put an 8 in, it draws the sur-faces without the lines. If you wantto make one side draw differentlyfrom another, experiment with thescript to make sure that you attachthe different value to the correct line.

Masking Values oneverything else

WITH more complex objects, you declare an over-

all masking value for the wholething, which is written on the firstline. For safety, just start by writing63 for most objects until you needto change it.

Certain objects also have specialconsiderations:- for example, withREVOLVE, you can have a startingangle surface and an ending surface.The masking values for this will be-have differently from a SWEEP.Therefore for Masking values, youneed to have handy access to amanual.

The Cookbook gives a summaryof the object masking for each com-plex 3D command.

Adding 64 to the masking (e.g.63+64) will reveal all the lines whichmake it. For example in a COONs,you will see all the triangulationlines.

1 draws the bottom edge line.

2 draws the vertical side line.

4 draws the top edge line.

8 draws the side surface as solid.

64 smooths the edge

You can add these yourself in any combina-tion. The examples adjacent illustrate thispoint.

Let’s explain Prism masking better...Masking values are the numbers that come after each XY location in the listing ofa PRISM_ (underscore) and other similar 3D objects. In Autoscripted objects, theseare either 15 or 79, or -1.

15 means draw everything, 13 means draweverything except vertical lines (left). 8draws the Prism with surface only, but nolines. 0 makes that portion of the Prism lookvacant. 79 means that 64 is added to 15,telling GDL that the point is part of a curveand that the smoothing should occur inphotorendering. –1 means that the objectoutline is finished.

This is the binary system in action.

2D CrosshairsIF stretchiness is a big feature of your object, the A.B pointsmay not actually be within the object boundary. To makethem visible to the user, plant a 2D crosshair at the A,Bpoints. e.g. for point A,0, write in the 2D script: LINE2 A-0.02,0, A+0.02,0 : LINE2 0,A-0.02, 0,A+0.02Don’t forget that it is better to declare all your stretchyHotspots before you issue the Project2 or the rest of the 2Dscript.

Fill PatternsQuick fill patterns for bitmaps are as follows:DEFINE FILL ‘blak’ 255, 255, 255, 255, 255, 255, 255, 255, 1,0,0 ! totally filled fillDEFINE FILL ‘grey50’ 85, 170, 85, 170, 85, 170, 85, 170, 1,0,0 ! 50% filled fillDEFINE FILL ‘grey25’ 85, 0, 170, 0, 85, 0, 170, 0, 1,0,0 ! 25% filled fillDEFINE FILL ‘tiled’ 64, 192, 192, 192, 192, 192, 255, 255, 1,0,0 ! 3D tiled effect

Byzanti
Highlight
Byzanti
Highlight
Page 60: Cookbook3_1

1.46

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

PolyLines that areimmediatelyUSEFUL and USABLE:

900, 1000, 4000.

Some of these have already beenillustrated in earlier pages of theCookbook.

Polylines are fully covered inthe Voyager section of the GDLCookbook.

Usually, prisms etc. are definedby absolute XY values. The lowernumbered polylines (100, 200,300 etc) are very useful for ‘rela-tive’ locations, i.e. ‘turtling’ frompoint to point.

POLYLINES enable you to make interesting shapes with PRISMs andother functions that you could not achieve with XY coordinates. You

can use Polylines with POLY_, PRISM_, CPRISM_, BPRISM_, CROOF, EX-TRUDE, PYRAMID, REVOLVE, SWEEP, TUBE, POLY2_, CUTPOLYA,WALLHOLE and more.

Polylines are also more economical – if you look at a curve that hasbeen autoscripted as a cPRISM_, it turns a circle into 36 polygonal X-Ycoordinates, each with 6 figures of decimals, and followed by a 79. Makea slab with a circular hole into a simple Library part and examine the scriptfor yourself.

All these 79’s can be replaced by just two lines, or sometimes just atweak of an existing line. Polylines are also controllable by RESOL, RA-DIUS and TOLER commands.

Some Polylines have to work together – e.g. if you want to issue a com-mand that involves Radius of rotation, it will return an error unless youhave first defined a Centre of rotation.

PolyLines – why use them?

I T IS DIFFICULT to say whichpart of the GDL Manual is the

most alarming to the GDL newcomerThe section on ••Polylines••would be firmly linked with theother leading contenders like thePIPG, VERT, BODY sections, theProperties scripting; CWALL andCROOF; OUTPUT & INPUT; PUT &GET; XFORM. Polylines are in facteasier than all of those.

GDL Voyagers need Polylines: ForDiscoverers, let’s make a start.Polylines are best learnt a bit at atime. The exercises in the Voyagerand a few in the Discovery make useof Polylines and explain them as yougo along.

PolylinesSpecial mask/status values: Curvy edge lines

See the Polylines example inthe Fire Extinguisher!

Zzyzx is a ‘dynamic parameter’ denotingHEIGHT. We are already used to the idea that Aand B are parameters for width and length – Ar-chiCAD recognises them as special ‘magic’ param-eters that can make objects stretchy. They aregiven special prominence in the Settings dialogbox. The vertical parameter ‘zzyzx’ is named af-ter a small town in the Mojave desert in Nevada;the Heathrow to LAX jumbojets pass right over it.Zzyzx is the magic parameter used for height,

What is

zzyzx?

and if you use it, the height will bedisplayed in the Info Box Palette.Objects with zzyzx can be stretchyin the 3D view – a 3D hotspot setwill appear at the height specifiedby zzyzx and if you grab the spots,the ‘pet palette’ displays a ‘stretchvertically’ option.

See Tips and Tricks in the Voyagercourse for more about zzyzx.

Page 61: Cookbook3_1

1.47

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

T HIS SHAPE on the right isan ordinary PRISM_ with all

points defined as XY locations, and15 used as the mask (15 means drawall lines and surfaces on the edge).

Now try converting it to make useof Polylines. 1000 is the easiestPolyLine to use – starting from onepoint, it branches off in a gracefulround curve and lands on the nextpoint – the one that has the 1000 com-mand written into it. It’s a tangentialcurve, because the existing straightstart and straight ending lines definethe way that the curve leaves and ar-rives.

You can write 1015 or you can writeit as 1000+15 – the longer way of writ-ing it helps you pick it out visuallyfrom a long block of script, and dis-plays how the 1015 was derived.

Polyline 900 and 4000 are goodcompanions for making circles.

0,0,900 means that the centre of theCylinder or circle is at the point of theorigin, 0,0.

0.1,360,4000 means draw a circle ofRadius 0.1, through a full circle of 360degrees.

This gets you a solid Cylinder.

Using the same Circle Centre, you canissue the 4000 command again, witha smaller radius, and you will get ahollow tube.

Using 13 instead of 15, you couldreduce the number of lines to bedrawn on the side surfaces.

Using PRISM and Polylinesto make a Hollow Cylinder

!PolyLine 1000 DemoPRISM_ 9,0.2, 0.00,0.00,15, -0.10,0.30,15, 0.10,0.30,15, 0.10,0.40,15, 0.20,0.40,15, 0.20,0.10,1000+15, !<add 0.15,0.10,15, 0.15,0.00,15, 0.00,0.00,-1

!PolyLine 900,4000 DemoPRISM_ 2,0.2, 0,0,900+15, 0.10,360,4000+15

!below

!PolyLine 900,4000 DemoPRISM_ 3,0.2, 0,0,900+15, 0.10,360,4000+15, 0.08,360,4000+15

!below

Ordinary Prism

!PolyLine 1000 DemoPRISM_ 9,0.2, 0.00,0.00,15, -0.10,0.30,15, 0.10,0.30,15, 0.10,0.40,15, 0.20,0.40,15, 0.20,0.10,15, 0.15,0.10,15, 0.15,0.00,15, 0.00,0.00,-1

Prism enhanced byPolylines

Try Polylinesyourself!

Object NamingArchiCAD 6.5 requires that all Library Objects end in the suf-fix .GSM (even on the Mac), and a similar limit applies toDoors and Windows (.WIN and .DOR). There are more specialsuffices for Zone stamps, Lamps and Labels. This makes themmore portable. Beware if you convert a complex 6.0 projectto 6.5. Archive that old library before throwing it away. Youmight wish you had kept it!Folders in a Library should reflect the logic of their contents.‘Doors’, ‘Windows’, ‘Labels’, and so on.

Object names should include the ArchiCAD version number(50, 60,65,70) and should be distinguishable from other ob-jects in a loaded library: to avoid ‘missing or duplicatedobjects’ messages. For example ‘door.DOR’ is bad, but‘door_glazed_ntc65.DOR’ is unlikely to clash with anythingelse.Avoid names longer than 27 characters+3, and avoid usingspaces in object names. Although supported by Mac andwindows, there are problems with building the index at thetime that libraries are loaded, and with calling macro ob-jects. Underscores should always be used instead of spaces.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 62: Cookbook3_1

1.48

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

REVOLVE!

REVOLVE takes the outline (thatcan be ‘drawn’ in the same way

as in POLY_, PYRAMID or EXTRUDE– onto the X-Y plane) and Revolves itaround the X axis.

It doesn’t allow you to describe anypoints with a Y value that is zero ornegative. i.e. All points must be higherthan the X-axis – one millimetre willsuffice. You cannot drill a hole in thecross section.

The last number on the first line isthe MASK. To get the REVOLVE drawnas totally solid, 63 is the ideal mask. Ifthe object is solid and lathed, then 63will do. However, a revolving objectthat is free of the centre (like a torus /doughnut) must have a masking valueof 0 to start off with.

REVOLVE can give you an objectstanding upright if you first applyROTy –90 first. A Vase, Baluster, Clas-sical column – in fact most REVOLVEsare preceded by a ROTy -90.

RESOL is a big issue with REVOLVE.One single revolve can result in hun-dreds of polygons, especially as thedrawn out line can have includecurved polylines.

Revolve is one of the must usefulcommands in GDL – but draw theX-Y outline on paper first to thinkit out

!REVOLVE Demonstration!Syntax:- REVOLVE n,alpha,mask,! x1,y1,s1,....xn,yn,snREVOLVE 9,90,63, 0.00,0.01,0, -0.10,0.30,0, 0.10,0.30,0, 0.10,0.40,0, 0.20,0.40,0, 0.20,0.10,1000, 0.15,0.10,0, 0.15,0.01,0, 0.00,0.01,-1

!REVOLVE Demonstration!Syntax:- REVOLVE n,alpha,mask,! x1,y1,s1,....xn,yn,snROTy -90REVOLVE 9,90,63+64, 0.00,0.01,0, -0.10,0.30,0, 0.10,0.30,0, 0.10,0.40,0, 0.20,0.40,0, 0.20,0.10,1000, 0.15,0.10,0, 0.15,0.01,0, 0.00,0.01,-1DEL 1

Remember, the ‘n’after commandslike REVOLVEand SWEEP is thenumber of XYpoints definingthe outline.

See the REVOLVE example inthe Fire Extinguisher!

bPRISM_bPRISM_ (bent PRISM underscore) issimilar to cPRISM, with the added abil-ity to curve it – by adding in a valuefor a radius. It always curves in adownward direction, along the X-axis.

If you want to curve •upwards•,you can issue a MULz -1 (multiply allZ values by -1) command first.

You can also enter a negative valuefor the depth of the prism, and bring itbelow the origin (and thus make atighter curve).

When you do a cursor movementor change, it’s wise to DEL as soon asit is possible afterwards.

With bPRISM, you can make longhelices, and perforated tubularstructures. It also reverses thematerials of Top and Bottom.

360:!bPRISM_ Demonstration!Syntax:-! bPRISM_ topmat,botmat,sidmat,! number,height,radius,! x1,y1,15,! x2,y2,15,...etcbPRISM_ "Sandstone","Pine","Zinc", 9,0.05,0.4, 0.00,0.00,15, -0.10,0.30,15, 0.10,0.30,15, 0.10,0.40,15, 0.20,0.40,15-2, 0.20,0.10,1013, 0.15,0.10,15, 0.15,0.00,15, 0.00,0.00,-1

MULZ -1GOSUB 360:!bPRISM Demo DEL 1

Most 3D commands require you to enter the ‘number’ of X-Y coordinates in the object. For examplePRISM 4,0.2 means that there are 4 points on the prism, with a height of 0.2. Similar rules apply toREVOLVE, SWEEP and almost all complex 3D forms.Masking Values: The next command, REVOLVE is the first to use a Masking value for the whole object –usually 63. Each command has a different way of using these. Each complex command in the GDLCookbook is accompanied by a small explanation of the object masking codes.

Revolve is always built aroundthe X axis. So if you want it tostand upright, issue a ROTy -90command before the Revolvecommand.

FPRISM_ andSPRISM_ arecovered in theVoyager Course

Curvy 3D commands

bPRISM requiresevery point to havea masking value.Start by giving it15, then changesome to 13 [15-2] toremove verticallines.

Changing these lastvalues from 0 to 1will remove the linethat follow thesur face of therevolve. 2 producesa hard edge thatovercomes thesmoothing in arendering.

Masking: 1=Base surface, 2=Top sur-face, 4=Side surface Start, 8=Side surfaceEnd, 16=Side edges Start, 32=Side edgesEnd, 64=Cross section edges.

With a mask of 127 (or 63+64) you getall the lines drawn, but do you want allthese? – your choice!

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 63: Cookbook3_1

1.49

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

!Fire Extinguisher!Discovery and Voyager

!Bottle BodyMATERIAL 'fxmat'PEN pcolTOLER 0.002 !Curvature ROTy -90REVOLVE 4,360,63, 0 ,dm/2,1, zzyzx-0.06,dm/2,1, zzyzx ,dm/6,1001, zzyzx ,0.00,1DEL 1

!HandleMATERIAL 'hanmat' ADDz zzyzxCYLIND 0.03,0.03 ADD -0.03,0,0.06 ROTy -110MATERIAL 'nozmat' CYLIND 0.05,0.01 DEL 2 ADDz 0.03 ROTx 90 ADDz -0.02

MATERIAL 'hanmat'PRISM_ 9,0.04, -0.03,0,15, -0.04,0.05,15, 0.11,0.10,15-2, 0.12,0.09,1015, 0.03,0.05,15, 0.12,0.01,15, 0.12,0.00,15, 0.03,0.03,15, 0.03,0.00,15DEL 4

VALUES 'fxtype' 'Water','Halon', 'Powder','Foam','CO2'

Fire Extinguisher

If you want the user to have a pop-up menu of options, putthis script into the Values List/Parameter Script. The MasterScript parses the result.

THIS LITTLE SCRIPT produces a useful object; it also introduces more techniques in 1

page than any other exercise in the Cookbook! Itcovers: REVOLVE; PolyLines; zzyzx, Value Lists,Defining Material, 2D text.

ParametersThe colour and type of the extinguisher is determinedby the Value List – which also generates a Defined Ma-terial and a Text annotation. The height of the barrel iscalled ‘zzyzx’ – enabling it to be stretched. You couldalso have a value list for Litres/Gallons and let the valuelist work out the best diameter and size from a knownrange of sizes (you could then delete ‘d’ and ‘zzyzx’).

2D ScriptInstead of using PROJECT2 (just too easy), try writing asimple 2D script, which looks just as good, and will guar-antee faster drawing in your plan view. Use the ARC2 com-mand to get a hidden line effect. If the user enters a validFont size, the script can label the Extinguisher. The TEXT2routine can indicate whether it is Water, CO

2, Foam, or

Powder. You could also write a short properties script thatwill send this information to a Components Listing. Ques-tion: If you use A_ (drawing scale) can you autosize thetext so it is always the same relative to the object?

!Fire Extinguisher!2D Script

PEN pcolHOTSPOT2 0,0ARC2 0,0,d/2,15,345CIRCLE2 0,0,0.03RECT2 -0.04,0.02, 0.12,-0.02

IF fsize>0 THEN DEFINE STYLE "ftext" Arial, fsize,2,0 SET STYLE "ftext" TEXT2 0,0,fxtypeENDIF

3D ScriptDeclare Material & Pen. Reduced resolution of curva-ture will speed up rendering, TOLER does the best job.

• REVOLVE is done along the X-Axis, so you have toROTy -90 for the object to stand upright. Remember toDEL 1 afterwards. Setting out the X-Y locations for RE-VOLVE is like laying out a set of points on the X,Y plane– just as you might do for a POLY.

• You need a sleeve at the top of the bottle, & a squirt-ing spout – done with CYLIND.

• Finally, you build a PRISMatic handle on top. Thisrequires you to position the X-Y plane sideways, so morecursor commands are required to get the cylindrical topand handle into place. DEL 4 to finish – always returnthe cursor to the origin.

Polylines: In the REVOLVE and PRISM commands, theuse of a 1000 poly line command (added to 15 in thePRISM) is required to get a tangential curve betweenthe two points mentioned. Type in the same commandswithout the 1000; use a 0 or a 15 instead, and then putthe 1000 back in – see what happens. This is a goodexercise to experiment with Polylines. The last statuscodes for the Revolve, 1, remove visible lines on thebottle. Try them with 0 instead. You can also removesurplus lines from the handle with a -2 on each of the15s.

Master ScriptThis works out suitable values for the Red, Green andBlue components of the colour of the bottle and han-dles and defines a new Material based on these colours– using a plastic surface quality.Revisit the Fire Extinguisher in the Voyager course

!Master ScriptIF fxtype="Water" THEN pred=0.6:pgrn=0.0:pblu=0.0ENDIFIF fxtype="Halon" THEN pred=0.0:pgrn=0.6:pblu=0.0ENDIFIF fxtype="Powder" THEN pred=0.0:pgrn=0.0:pblu=0.6ENDIFIF fxtype="Foam" THEN pred=1.0:pgrn=1.0:pblu=1.0ENDIFIF fxtype="CO2" THEN pred=0.0:pgrn=0.0:pblu=0.0ENDIF

DEFINE MATERIAL 'fxmat' 4, pred,pgrn,pbluDEFINE MATERIAL 'nozmat' 4, 0.8,0.8,0.8DEFINE MATERIAL 'hanmat' 4, 0.01,0.01,0.01

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 64: Cookbook3_1

1.50

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

THIS EXERCISE explains the basics ofhow to make a simple window, using

drilled prisms.For serious architectural work, authentic looking windows anddoors are essential. If you do not find a suitable one in the existinglibrary, you have to make one. It is not well explained in any ofthe official literature, and too much trust is placed in building win-dows with the slab tool, and relying on a 3D view saved as a Li-brary object to make the window. These may look OK, but willnot be parametric.

The window explained here is so simple that you could easilymake it with slabs, but then it wouldnt be parametric. This exer-cise shows how a window COULD be made with scripting. Withthe knowledge gained from doing this exercise, you will betterunderstand how ArchiCAD uses windows, and can then attemptwindows of a more complex nature that go well beyond what canbe done with the slab tool.

Windows that use soldier courses and sills, or chamfered re-veals require a knowledge of Global Variables. These tell theGDL object the current thickness and materials of the walls. Win-dows always cut rectangular holes in the wall based on the di-mensions A and B. If the window is not rectangular, you have tobuild chunks of wall around it (to finish as a rectangular shape) oruse the new AC6 command, WALLHOLE. Let’s stick with a rectan-gular hole for now.

ParametersIf you open the new Library object as a Window,you get a parameter box like this. Much of the mid-dle section is not required until you start usingjambs and head details. It is possible to start a win-dow as an ‘object’, and convert it to a window later.It cannot cut holes in walls until it is officially de-fined as a ‘window’ in ArchiCAD.

Exterior (left) and Interior (right) views

Finished 3D window should look like thisin the 3D window – lying face down,bottom face flat on the X-Y Plane.

Simple Sash Window

Golden Rules...for making Windows (and Doors)• Build the window with the outside face fac-ing downwards, level with project zero. (Eventhough you may want to recess the frame intothe opening, you should build the GDL model asstated).• Position the origin on the centre line of thelowest sill of the window.• PRISM_ makes better frames than BLOCK –but TUBE makes better frames than PRISM_, in-cluding rebates and chamfers, and more complexcurves.• Use POLY instead of PRISM for Glass unlessyou want it to look thick.• Repeated items like sashes should be self con-tained subroutines.• Create the 2D view by using the PROJECT24,90,1 command, with a ROT2 180 command to‘turn the camera upside down’. You could thenattempt some 2D scripting, using Project2 as a guide.• The A dimension is the width of the window, and B is the height.(Autoscripted windows do this too, but go very wrong when youadd jamb, sill and head brickwork.) If you use B for height, youwill be able to stretch the windows in Section / Elevation.• When you get more confident, experiment a bit at a time withopening sashes, multiple glazing bars, jamb, head and sill details,reveals, architraves and ironmongery.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 65: Cookbook3_1

1.51

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

!Truly simple window!GDL Cookbook!3D Script

p=0.04 !Min. frame dimens’nPEN 1!Offset to lower left corner ADDx -A/2

!Main FrameMATERIAL fmatPRISM_ 5+5,p*2, 0,0,15, A,0,15, A,B,15, 0,B,15, 0,0,-1,

p, p,15, A-p,p,15, A-p,B-p,15, p, B-p,15, p, p,-1

!Both sashes ADD p,p,pGOSUB 100 !Lower Sash DEL 1

ADD p,B/2-p/2,0GOSUB 100 !Upper Sash DEL 1

!Sill ROTy 90MATERIAL fmatPRISM 5,A, 0,0, p*2,0, p*2,p/2, 0,p, 0,0DEL 1

DEL 1 !Undo offset

END:!------------------------

END:!---------------

100:!Sash Subroutinesh=(B-p*2)/2+p/2 !Sash Htsw=A-p*2 !Sash Width

MATERIAL fmatPRISM_ 5+5,p, 0, 0,15, sw,0,15, sw,sh,15, 0, sh,15, 0, 0,-1,

p, p,15, sw-p,p,15, sw-p,sh-p,15, p, sh-p,15, p, p,-1

ADDz p/2MATERIAL gmatPRISM_ 5,p/4, p, p,15, sw-p,p,15, sw-p,sh-p,15, p, sh-p,15, p, p,-1

DEL 1RETURN

3D Script• Use a simple variable to represent thesmallest ‘pixel’ size of your object.Here, ‘p’ (representing frame thickness)is much easier to use in the prism com-mands than real dimensions. It meansyou can change the frame thickness bychanging the value of the one singlevariable.

• Because you must Centre the originon the axis of the window, but becauseit is also easier to build anything fromthe bottom left corner, apply an ADDx-A/2 offset. You will see how it workswhen you try it.

• Material command is essential be-cause sash windows could be wood,PVC, aluminium, or a variety of colours.• PRISM_ command defines the mainframe of the window. By using the mainvariables of A and B, and a frame thicknessof ‘p’, it is easily defined. Use 15 for all thepoints, and -1 to denote the end of one sur-face and the start of another.

• The sashes occur twice, and you need tohave the sash frame and the glass act to-gether as a single object, so you shouldmake the sashes as a subroutine.

• The Sill is a simple prism, rotated so as tolie flat in the correct location, facing down-wards.

• Make sure you put comments in for eachsmall routine.

• Finally, you DEL the -A/2 offset.

• The routine must finish with an ‘END’command so that you can write your sub-routines below.

• The sash is created with a subrou-tine. To keep it simple, work out theheight and width of the sash first, andthen use the simple variables ‘sh’ andsw’ in the PRISM command. Note thatthe Glass is exactly the same prismprofile as the hole in the sash frameprism – so you can copy and pastethe coordinates.

• It is a good idea to enable the userto define the material for Glass in casethe user wants to use Ice (for translu-cency) or Mirror.

Complex windowshapesWindows and Doors are made, by de-fault, with Rectangular openings.More complex window shapes cannow be made with the WALLHOLEcommand. See the Curvy Window inthe Voyager course, and a simplercurvy window in the Discoverycourse.

With PRISM_you have to adda ‘status value’

of 15 to the endof each

coordinate, and-1 to tell it to

change from theouter to the

inner outlines ofthe frame.

!Window - 2D Script ROT2 180PROJECT2 4,90,1 DEL 1

2D ScriptFinally, the 2D window script looks like this. I use a Project2 command,but unlike the 3 you have used for other objects, you use 4. The ROTy 180turns the camera upside down (so that the image is corrected). If you wantsuperfast 2D redrawing in a large building, this 2D image should be scriptedusing the Project2 as a guide – and when the scripted one looks correct,you delete the Project2 command.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 66: Cookbook3_1

1.52

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Simple Curvy Window

!Very Simple round window!3D Script

RESOL 36WALLHOLE 4,2,-A/2, 0,7,-A/2,B-A/2,5, A/2,B-A/2,1007, A/2, 0,7

ADDz fdep/2MATERIAL gmatPOLY_ 4,-A/2, 0,7,-A/2,B-A/2,5, A/2,B-A/2,1007, A/2, 0,7DEL 1

MATERIAL fmatPRISM_ 5+5,fdep,-A/2, 0,15,-A/2,B-A/2,13, A/2,B-A/2,1015, A/2, 0,15,-A/2, 0,-1,

-A/2+fwid, fwid,15,-A/2+fwid,B-A/2,13, A/2-fwid,B-A/2,1015, A/2-fwid, fwid,15,-A/2+fwid, fwid,-1

3D Script

Parameters: A and B define width and height

Build it on the X-Y floorplane as usual, with theoutside frame face on level zero, and the origin onthe centre axis.

The list of X-Y locations can be copied and pasted from theWALLHOLE outline straight into the POLY definition, withoutchange. Although POLY requires only 1 or 0 for the Status setting,any odd number is the same as 1, and even number is equivalentto 0.

The Wallhole outline has been modified with a 5 instead of theusual 7, to remove the lines around the arch. The same has beendone for the Prism, using 13 instead of 15.

The window is beautifully stretchy when viewed insection. I love WALLHOLE. It’s so effective andcompact and precise. I use it even for rectangularwindows.

THIS EXERCISE exploits the wonderful new commandin ArchiCAD 6+ called WALLHOLE. It also demonstrates

the effectiveness of easy-to-use Polyline statements.

It quite liberates the GDL user from the complex proceduresfor making windows that are not rectangular. If you can definethe outline of the window shape with the similar set of com-mands that you would use to draw a POLY, EXTRUDE or PRISM, then you can make a window..... with the limitation that a sin-gle WALLHOLE command must be convex in shape. To makeconcave window shapes (such as an L-Shape), you can maketwo or more Wallholes together.

This window is a simple arched window, with fixed glazingand a simple outlined frame, but it is ideal for illustrating theprinciple. A more complex use of Wallhole is illustrated in theVoyager course.

!Simple round window!2D Script

ROT2 180PROJECT2 4,270,1 DEL 1

2D ScriptNote that for the script in 2D, youfollow the trick shown here, todo a Project2 having first done a180degree rotation. For a win-dow that is to be used manymany times, you could script thewindow using the RECT2 com-mand.

The 2D symbol in plan

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 67: Cookbook3_1

1.53

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

ABS(number) returns the positive value of a number,regardless of whether it is negative or positive. Youcan prevent the user entering negative parameters intothe dialog box with a simple statement like:item=ABS(item).

SGN(number) returns a 1 if the number is positive, ora -1 if the number is negative. Small token numberslike this which signify the status of a number are called‘flags’, in programming jargon.

RND(number) returns a random number value be-tween 0.0 and 1.0 and is multiplied by the number inthe bracket, e.g. RND(50) is numbers from 0 to 50,RND(0.1) is from 0.0 to 0.1. RND numbers are RealNumbers, so can only be used to generate Dimensionsif you are using Metres. Unfortunately, GDL’s randomnumber generator is weak, and generates the same se-quence each time from a fixed list, with a preponder-ance of low numbers. The only way to get a more nearlyrandom number is to get the list to start from anywherebut the start. You could do FOR k=0 TO SYMB_POS_X:x=RDN(1): NEXT k (the list is started from the numberequal to the object’s horizontal distance from the planorigin – different in most cases). In animations, youcould use the Frame number as a randomisation seed.

INT(number) returns the integer of the number – aninteger is a round number (without decimals). The INTcommand ALWAYS rounds downwards, so you can dox=INT(number + 0.5) to get it to round up OR down-ward correctly.

Example: INT(8.56) = 8 (rounds down)INT(8.56+0.5)=9 (rounds up)

CEIL (number) is similar to INT, collects the nearestinteger number larger than the number.

SQR(number) returns the square root of the number.This is useful in matters like the use of Pythagoras Theo-rem in Triangles, and Circle geometry. If you need Cubeand Quad roots, try using the Power symbol – e.g.length**(1/3), width**(1/4)

FRA (number) is the other side of INT(). It returnsthe fraction remaining when you remove the integers.Unfortunately it behaves always in one direction, soFRA(6.3) returns 0.3, but FRA(-6.3) returns 0.7.

PI is useful in circle geometry – it is exact, and there-fore better than trying to put in your own number, suchas 3.1416, and incurring errors in a calculation.

MIN( ) and MAX( ) are useful – they simply tell youthe highest or lowest of a series of numbers or vari-ables that you print in the brackets.

For example:ADDz MAX(leftht,rightht)

to raise the cursor to the height of one of the ridge of amonopitch gable wall.

NOT( ) is useful in IF statements. You could write IF

thing=0 THEN GOSUB 100, but it is more like englishto write IF NOT(thing) THEN GOSUB 100. Also be-cause NOT() either returns a value of 1 or zero, youcould use it as a flag, as in:

LET rotation_angle= 30*NOT(thing). When ‘thing’ isvalid, the angle would be zero and if ‘thing’ is zero,then the angle will be at 30degrees.

AND and OR and EXOR are used as arguments in IFstatements. For example, you could say: IF item>4 ANDitem<6 THEN GOSUB 500. This would certainly iden-tify a floating point number in the region of five. IFitem<4 OR item>64 THEN GOSUB 500 would activatewith all numbers except those between 4.0001 and63.999. Usually, if you say it to yourself slowly in Eng-lish, and digest the natural logic of the AND and theOR argument, you will get it right. I have never neededto use EXOR, but it is exclusive whereas OR is inclu-sive.

EXP, LGT, LOG are ‘transcendental’ functions, to dowith ‘e’ and logarithms. These would be useful if usingcurves, but I have not needed them yet.

MOD is a way of finding the remainder after a divi-sion. For example 8 MOD 2 equals 0 because 2 dividesperfectly into 8. 8 MOD 3 equals 2 because if you di-vide 8 by 3 it goes twice and leaves a remainder of 2.

Trigonometrical functionsSIN( ), COS( ) and TAN( ) – Trigonometry functionsare explained in the diagram below.

ATN(), ASN(), ACS() mean respectively ArcTan,ArcSin and ArcCos. This means that if you know thesides of a right angle triangle, you can easily work outthe angles. ArcTan(0.231) will return you the Anglewhich, if you calculated TAN(angle) would give you aTAN of 0.231. This is essential if you are building lat-tice trusses.

Common maths symbols<> Not Equal to (you can also use #)> Greater than, < Smaller than>= Great than or Equal to<= Smaller than or Equal to^ To the power of... (you can also use **)

All numbers in GDL are ‘Floating Point’, you cannotforce a variable to be an integer.

Declaring variables : number or string

You can force a variable to be a string – this containstext. Once a variable is a string, do not change it backto a number. The script below is likely to produce asyntax error that will baffle you – but the error has beencaused by a previous use of ‘n’.

LET n=”washbasin”FOR n=1 TO 5

GOSUB 100NEXT n

Maths Operators

Here, n wants to be a numberagain, but cannot be – it willreport an error

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 68: Cookbook3_1

1.54

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Trigonometry: You need a basic knowledgeof the right angle triangle – all you need to know is:

• Pythagoras – the Square of the Hypotenuse is the Sum ofthe Squares of the other two sides.

• SOH CAH TOA – You need to remember this motto sothat you can always calculate the characteristics of a trian-gle from minimal information. If you don’t know this onealready, say it to yourself as a mantra whilst being kept onhold on the phone, or standing under the shower.

• Irregular triangles can be analysed by breaking intosmall right angled ones and using SOH CAH TOA.

• The angles of any triangle add up to 180o.

• Many Circle geometry problems (e.g. converting a knownAngle and Radius into X and Y coordinates) are easilysolved with SOH CAH TOA.

Remember: SOH CAHTOASIN(angl)=Opposite/HypoteneuseCOS(angl)=Adjacent/HypoteneuseTAN(angl)=Opposite/Adjacent

Hypoteneuse

angl

(The side) Adjacent (to the angle) (The

sid

e) O

ppos

ite

(to th

e an

gle)

The RightAngle

See more about Circle Geometry and Trig in theMaths Primer in the Voyager Section.

Maths Operators: continued

PROPERTIES and Listing have been extensively rebuilt by Graphisoft for AC_6.X. These provide

greater opportunities for printing out schedules, butalso have greater complexity. AC 6.5 carries a newmanual on the subject. The main difficulties are forArchiCAD users to set up their listings formats etc.

DESCRIPTORThere is a simple solution for GDL writers – whateverthe ArchiCAD user wants to do, DESCRIPTOR can en-sure that your object appears in listings with a correctdescription. It is no good relying on the filename ofthe object. If your object is smart, then the filenamedoesn’t really describe it very accurately. The simplestmethod is to use the DESCRIPTOR command. In yourProperties script for the swivel chair, simply write:

DESCRIPTOR "Swivel Office chair"

It becomes interesting though when you add spe-cific manufacturer’s information.

DESCRIPTOR "Herman Miller chair HM-SX0723"

This is where the growth area of GDL is going to bein the next 5 years. For the first 15 years of ArchiCAD,furniture and component library objects have beengeneric and stretchy. If GDL is to become (to manu-facturers) as widespread as DXF has been for the lastdecade, then they have to see that it encouragesspecifiers to use their products. Its not enough just tohave a self labelling 2D symbol, although this is alsovery valuable. A simple DESCRIPTOR command willensure that if you put THEIR office furniture into theplan, then the correct item will be purchased.

It gets even more interesting if you have a smartobject which could have different descriptions depend-ing on the user’s choice. Take the Fire Extinguisher.This simple (if verbose) property script will send a cor-rect description to the Listing.

!Properties ScriptIF fxtype="Water" THEN objname="Extinguisher: Water"ENDIFIF fxtype="Halon" THEN objname="Extinguisher: Halon"ENDIFIF fxtype="Powder" THEN objname="Extinguisher: Powder"ENDIFIF fxtype="Foam" THEN objname="Extinguisher: Foam"ENDIFIF fxtype="CO2" THEN objname="Extinguisher: CO2"ENDIF DESCRIPTOR objname

Properties – keep it simple!

COMPONENTYou can also use the COMPONENTS command if youwish to include quantitative information. For example,the Fire Extinguisher description does not include thelitres of water or foam. You could calculate the capac-ity from the height and diameter:

capac=1000*(zzyzx-d/2)*(PI*d^2)/4 !capacity calcCOMPONENT "Capacity", capac ,"litres"

GDL works in metres, so you need the 1000 to con-vert cubic metres into litres.

In the case of a real fire extinguisher, it is likely thatthere is a limited range of fixed sizes, so this is solelyfor illustrative purposes. In reality, the parameters forheight and diameter might be replaced by a VALUE LISTthat would allow the user to select one from a varietyof given sizes, so that only the correct sizes would bepassed to the Listing.

Select the object, go to Calculate Menu/Components/Basic, and you will see a small list created, showingyour object.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 69: Cookbook3_1

1.55

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Bocaccio Chair – Prism masking

THIS chair is a simplified edition of the Bocacciochair, to show how prism masking works in prac-

tical use. It also includes a material definition. The chairis simply constructed. If this object was for commer-cial use, one would build into it softer edges and cor-ners.

We want a cube that has a cubic chunk carved outof it. There is no 3D Boolean subtraction in GDL so webuild it up from a seat prism and a prism for the arms.The left hand chair shows the chair with all maskingvalues set to 15. Although the seat element is a square,it is a good idea to include two points that coincidewith the inside line of the arm. This gives you thechance to remove the top line under the arm, but showit across the seat cushion.

3D ScriptLook at the masking on the Prisms for the upholsteryelements. 15 means ‘show all’, so if you write ‘15-4’that means ‘show all except the top line’.

2D ScriptFor a commercial object one writes a proper script. It’seasy to copy the outline for the arms Prism, convertthem to a Poly2 and you are almost done. The chairobject on the CD is fully 2D scripted.

!Bocaccio Chair!Demonstrates Prism Masking

PEN pcolIF upthik>B/6 THEN upthik=B/6

!SeatingMATERIAL setmatADDz sethit-upthikPRISM_ 7,upthik, !Seat -A/2, -B/2, 15-4, -A/2+upthik,-B/2, 15-2, A/2-upthik,-B/2, 15-4-2, A/2, -B/2, 15-4, A/2, B/2, 15-4, -A/2, B/2, 15-4, -A/2, -B/2, -1

ADDz upthikPRISM_ 9,armhit, !Arms -A/2, -B/2, 15-1, -A/2+upthik,-B/2, 15, -A/2+upthik, B/2-upthik,15, A/2-upthik, B/2-upthik,15, A/2-upthik,-B/2, 15-1, A/2, -B/2, 15-1, A/2, B/2, 15-1, -A/2, B/2, 15-1, -A/2, -B/2, -1

ROTy -90ADDz -(A-upthik*2)/2PRISM_ 5,A-upthik*2, !Cushion armhit+upthik,B/2-upthik, 15, armhit+upthik,B/2-upthik*1.5,15, 0,B/2-upthik*2, 15, 0,B/2-upthik, 15, armhit+upthik,B/2-upthik, -1DEL 4

!LegMATERIAL legmat RESOL 8 ADDz 0.04CYLIND sethit-upthik-0.04,0.025

!Cruciform Foot ROTz 45dm=MAX(A,B)*1.2p=0.01 !one 3d pixel

PRISM_ 13,0.04, -dm/2,-p, 15, -p, -p, 15, -p,-dm/2, 15, p,-dm/2, 15, p, -p, 15, dm/2,-p, 15, dm/2, p, 15, p, p, 15, p, dm/2, 15, -p, dm/2, 15, -p, p, 15, -dm/2, p, 15, -dm/2,-p, -1DEL 2

!Black feetDEFINE MATERIAL 'blakfoot' 4, 0,0,0 !R,G,BMATERIAL 'blakfoot' FOR k=1 TO 4 ROTz 45+k*90 PRISM_ 5,0.04, dm/2, -p, 15, dm/2-p*4,-p, 15, dm/2-p*4, p, 15, dm/2, p, 15, dm/2, -p, -1DEL 1NEXT k

!Bocaccio Chair 2DHOTSPOT2 0, 0HOTSPOT2 A/2, B/2HOTSPOT2 -A/2, B/2HOTSPOT2 -A/2,-B/2HOTSPOT2 A/2,-B/2

PROJECT2 3,270,2

These numbers could bewritten as 11. If you write

it analytically as in thisexample, you can easily

run your eye down the listand notice errors.

It’s a good idea to tabulatethe values neatly in

vertical line

The cushion isbuilt on its

side thenrotated into

position

The object will adapt ifthe user stretches it

mischievously

This Prism forms thecruciform leg in one piece.By setting up values for thegoverning large and smalldimensions, you can save

yourself a lot of typing

The user is free to set anew material for themain leg – it can be

stainless steel or painted.But the feet are black. To

make sure that they arealways black, define your

own material, set it anduse it.

This pointcloses the

prism

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Line
Page 70: Cookbook3_1

1.56

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Lattice Truss

THIS is kind of structure could be made by placing, arranging andgrouping the cylinders from the ArchiCAD Library, but it would not

be parametric or smart. We need GDL for a beam that is adaptable todifferent spans and depths.

ParametersThe model is not stretchy, as the lattice is built from manufacturer’sstandard sized modules.

• The Truss is to be done here using only CYLIND to form the tubes.• The user is offered a choice of width, height and any number of mod-

ules, and tubing diameter. This example does not worry about joints,but it would be easy to add balls or cones, which could be a useroption.

• The user can ask the truss to ‘Show Data’ – this could be a print out ofits span or weight.

• As the truss could in fact be a vertical structure (column) or could beleaning (over an atrium) the lean angle option is offered.

3D ScriptEven for a small object, a strictly structured approach is adopted fromthe start. Resolve the model into a series of subroutines, one to drawevery element of the model. The executive script is short in the ex-treme, just calling subroutines.

The technique is to make all the upper elements, in a FOR...NEXTloop, then the bottom tube, and finally, the diagonal tubes. Some trigo-nometry is required to work out the angles of the diagonal tubes. Asthis is an important part of the script, a special subroutine 100: is pro-posed for working out the trigonometry and setting up other param-eters.

100: First set up the usual things like RESOL, Material and Pen. Thenconvert diameter to radius.

Now work out the angle of the diagonal tubes. As the truss moduleas seen in plan is a perfect square, the diagonal across the square is the‘truss module times √2’; the angle of lean of the cylinder will be theArcTan of half that diagonal and the truss depth.

Finally, the Length of the diagonal tube can be found as thehypoteneuse of the right angle triangle formed by the tube – the depthdivided by the COS of the angle. Alternatively, you could work out thetube length by Pythagoras. In later exercises (winged truss) you will seethat it is possible almost to dispense with trigonometry and use the TUBEcommand to go from XYZ point to XYZ point.

This model is a useful exercise in:• Using Trigonometry to determine lengths and angles• FOR... NEXT loops• 2D script writing• Using 2D image to display information• Defining text styles

!LATTICE TRUSS!3D Script

!---- THE PROGRAM ---------GOSUB 100 !check parameters

ROTy -LeanangGOSUB 200 !Upper elementsGOSUB 300 !Bottom tubeGOSUB 400 !Diagonal tubes DEL 1 !undo Lean angle

END !-------------------

100: !parameter set up!or put into Master Script

RESOL 8MATERIAL tmatlPEN tpentrad =tdiam/2 !tube radiusdtang =ATN((tmod*sqr(2)/2)/tdep)dtlen =tdep/cos(dtang)RETURN

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 71: Cookbook3_1

1.57

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

200: The Upper longitudinal tubes are easy enough : a matter of gettingto the right position, and pumping out a CYLIND. However, note thatone steps backwards by one tube radius, and makes the tube a tiny bitlonger to give the impression of a butt end to the tube. The same is donefor the bottom member.

The FOR...NEXT Loop is needed to generate the lateral tubes. By us-ing a loop, you can use the number of modules as a counter to decidehow many to draw. Notice in this example, that we use K as a counter inthe loop and also as a way of calculating how far the cursor travels be-fore generating the cylinder. For the first tube, it moves ‘tmod*(k-1)’ whichis, effectively, zero. When it gets to the 4th tube, it is moving ‘tmod*(4-1)’which gets it to the right place. Using this method, you can do the DELcommand INSIDE the FOR... NEXT loop, which is much tidier.

300: Bottom member of the truss is very easy. One long Cylinder, slightlyelongated to improve the junction detail.

400: The Diagonals – well, the routine to draw the 4 diagonal tubes is abit complicated, so it uses subroutine 450 for each truss module, so thatthe main FOR...NEXT loop looks tidier.

450: Rotate 45º then issue 4 leaning-over cylinders rotating 90º each time.At the end, put DEL 4+1 instead of 5. It reminds you not to forget theROTz 45 with which you started drawing the tubes.

200: !Truss upper element !Longitudinal

ADD -tmod/2-trad,-tmod/2,tdep ROTy 90CYLIND tmod*tnum+tdiam,trad ADDy tmodCYLIND tmod*tnum+tdiam,trad DEL 3

!Truss upper tube – LateralFOR k = 1 TO tnum+1 ADD -tmod/2,-tmod/2,tdep ROTx -90 ADDx tmod*(k-1)CYLIND tmod,trad DEL 3 NEXT kRETURN

300: !Bottom boom ROTy 90 ADDz -trad !slightly longerCYLIND tmod*(tnum-1)+tdiam,trad DEL 2RETURN

400: !Diagonal Truss elementFOR k = 1 TO tnum ADDx tmod*(k-1) GOSUB 450 DEL 1 NEXT kRETURN

450: !Diagonals ROTz 45: !first tube angleFOR n=1 to 4 ROTx dtang CYLIND dtlen,trad DEL 1 ROTz 90NEXT n DEL 4+1RETURN

!2D Script

IF Leanang THEN PROJECT2 3,270,2

ELSE !if Truss is Flat

LET w2 = tmod/2!Top and bottom lengthstenx= tmod*tnum-tmod/2benx= tmod*(tnum-1)!--------------------------RECT2 -w2,w2, tenx,-w2FOR k=1 to tnum ADD2 tmod*(k-1),0 LINE2 -w2,-w2,w2, w2 LINE2 -w2, w2,w2,-w2 LINE2 w2, w2,w2,-w2 DEL 1NEXT k LINE2 0,0, benx,0!--------------------------HOTSPOT2 0,0HOTSPOT2 benx,0!--------------------------IF shodata THENDEFINE STYLE "display" "geneva", fhigt,1,0 STYLE "display" TEXT2 0,w2,"span" TEXT2 0,0 ,tmod*(tnum-1) ENDIF

2D ScriptIt is important to have a good 2D script, as the Project2 command willtake too long to display, with all those cylinders.

If you wish to tilt the truss so that it’s a leanto or a Column, the 2Dscript would not work, so you need to use Project2.

The 2D script here takes the same parameters as the 3D script, worksout a few locations of the nodes, and draws quick lines and rectangles todraw the truss in plan. It also plants Hotspots in the right places.

Finally, you might like to try getting the 2D symbol to give you infor-mation. In this case, the span of the truss. For this, you need to define atext style – the size of the text is parametric. This 2D display ability couldbe used to print out structural or weight data. It is also useful in circularobjects in displaying Radius or span.

The truss can also be used as a Walling element. A way to make thetruss draw very quickly in the project plan is to ‘encapsulate’ your Truss:make your parametrically defined truss a library object AGAIN, so that ithas a standard object symbol – providing you have no further intentionof changing it. You can use this method to make an entire PORTAL.

Scripted 2D symbol if the truss is flat Use PROJECT2 if the truss is tilted Truss as a wall element

Notice tubularends to trusslongitudinal

members

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 72: Cookbook3_1

1.58

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Lattice Portal – using Lattice Truss

This model is an exercise in:

• Finding ways to speed up your plan drawing

• Encapsulating : Making Library objects of library objects

• Using the Elevation/Section window to get the model right

Relax! There is no GDL coding in this exercise.

The Plan – Using three library objects, and showing section A/1.

Section A/1 – Lift the truss into position on the columns.

I N THE Lattice Truss exercise,you had a choice of scripting the 2D as

a Project2 command, or as a script. If theTruss is used as a column or a slopingbeam, the Project2 command has to beused, which will take a long time to re-draw.

A way to make the Truss draw ex-tremely quickly in the project plan is toencapsulate your Truss: make yourparametrically defined truss a library ob-ject AGAIN, so that it has a standard ob-ject symbol – providing you have no fur-ther intention of changing it. Here is themeans of doing this.

ProcedureHere is a single truss with 5 modules of1.2 metres, supported by two columns of3 modules each (3.6 metres high) Laythem in the plan, so that they relate cor-rectly in plan.

Plant a section line just in front of thetruss to give you a view of the Portal, thenview the section.

The columns and the beam elementsstart off on the floor. Use the section win-dow to lift the beam to the correct height.

Set up a 3D view, with the camera at270º and the view set to Plan (Top View),When you have a 3D view, you can savethe result as a new Library Object.

Alternatively, just select the three items in the Project Plan window, and use“File: Save Special: ArchiCAD object” to save as a library object.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 73: Cookbook3_1

1.59

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

When you save the library object,make sure it is saved as an ob-ject, and not (accidentally) as awindow or door.

I recommend saving inEditable form, as you can look atthe script and made tiny modifi-cations to certain parameters likematerials or pen colour withouthaving to remake the whole por-tal. Otherwise, it could be savedas a Binary object, in which nofurther editing is possible, andthis is sometimes a necessary pre-caution against certain bugs inArchiCAD which spuriously re-ports rendering errors withEditable objects, but not with Bi-nary.

Raised Computer Flooring Tool

Raised computer flooring is a genuinely usefulobject – by arranging small stretchy rectanglesof floortool, you can adapt to complex roomshapes.

ParametersFor this the only parameters that really matterare the total width and length dimension, thepanel size and floor height. However, you canmake the object more user friendly by adding inoptions, such as to leave out the panels. You alsocontrol the Materials. When you have more thanone material in an object, you need to have themspecified in the parameter box. When you haveone (such as the pen colour here) there is noneed for this, as the user can control it from otherparts of the Library part settings box.

The dimensioning system here is in millimetres, although, note,that the GDL script is ALWAYS written in Metres, or if you wishto write in imperial, with inch or foot markers (as in 2’-0”)

THIS is a classic example of stretchiness resulting in a useful tool. Itis done with Nested FOR... NEXT Loops. This object also reminds

you of the usefulness of using VALUE scripts and a Master Script.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 74: Cookbook3_1

1.60

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

!Raised Office Flooring!2D Script

!PROJECT2 3,270,2

HOTSPOT2 0,0HOTSPOT2 A,0HOTSPOT2 A,BHOTSPOT2 0,B

!CrosshairLINE2 A,B+panth,A,B-panthLINE2 A+panth,B,A-panth,B

!LegsFOR n=0 TO B+pansiz STEP pansiz ADD2 0,nFOR k=0 TO A+pansiz STEP pansiz ADD2 k,0 CIRCLE2 0,0,0.03:!Floor leg DEL 1 NEXT k DEL 1 NEXT n

!PanelsIF d3d=2 THENFOR n=0 TO B STEP pansiz ADD2 0,n FOR k=0 TO A STEP pansiz ADD2 k,0 RECT2 0,0,pansiz,pansiz DEL 1 NEXT k DEL 1 NEXT n ENDIF

The fully written 2D scriptrewards the time youhave invested because itspeeds up Redraw in theProject plan.

!Raised Flooring System - 3D

!LegsFOR n=0 TO B+pansiz STEP pansiz ADDy n FOR k=0 TO A+pansiz STEP pansiz ADDx k GOSUB 100:!Floor leg DEL 1 NEXT k DEL 1 NEXT n

!PanelsIF d3d=2 THENFOR n=0 TO B STEP pansiz ADDy n FOR k=0 TO A STEP pansiz ADDx k GOSUB 120:!Panel DEL 1 NEXT k DEL 1 NEXT n ENDIF

!GridIF d3d AND NOT(simple) THENMATERIAL lmatADDz florhit-panthFOR n=0 TO B+pansiz STEP pansiz ADDy n BLOCK numpana*pansiz,jonth,panth DEL 1 NEXT nFOR k=0 TO A+pansiz STEP pansiz ADDx k BLOCK jonth,numpanb*pansiz,panth DEL 1 NEXT k DEL 1 ENDIF

END:!----------------------------

100:!Floor legMATERIAL lmat RESOL 8 CYLIND 0.01,0.04 CYLIND florhit-panth,lgrad ADDz florhit-panth-0.01 CYLIND 0.01,0.04 DEL 1RETURN

120:!Panelpsiz=pansiz-jonthMATERIAL pmat ADD jonth/2,jonth/2,florhit-0.02 BLOCK psiz,psiz,0.02 DEL 1RETURN

2D ScriptYou could use just a Project2, and the four primaryhotspots (bounding boxhotspots will not be stretchy).It is also helpful to write asmall ‘Crosshair’ routine to tellthe user where the A,BHotspot is located. You canmimic the structure of the 3Dscript.

3D ScriptFOR... NEXT Loops can bebased on distance, angleor number. Here you cando it with distance, al-though to get it to workusefully, it is best to makethe panelling extend be-yond the A and B dimen-sions; hence the final di-mension is (A+pansiz), notA. If the panelling stayedwithin the AB dimensions,the active hotspot thatmakes it stretchy wouldget lost in walls or overother areas of floor.

Stretchy hotspotis marked by across hair

VALUES "disply" "Whole floor", "Panels removed", "Supports only"

!Master Script - feeds parameters!to both 2D and 3D scripts

IF disply="Whole floor" THEN d3d=2IF disply="Panels removed" THEN d3d=1IF disply="Supports only" THEN d3d=0

numpana=INT(A/pansiz)+1 numpanb=INT(B/pansiz)+1 panth=0.02 !Panel thickness jonth=0.01 !Joint thickness lgrad=0.02 !Leg Radius

Value list in the Parameter ScriptAvoid putting titles or comments into theValue script as they can behave erratically.Value Lists are best used for strings (‘abc’),even though numbers are possible.

Master Script is the best way to ‘parse’ aValues list script and convertthe results into numbers. In-ternal parameters such aspanel thickness (ones you donot want the user to change)can also be here. Masterscripts should not exceed10k in size or Value Lists donot work correctly (bug).

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 75: Cookbook3_1

1.61

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Louvre SunbreakerTHIS IS SIMILAR in some way to the Joist tool or the

Computer flooring, in that it is stretchy and uses aFOR... NEXT Loop; but this operates as a mechanism. Onecan rotate the louvres, tilt the assembly and change the cur-vature of the blades. This could be used ona building whichused mechanised louvres to respond to the sun path.

ParametersTwo of the parameters are based on a Value List, for Louvreshape and for the design of the surround. The shape couldbe based on asking for a Radius, but it is more user friendlyto offer a Value List selection. Group the parameters undertwo main headings and indent all of them so you finish upwith a tidy settings box.

3D ScriptFirst the Value Lists are parsed to calculate some internalflags and parameters. Then Tilt and Pen. The louvres arelaid out using a FOR... NEXT Loop, and the hard work isdone by a short subroutine 100. By using a bPRISM, andmaking the radius variable, you can in effect get flat lou-vres.

VALUES 'fram' 'No Frame','Arms only', 'Frame surround'VALUES 'louvc' 'Flat','Slightly curved', 'Very Curved'

Because the louvresare flattish, you aresafer with TOLER forcurvature control,and 1mm seems bestin this case.

!Louvre wizard!3D Script

IF fram='No Frame' THEN frm=0IF fram='Arms only' THEN frm=1IF fram='Frame surround' THEN frm=2IF frm=0 THEN lwid=AIF frm THEN lwid=A-frwid*2-lthk

IF louvc='Flat' THEN radc=lspac*100IF louvc='Slightly curved' THEN radc=lspac*2IF louvc='Very Curved' THEN radc=lspac/1.5

!tilt if requiredROTx tiltPEN pcolTOLER 0.002

!Draw the Louvre AssemblyMATERIAL lmatADDy lspac/2FOR k=1 TO numlv ADDy lspac*(k-1) GOSUB 100:!Louvre DEL 1 NEXT kDEL 1

!Draw the Frame!first the ArmsIF frm THENMATERIAL frmat ADDz -frdep/2BLOCK frwid,lspac*(numlv),frdep ADDx A-frwidBLOCK frwid,lspac*(numlv),frdep DEL 2ENDIF

!Draw frameIF frm=2 THENMATERIAL frmat ADDy lspac*numlv ADDz -frdep/2 BLOCK A,frwid,frdep DEL 2

ENDIF

DEL 1 !Undo tiltEND!-------------------------------

This varies the curvatureof the louvres

This loop is based onnumber, incrementing

by distance

The frame might betterbe done with a PRISM,but I am trying to keep

things simple !2D Script

HOTSPOT2 0,0HOTSPOT2 A,0PROJECT2 3,270,2

Final settingsbox can beVERY neatand tidy!

!------SUBROUTINES -----

100: !Louvre curvedIF frm THEN ADDx frwid+lthk/2 ENDIFROTz -90ROTy 90+langADDz -lthk/2bPRISM_ lmat,lmat,lmat, 4,lthk,radc, -ldep/2,0, 15, ldep/2,0, 15, ldep/2,lwid,15, -ldep/2,lwid,15DEL 3IF frm THEN DEL 1RETURN

2D ScriptYou could script this if it was alwaysto remain level, but as it might tilt,you can use Project2.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 76: Cookbook3_1

1.62

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Comment, Preview and LabelsTHE Comment field is a good way to docu-

ment your object so that a user has a guide as to itspurpose or to how it functions. If you are building in-vestment objects (where you won’t be around to ex-plain), the comment box is like a tiny manual – or acopyright notice. Place a Web address in there and ob-jects may enable users to refer to a website (in futureversions of ArchiCAD.)

It has a wierd word-wrap mode, so you are best justto write it without carriage returns, and let it work outthe wrap itself. It cannot scroll, so you cannot writemuch.

THE Preview Picture – is used to show what the object should looklike. You can place a picture from the clipboard straight into the Preview

Picture Window – this could be one you made earlier with Artlantis. Every-thing you do should be equipped with a Preview image. Preview images canalso be used in the User Interface dialogs (with AC_6.5). If you use a PC, yourPreview image will become your icon in Windows. In the GDL Browser win-dow, the Preview image is the main means of identifying the object.

LABELS – Every Wall, Roof, Floor andLibrary Object has a label assigned to it by

ArchiCAD. This is difficult to write into (althoughyou can do). It is possible for each object in theplan to be displaying its label.

Tips and TricksRendering

Anti Aliasing: For quick on-screen rendering, alwaysturn off shadows and lamps. Both require greater

amounts of disk and ram and time. Avoid anti-aliasing, oranything that will slow it down.

However, for quality rendering, first thing to restore isanti-aliasing. This ‘softens’ the pixels, that that thin or smallobjects are still drawn, whereas without anti-aliasing, theywould judder between being drawn and being omitted.Hence they would look jagged. ‘Anti-aliasing’ means thatit looks at the surrounding pixels and does a controlledblur, in which the colour of surrounding pixels are takeninto account to produce a softer image – for example theoutline of a roof against a blue sky.

Higher levels of anti aliasing slow it down, but producebetter results. For each pixel of the final image, four pixelswill be calculated, and the final pixel will be averaged –for example a thin vertical glazing bar that is normallysmaller than a single pixel would now show. This results in4 times as much rendering time.

As a rule of thumb, ‘Good’ anti-aliasing does not causeserious slowdowns in rendering, but ‘Better’ and ‘Best’ candelay rendering quite seriously. So use ‘Good’ most of thetime.

Anti aliasing procedures are improved in AC-6.5, witha slider to control quality (but only if in AC’s own render-ing engine, and set to Best quality.

Textures versus 3D: Textures are always quicker topaint than geometrically modelled surfaces to build. For

example, a tree model could have thousands of polygons ifleaves are geometrically modelled. However, a lollipopshape with a dome or sphere shaped leaf ball, and an al-pha-channelled image of leaves mapped onto the ball willlook almost as good and reduce the polygon count to lessthan a hundred.

DPI and Resolution: Computer monitors work at72dpi (dots per inch), and if you want to see how an

image is progressing always use 72dpi – no matter whatthe final image size will be. If your image is to be printed,do not be tempted to enter any other figure in the Photo-rendering settings box. Stay with 72, but make the numberof pixels in the image larger. For example, if you want toprint an A3 landscape image, that is 17”x11” (420x297mm)with a final resolution of 200 dpi multiply 17x200=3400and 11x200=2200. Set the size of the ArchiCAD Render to3400x2200 at 72 dpi. It doesnt matter that this is biggerthan your screen.

When it is done, quit ArchiCAD, open the file withPhotoshop, Graphic Converter or PhotoPro, and you canresize the image to 17”x11” with 200dpi. You can also con-vert it to JPEG at varying levels of quality – always use‘maximum’ if the artwork has to be presented. You can alsoscale the same file down to 340x220 GIF or lower qualityjpegs for Web page presentation.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 77: Cookbook3_1

1.63

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Planar 3D Elements

PLANAR 3D elements are very usefulbecause they only generate two poly-

gons, 1 top, 1 bottom; when it comes torendering speed, the ‘polygon count’ of amodel is all important (because AC has tocalculate the line outlines and the shad-ing values for each polygon.)

CIRCLE, POLY, PLANE and RECT all ap-pear in renderings – but LIN_ disappears.

Whenever you would normally use aPRISM or a CYLIND, stop to think whetherthe same job can be done with a PLANEor a POLY or a CIRCLE.

CIRCLE is simply defined by its radius.Use it instead of thin cylinders.

LIN_ draws a straight line in 3D from oneXYZ location to another; but only showsup in 3D views with Best contours.

ARC draws a curved line sector shape.The rotation angle goes in an anti clock-wise direction starting from horizontal.Here, the start angle is 45 degrees, and itfinishes with 100degrees – anti clockwise.

Example of POLY – a simpleoutline with straight edges.

Example of POLY_ – an outline withthe opportunity for curved & straightedges and drilled holes (round orpolygonal).

POLY the syntax is identical to that ofPRISM, without a thickness. No holes orcurved edges or masking codes are per-mitted. POLY must always be laid on theX-Y plane, so if you want a poly in an oddplace and angle, you have to move thecursor there first.

POLY_ (Poly underscore) is similar toPrism underscore – it supports holes andcurved edges. With prisms, masks go from0 to 15, but with POLY_ you only need toknow if the line is to be drawn or omitted– so one or zero is enough. In addition,by adding 1000 or other polylines, you getcurved lines or holes. As a bit of adven-ture, I have shown you an example of ahole drilled in the Poly – this is similar tothe procedure for holes in PRISM.

!POLY Demo!Syntax:- POLY number,! x1,y1, x2,y2, etcPOLY 9, 0.00,0.00, -0.10,0.30, 0.10,0.30, 0.10,0.40, 0.20,0.40, 0.20,0.10, 0.15,0.10, 0.15,0.00, 0.00,0.00

!POLY_ Demo w’ hole!Syntax:- POLY_ number,! x1,y1,mask,! x2,y2,mask, etcPOLY_ 9+2, 0.00,0.00,1, -0.10,0.30,1, 0.10,0.30,0, 0.10,0.40,1, 0.20,0.40,1, 0.20,0.10,1001, 0.15,0.10,0, 0.15,0.00,1, 0.00,0.00,-1,0.05,0.1,900, !Hole centre0.05,360,4000 !Hole drawn

!Two-D elements!Syntax:- CIRCLE radius!ARC radius, startangl,endangl!LIN_ x1,y1,z1, x2,y2,z2!RECT x,y

CIRCLE 0.2ARC 0.3,45,100LIN_ 0.00,0.00,0.00, -0.15,-0.15,0.15 ADDz -0.2RECT 0.3,0.3

URL in the Comment fieldIt doesn’t do anything now, but in future ver-sions you might be able to benefit by placinga URL (web address) in the Comment field ofyour object.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 78: Cookbook3_1

1.64

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

More 3D ElementsSLABSLAB is very similar to PRISM, but far moreflexible. You only need to define the XYZpoints of the nodes – like PLANE. As withPrism, you define a thickness, but depend-ing on the pitch, this is really a vertical heightquantity, not thickness.

Plain SLAB and SLAB_ are all one colour.The XYZ points are actually the points onthe lower surface unless you specify a Nega-tive Height.

One problem with SLAB is that you needto be sure that the surface will be planar – orit may not render properly. It does not checkfor you. Also, if the pitch gets too steep, theridge and eaves detail get very distorted.

SLAB retains its sides perpendicular to theground, or to the current XY plane – makingit ideal for ramps, roof slabs etc. It is goodbecause you do not have to move the cursorto its location, or Rotate the XY plane, as youdo with a Prism.

SLAB_SLAB_ is similar, but you can control theedges in 3D drawings. (However, all theedges in the illustration here still get shownin photo render.)

SLAB_ does not appear to support the drill-ing of holes – you have to use CROOF, orPRISM_. SLABs do not support PolyLines.

With SLAB_, you can control thedisplay of edges and edgelines, aswith Prisms.

!SLAB Demonstration!Syntax:- SLAB n,h,! x1,y1,z1,! ....xn,yn,zn

SLAB 4,0.2, 0.0,0.0,0, 0.8,0.0,0, 0.8,1.5,1, 0.0,1.5,1

!SLAB_ Demonstration!Syntax:- SLAB_ n,h,! x1,y1,z1,mask1,! ....xn,yn,zn,maskn

SLAB_ 4,0.2, 0.0,0.0,0,15, 0.8,0.0,0, 0, 0.8,1.5,1, 8, 0.0,1.5,1,15

PLANE is most useful, as you can specifyXYZ locations of any points in 3D space andGDL will endeavour to join them up with asurface.

With three points, you can do anythinganywhere.

With more than 3, you must ensure thatthe surface will be planar. If they are not pla-nar, the whole surface may appear as empty.

PLANE_ (Plane underscore) allows you todecide if edge lines are to be drawn or not.

Imported 3D DXF files often getconverted to a large number ofPLANEs when read in by GDL.

!PLANE Demonstration!Syntax:- PLANE number,! x1,y1,z1,! x2,y2,z2,! x3,y3,z3, etc..PLANE 3, 0.20,-0.4,-0.2,-0.20, 0.3, 0.1, 0.25, 0.4, 0.1

PLANE_ 4, -0.3,0.0,-0.20,0, 0.3,0.0,-0.20,1, 0.3,0.2,-0.05,1, -0.3,0.2,-0.05,1

More Planar 3D

See your cursor!

One tip that I often use myself is to plant asmall object whereever the cursor is sup-

posed to be. If you have a little one liner ELLIPS0.04,0.01, you can copy and paste it as you workthrough the script. Put it in places where things

aren’t working out right. It plants a little bullet like object showingposition and orientation.

In 2D scripting, you don’t even get the 3 pointed star that you get in3D, so you are in the dark. You can plant a CIRCLE2 0,0,0.02 always infront of you as you push out the script.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 79: Cookbook3_1

1.65

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

CSLAB_CSLAB_ is SLAB_ with the ability to set differ-ent materials for top, bottom and edge surfaces.CSLABs are what you get when you make anautoscripted library part using hipped roofs. TheMaterials can be defined by name, or by indexnumber, or with variables.

This is analogous to cPRISM. Because of theway it handles the edges, and because you donot have to lift or rotate the cursor into position,the SLAB family can be more useful than Prism.

Standard LampSteal-poly, Revolve, Light

THIS exercise teaches 4 ideas:• The stealing of a Poly from ArchiCAD• Making it into a REVOLVE• Making a Lamp with LIGHT• Using a flag

Procedure: First, find the origin of the Project Plan window, drawa FILL object to trace the outline of the lathing pattern for the stand-

ard lamp. Make sure it is on or ABOVE the origin. Start from the centreof the base of the lamp.

Now open a New Library Object – a ‘Lamp’, and open the 2D Scriptwindow, position it next to the Project Plan window. The trick is toopen the 2D window by clicking on the little white button, not themain grey button on the button bar – so it’s a floating window.

Now simply grab the edge and D-r-a-g the Fill from the Project planto the 2D Script window – Hey presto! Instant GDL!

!cSLAB_ Demonstration!Syntax:- CSLAB_ topm,botm,sidm,! n, h,! x1,y1,z1,mask1,! ....xn,yn,zn,maskn

CSLAB_ "Gold","Zinc","Ice", 4, 0.2, 0.0,0.0,0,15, 0.8,0.0,0,15, 0.8,1.5,1,15, 0.0,1.5,1,15

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 80: Cookbook3_1

1.66

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Picture Objects - Alpha channelsThis model is a very important exercise in:• The PICTURE command• Using Photoshop to make the alpha channel• Creating the basic library object that can

use any 32bit PICT or TIF file• Rotating the object to face the camera• Using photorendering for the finish

THE example used here is a bit of fun; I assure you thatthere is no montaging done – it’s rendered in ArchiCAD.

The serious uses are as follows:

• People in buildings – populate models with photorealistic figures.

• Put pictures of trees onto flat planes, don’t model them in 3D.

• Pictures and decoration on walls give interiors more realism.

• Attach facades of buildings in urban models to avoid having to modelthem geometrically – rapidly create urban surroundings for your build-ing.

Batman visited Thailand entirely free of 3Dgeometrical entities!This Picture Object provides you with a surface towhich you attach an image. It is not the same asa texture. Textures tile themselves, and may havea random origin. An Image is a single entity.

!Standard Lamp!2D Script

HOTSPOT2 0,0!PROJECT2 3,270,2CIRCLE2 0,0,0.03CIRCLE2 0,0,0.15CIRCLE2 0,0,0.25CIRCLE2 0,0,0.30 FOR k=1 TO 2+C*4 ROT2 (360/(2+C*4))*k LINE2 0.03,0,0.3,0 HOTSPOT2 0.3,0 DEL 1 NEXT k

!Standard Lamp 3D Script

MULz zzyzx/1.55ROTy -90MATERIAL stmatlRESOL 16REVOLVE 21,360, 63, 0.0, 0.159792, 1, 0.019831, 0.159792, 1, 0.019297, 0.144624, 1, 0.027216, 0.142644, 1, 0.043055, 0.093148, 1, 0.052954, 0.027813, 1, 0.062854, 0.027813, 1, 0.064833, 0.037712, 1, 0.088592, 0.06147, 1, 0.11037, 0.06543, 1, 0.136108, 0.06543, 1, 0.7756, 0.029793, 1, 0.7756, 0.039692, 1, 0.785499, 0.049591, 1, 0.799358, 0.049591, 1, 0.809257, 0.031773, 1, 1.16167, 0.047612, 1, 1.179489, 0.041672, 1, 1.189388, 0.015934, 1, 1.227005, 0.015934, 1, 1.228985, 0.000095, 1

!Lampshade

IF C THEN MATERIAL 'Lamp' ELSE MATERIAL 'Whitewash' ENDIFREVOLVE 2,360,0, 1.20,0.3,1, 1.55,0.25,1DEL 1

!BulbIF C THEN ADDz 1.3 RESOL 6 SPHERE 0.03 gb=G/100 !brightness index LIGHT gb*D,gb*E,gb*F,!R,G,B 0,0, !shad,rad 0,0,0,!alp,bet,angfall 0,gb*dist,(gb-1)^2!falloff DEL 1 ENDIF

Lampmakingroutine

Shaderoutine

verticalpost

routine

Standard Lamp, continued

3D Script: Now cut the whole text of the POLY2B that results, and pasteit into the 3D window. Delete the Hotspot commands that get dumped intothe script. In the 3D script, convert it into a REVOLVE, removing the firstand last X-Y point and reducing the number of points in the REVOLVE by 2.Notice, the syntax for the X and Y points in the Poly2B and Revolve arealmost the same – only the header is different. The main mask is 63, as usualfor solids.

Now you have got the standard pole, it’s relatively easy to make theshade – but here the main mask for the object will be zero. This will make ithollow with open top and bottom ends – an open cone, in effect. You canhave a small IF statement to change the material from ‘Lamp’ to ‘White-wash’ if the light is ON or OFF. You could add material parameters to theparameter box in case the person using your lamp is using a PortugueseArchiCAD and all the materials have different names.

The height of the lamp stand is made parametric by applying a MULcommand to the zzyzx parameter.

The Light: For simplicity, we are doing an ‘All round light’ (or generalbrightener. The LIGHT command starts with the Red/Green/Blue compo-nents, each of which is affected by the ‘intensity’ (G) followed by the pro-portions of the RGB components (D, E and F). See the way it is done hereand copy that. For a general light source, shadow, radius and the threeangles are zero. The distances are defined, and the brightness (intensity)governs the long distances and the fall off characteristic of the light. Place

the lamp on a surface, and experiment withPhotorendering to see how it performs.

2D Script: This is a series of Circles, but toindicate that the Lamp is on or off, you can havea loop to draw radiating lines. To save writing 2

loops, I have used C as aflag to decide whether todraw 2 or 6 lines, and theflag also calculates theangles between thelines.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 81: Cookbook3_1

1.67

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

ProcedureFirst catch your lion – or person, or plant, orbuilding facade – using a digital camera orscanner.

Cutaway the background using the magicwand and eraser. It must become totally white.Use the ‘Channels Palette’ to create a newchannel, which you can call the Alpha Chan-nel. You must operate in 32bit RGB colour(even if your screen only supports 16 or 8bitcolour). The Red, Green and Blue channelseach require 8bits (hence 24 bits for 16.7 mil-lion colours). The 8bits between 24 and 32hold the Alpha channel, which you have cre-ated. Select and ‘Cut’ the WHITE area in theRGB channel (using the magic wand). Clickon the alpha channel (cmd-4) and ‘Paste’ thesame area into the Alpha channel. With theWhite Area still selected, fill the selected areawith BLACK paint using the bucket tool.

Flatten any Layers, then Save the file as aPICT or TIFF with 32 bit colour, and avoid anyform of compression, or you will lose the Al-pha channel. For most Picture objects, 72 or100dpi is enough; avoid high resolution scans.

Important: Save the final image into your cur-rent Library, and Reload Libraries.

If you are intending to do this with build-ing elevations, a picture dpi of 60 dots/mworks well. This is a fair compromise betweensharpness of detail, rendering time, memoryusage, library size etc.

For this, you need Photoshop, or any art software that can handleAlpha Channels – which can be used by CAD software for specialfunctions like transparency or bump-mapping.

3D ScriptMasking: If the photo is a building facade, you may not want thealpha channel to be made invisible, so the ‘mask’ has to be a choice.The Mask modifier lets the user decide if the image is ‘see-through’or solid.

Size: There needs to be a rectangular frame and the photoshopimage will adapt to fit the size. The frame must be the same propor-tions or it will look distorted. A and B make the object stretchy.

Face Camera: Many 2D Objects such as people or trees look to-tally wrong if they don’t face the camera. It is vital to know how toturn the object round so it looks solid. You may not want this tohappen always – eg if it’s a picture on the wall, or a building facade;therefore the user has to have a choice in the matter. If the objecthas a rotation angle in the dialog box, it will never face the cameraproperly; so one workaround is to use 90+azi-W~ (W~ is the glo-bal for object’s rotation angle.) If you have a rotated grid (in AC6)then this will not work correctly.

!Master Script!Location Awareness Check

dkx=K~-X~:IF dkx=0 THEN dkx=0.001dly=L~-Y~dmz=M~-Z~

dd=SQR(dkx^2+dly^2+dmz^2)!Distanceazi=ATN(dly/dkx) !Azimuth

!Three-D Script

width=A: height=BIF facecam THEN ROTz (90+azi-W~) ROTx 90 ADDx -width/2MATERIAL backmatSHADOW OFFPICTURE pictmap,width,height,mask DEL TOP

A bit of trial and error was required to getthe rotation angle working perfectly.

ParametersThe parameter box needs to know the name of the Pictmap thatwill form a picture – and it is unhelpful – no popup menu helpsyou; you just have to know the name. If the picture file is not inthe library, you get very irritating error messages.Width (A) andHeight (B) will stretch the pictmap to fit. In the parameter box onPCs, you must leave out the 3-letter suffix in the parameter box.i.e. fat_man.tif must be entered as fat_man. On Macs, you mustput the suffix in!

Page 82: Cookbook3_1

1.68

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

2D ScriptYou can simply use PROJECT2, or you could use aLINE2 or RECT2 command. You should add Hotspotsif the Picture object is easy to pick and stretchy. (If youmake it stretchy, you could accidentally alter the rec-tangular proportions, and distort the image.)

I have introduced the idea of ‘Helpfulness” wherebyyou can project the object onto the floor for the user tostretch, using ‘B’. It also names the file. To use TEXT,you should always define the text style. The idea of‘px’ (an object pixel) is that it will work for very smallor very large objects.

In Helpful mode,the Picture objectappears to be laidflat on the groundfor easy re-sizing,and its name isdisplayed – eventhough it is stillstanding upright.

!ROTATING PICTURE MAP!2DScript

!PROJECT2 3,270,1 px=MIN(0.01,A/100)IF facecam THEN ROT2 (90+dazi-W~)+180 HOTSPOT2 A/2,0 HOTSPOT2 -A/2,0

HOTSPOT2 0,px CIRCLE2 0,0,px RECT2 -A/2,-px, A/2,px

IF helpful THEN RECT2 -A/2,0,A/2,B HOTSPOT2 A/2,B HOTSPOT2 -A/2,B

DEFINE STYLE "pictext" Arial,1,7,0 STYLE "pictext" TEXT2 -A/2,0,pictmap ENDIF

DEL TOP

Rendering picture objectsThe rendered object is light sensitive, so check yoursun angle relative to the camera position (or you cancreate misleading shading on the picture.)

If the image is not to be silhouetted or transparent,you do not need to worry about alpha channels, norabout 32bit colour – for example building facades orpictures on walls. You can save files as PICT or TIFF in8 or 12 bit colour, you can even use a modest level ofcompression. Make sure you reload Libraries after yousave the Photoshop file into a library. By the way, ifyou didn’t ‘Flatten the Layers’ in Photoshop, it may notrender.

Once you get the hang of this, you can build entiremodels out of just the picture object! You can buildwhole streetscapes from this.

One problem is that you will have difficulty copy-ing these items across to Artlantis Render – they mayfinish up looking like flat boards. But then there areways of bringing in Alpha channelled images intoArtlantis.

Another problem is that Alpha channelled silhouet-ted objects do not cast correct shadows. If SHADOWis on, you get just a rectangle(:-( so you might put aSHADOW OFF command into the script. For Graphisoftto write a Shadow algorithm that looked at the imagewould be difficult. But then if the Alpha channel isdesignated ‘transparent’ it should be made to work.

The Picture Objectlooks like this in 3Dviews. You shouldassign a Materiallike ‘Whitewash’ or‘Glass’ to make it lessobtrusive in 3Dviews.

The same 3D viewlooks like this whenrendered. As theimage could lookdistorted, you shouldoffer a choice to ‘Facethe Camera’.

See the Voyagercourse for adiscussion of ShadowCasting with AlphaChannels

If you want to map a picture on to a curved or rough surface,there is a method! See the Voyager course

Page 83: Cookbook3_1

1.69

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Cutplane/CutendCUTPLANE is one of my favourite com-mands. It is much easier to make something largerthan it needs to be and cut it down to size, thanto build it up in a positive method. The more com-plicated the object, the more useful CUTPLANEbecomes. Its greatest use comes when you needto form mitres at the end of extrusions. Withoutcutplane, it could not be done.

I only use and only teach one method, whichI call the Angle method. The other method, basedon Vectors is to difficult to use.

CUTPLANE can be likened to a large spinningbacon slicer. You move the slicer into position,rotate the blade to the right angle, issue the

CUTPLANE command; now you must use DELto get back to the origin. Next, build the modelthat needs cutting. If your model disappears, youmay have forgotten to DEL correctly.

CUTPLANE always cuts away what is aboveit, and leaves behind what is below. Some-times, you wish to do the opposite, and cut awayeverything below the ground plane. For this, it ishandy to spin the blade through 180 degrees witha ‘CUTPLANE 180’ command to leave behind eve-rything above the plane.

Remember to do thecorrect number of DELsbefore building theobject that is to be cut.

For other angles (i.e. not around Xaxis), you do the swivelling yourself withROT commands and issue aCUTPLANE.

ADDz 0.5CUTPLANE 45 DEL 1SPHERE 1CUTEND

ADDz 0.5CUTPLANE -45 DEL 1SPHERE 1CUTEND

ADDz 0.5 ROTy 45CUTPLANE DEL 2SPHERE 1CUTEND

ADDz 0.5 ROTy 45CUTPLANE 180 DEL 2SPHERE 1CUTEND

!CUTPLANE Demonstrat’n!Syntax: - CUTPLANE angle!After you’ve made the object!to be cut you issue a CUTEND! ADDz 0.5CUTPLANE DEL 1SPHERE 1CUTEND

This multi-coloured model of the worldcan only be made by CUTPLANE, but thereare so many Cuts that if you do the wholeworld in one go, you could need over100megs of RAM allocated to ArchiCAD.

CUTEND At the end of the cutting process, the CUTENDcommand is required to stop the blade spinning. If CUTENDis not stated, the Cutplane command will continue till theend of the object and you will get an Error report.

Some models use many Cuts, and for EVERY Cutplane,you must have the right number of CUTENDs. It is annoyingto GDL user that there is not some sort of CUT TOP com-mand that has a similar function to DEL TOP – i.e. it wouldstop all cutting, and if there were no cutplanes in action itwould not result in an error.

You can also do a CUTPOLY which is similar to a PRISM,but it’s cutting instead of building. See later in the book.

CUTPLANE needs to know the Material that you are using.If you do not issue a Material command before Cutplane, itwill leave the cut face to the current PEN colour, not to thematerial of the cut object.

Multi coloured models: You could issue a Material com-mand, issue a Cutplane, then issue another Material com-mand, issue another Cutplane... and so on. Then build theobject to be cut. In this way, you can get multi colouredmodels.

CUTPLANE uses a lot of memory, and if you issue a largenumber of them, the model rendering will slow down, oryou may even be told that ArchiCAD is out of memory.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 84: Cookbook3_1

1.70

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Tapering tube – with cutplane

THIS MODEL is a component in larger steel structures. It ishere because it is another example of :

• The CUTPLANE command, used at angles

• POLYLINES in a PRISM

CUTPLANE is used here to model the end ofthe main cylinder – there is no other way to getthat shape.It’s done by moving the cutting planeto each end, tilting to the right angle, Cutting,then DEL back to the origin. This must be donebefore you make the 3D elements.

3D ScriptYou must issue a Material definition BEFORE is-suing Cutplane, otherwise the cut face adoptsthe colour of the current PEN.

When you have done cutting, issue theCUTEND command, or the rest of the Libraryobject will also be cut. You can write simply,CUTEND:CUTEND:CUTEND:CUTEND as amultistatement line.

To economize on code here, the CUTPLANEis one single subroutine, and the script usesADD, ROT and MULs to do the fine positioningand tilting.

Flange: The Polyline in the flange is 1000, a tan-gential curve – the easiest one to use, with a 900,4000 for the hole. Careful masking (by subtract-ing 2) is used to removed redundant wirelineson the curves.

2D ScriptThis is a hingeing component of a larger steelstructure and could be any-which-way up, soyou have to script it in 2D as a Project2 com-mand. If you were building a large structure withthese, you could ‘encapsulate’ them once theywere assembled. The Hotspots are in the 3Dscript for locating the centre of the holes, butyou need the bounding box for generally locat-ing the tube.

!Tapering tube 2D ScriptPROJECT2 3,270,2!Rely on the 3D Hotspots to!pinpoint the hole centres

!Tapered Cylindrical spar - 3D Script

PEN pencolMATERIAL mat trad=tdiam/2 !tube radius traf=trad*0.95 !flange width slightly smaller clen=leng-tdiam!length of cylinder sectionIF cangl<0 OR cangl>90 THEN cangl=12.5TOLER 0.002 !2mm

!_____ THE PROGRAM ______ROTy yangl !global commandROTx xangl !to positionROTz zangl !rod

GOSUB 100 !Main tubeGOSUB 200 !Bottom flange ADDz clen+tdiam MULz -1GOSUB 200 !Top flange DEL TOP !return to origin

END:!------------------------

200: !End Flange ROTz 90 ROTx -90 ADDz -flanth/2HOTSPOT 0,0,flanth/2PRISM_ 6+2,flanth, -traf,-trad, 15, -traf, 0, 15-2, traf, 0, 1000+15-2, traf,-trad, 15, 0,-trad, 15-2, -traf,-trad, -1, 0,0,900, hdiam/2,360,4000+15-2 DEL 3RETURN

100: !main tube with cuts ADDz tradGOSUB 110 MULx -1GOSUB 110 DEL 1 !cut bottom

ADDz clen MULz -1GOSUB 110 MULx -1GOSUB 110 DEL 3 !cut topCYLIND clen,trad !draw tube

!cancel cutsCUTEND:CUTEND:CUTEND:CUTEND DEL 1RETURN

110: !Make the cut ADDx flanth/2 ROTy -(90-cangl) CUTPLANE 180 DEL 2RETURN

Don’t use Storey-0 for buildingStorey 0 always has to be at zero height, so if yourground floor is not at zero, start this on floor 1 withthe correct height. Use Storey-0 for the landscape orsiteplan.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 85: Cookbook3_1

1.71

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

The User Interface – part 1

FOR ArchiCAD 6.5 and 7.0 users, the mostnoticeable difference for users of Library

objects is the user interface (UI).

The usual box of parameters with the scroll bar stillexists, but it can now be organised into tidy groupingswith hierarchical menus, bold titles and line spaces.First, the selection of objects is made easier as the ob-ject browser displays icons for each object. Second, itis possible to build a custom user interface that does

away with the traditional parameter box altogether andmakes it possible to build objects that have the sort ofinterface you normally expect from a well written APIadd-on. You could also build a set of duplicate userinterface windows in different national languages.

Let’s go to the first of these improvements and lookat how to organise the parameters tidily. The object‘UI_Tester.gsm’ demonstrates most of the features ofthe new interface. It’s on your CD.

Now, let’s get rocking!AS you build each parameter, you have 2 new options– you can have a Title which will be in bold type, andyou can have an empty line (Separator) to give alinespace in the list of parameters.

You also have three new buttons to touch on; thefirst one, with a cross (as in ‘fontui’) means ‘hide it’, inthis case because it is ONLY to be used in the advancedUser Interface boxes. The second button with an ar-row means ‘indent the parameter name’, making theparameter hierarchically subservient to the nearest un-indented above it. The third button with a large ‘B’means ‘set parameter description to Bold’.

By organising the box so that the indented param-eters come under the Titles, you get triangular ‘rock-ing’ buttons, giving you ‘cascading parameters’ – youcan make a neat and tidy job, reduce the need for theuser to scroll down, and ensure that the parametersare logically grouped together – for example, 3D con-figuration, 2D symbol appearance.

It is worth noting that if you use zzyzx to denoteheight this should now be at the TOP of the parametertable and not in any hierarchical group. When the ob-ject is saved and then viewed through its settings box,the height becomes one of the Infields, along withwidth and depth.

There is no longer a Value List button – Value listsautomatically activate if they find a valid script in theParameter script. In the advanced UI, you can havePictorial Value lists.

It is possible to do away with the conventional pa-rameters box. Put all of the parameters into a User In-terface, make the UI appear first whenever the settingbox is opened. The user then has to choose to use theold parameter list, unless you choose to use the Hidebutton to hide them all!

Title and linespace are two new parameter types

These are the dialogs wehave been used to withearlier versions ofArchiCAD – now lookingdull by comparison withwhat is available with AC-6.5

This is theuser’sparameterbox all neatand tidyand foldedup.

This is theuser’sparameterbox with 2of thegroupsopened upready forinspectionand use.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 86: Cookbook3_1

1.72

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Compare ArchiCAD 6.5/7.0This page lists the main improvements in GDL brought in with the issue of ArchiCAD 6.5, comparedwith 6.0. Many 6.5 users still work with the 6.0 GDL manual. GDL in 7.0 is largely unchanged.

General• The Parameter building box is a lot easier to work

in as you do not have floating palettes all overlay-ing each other (although you can have them float-ing if you wish it that way.)

• Organising the Parameters box to be user friendly iseasier with the opportunity to have Bold font, titlelines, linefeeds, hidden parameters, lockable/unlockable parameters, and cascading parameters.

• Special characteristics of an object, window, lampand so on may now be found by clicking on a but-ton called Details (including ‘Hotspots on Bound-ing Box’)

• The GDL Debugger, is still too baffling and proneto ‘Internal VM error’ when it tries to draw things,so the END statement is still the best way of puttingbreakpoints into a script.

• Copy from Mac to PC without making .PLA Archives.

3D scripting• HOTSPOT – to remove the annoying tendency of

2D hotspots, when seen in the 3D window to beanywhere but where you want them! But you can-not see the 3D Hotspots in GDL’s 3D view, only inthe Main model’s 3D view.

• Extension of XWALL to allow Log building.

• BEAM – has a syntax similar to XWALL, i.e. a lotmore difficult to use than BLOCK or PRISM. But youcan vary the materials of the faces. For creative pro-gramming one is likely to continue using cPRISM_.But BEAM will be the new standard for Autoscriptedobjects which have been constructed with the newBeamtool. The Beamtool has new and clever waysof revealing intersections with others and allowingthemselves to be drilled (like Walls) or cutting slabs.In the autoscripts, these are done with CUTPOLYs.The Beamtool has many links to the ArchiCADmodel through a host of new Global Variables forthe purposes of listing, but it remains to be seenhow the GDL writer can use this creatively.

• SET SECT_FILL – this will satisfy one of the big-gest wishes on ArchiCAD talk, of how to control theappearance (fill pattern) of objects when cut in theSection window.

2D scripting• HOTSPOT2 – can be followed by an ‘identifier ID’

code. Useful if the 2D view is changing in a com-plex way.

• DRAWINDEX – defines the order in which 2D el-ements are drawn.

Properties• DATABASE_SET – if this command is placed in

the MASTER.GDL file, it will define a database setcontaining Descriptor, Component, Unit, Key, Cri-teria and List Scheme files. Along with the fact thatAC_6.5 includes a special manual for the Calculatemenu, this command, and what goes with it mustgo some way to make the whole matter of Proper-ties easier to use.

Parameters and Values• VALUES – the command is extended in power. If

the user wants a choice that is not in the list, theCUSTOM keyword makes that possible. In addition,the RANGE keyword means that the user can entera value falling within a range of values. VALUEScommands are now written in the Parameter Script.

• PARAMETERS – enables one to feed the objectand the settings box with predetermined parametervalues if the user makes a certain choice – rather asthe CALL command sends a list of parameter valuesto a Called object. For example, it can redefine anddisplay the new values of A and B. If, in a Car model,you select ‘MiniHatchback’ from a Value List of cars,it can set A to 3.1 metres, B to 1.6 metres and zzyzxto 1.4. If you select Limousine, it can change themto A=6.0, B=2.1, and zzyzx=1.6. Previously, if achange of object configuration was likely to resultin the outer dimensions changing, one could notuse A and B.

• LOCK – This enables the script to lock out param-eters which are not available as a result of a deci-sion – e.g. if the user of a smart chair object selectsthe model without arms, the parameters relating tochair arm height and material will be greyed out.The parameter name must be in quotes.

• USER INTERFACE Script – the GDL writer canbuild a whole new series of dialog boxes with im-ages, buttons, and boxes which the user can fill in.In particular, Pictorial Value Lists can be built whichadd 100% more user friendliness than before.

The UI is a profound improvement. The UserInterface (UI) brings GDL closer to API capabilities,and of course will greatly strengthen anybody whohas the will to program in API and GDL combined.

If the User Interface Script is enabled, the user will see anextra button in the settings box, like this.

Page 87: Cookbook3_1

1.73

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

THIS EXERCISE is an exam-ple of ‘tinkering’ with exist-

ing Library Objects.

Students are always asking me foran easy way to rotate objects in theplan (around the X-axis).

One of the slickest things you cando is to put a ROTx in front of anobject and make it stand upright, orfit to a sloping site or floor.

There are many objects in the ex-isting libraries that are not usable onsloping sites, or in unusual uses. Forexample the ArchiCAD and the Peo-ple and More cars all stand horizon-tally, and look quite silly on a slop-ing carpark or driveway. A simple ROTx or ROTy canmake all the difference, even to Binary objects. Forthese, the command ROTx 90 or ROTx -90 or ROTxrotang at the start of the script can work wonders to anexisting library object. Whatever you do by thismethod, do not forget to make the minor essentialchange to the 2D script, or you will not see the changeexcept in 3D views.

You can make shapes in Plan such as laying out atruss using the slab tool, save them as Library objects,and then ROTx them to the angle you want – this iseasier than setting up the views in elevation if the an-gle is anything other than 90. Use ROTy if you want tolean objects in the other direction.

The Mesh Tool will not allow you to make complexshapes with undercutting. However, if you prepareMeshtool surfaces on the level, put them into GDL (bydragging into a 3D script window) and then add someROTx and ROTy commands, you can manouvre thesurfaces to the right position, and join several togetherto make very complex objects. This is one of the tech-niques used in my Motorist Car object.

The Magic of ROTxHow to rotate objects in plan

!2D Script!ArchiCAD Car!Alternative Script

IF rx<>0 OR ry<>0 THEN PROJECT2 3,270,2 ELSE FRAGMENT2 ALL,1 ENDIF

!3D Script!ArchiCAD Car!Modified Script

ROTx rxROTy ry

MULx A/4.538808MULy B/1.809472Binary 1

2D ScriptOne important thing to note is that the 2D view of theobject in the plan could be quite different as a result ofyour ROTx, so if you have made the angle a new pa-rameter, use a script like the one above. If a rotationhas been specified, the script forces a Project2 com-mand to take place. If not, then it will use the existingsymbol – this can be invoked with the Fragment2 com-mand, or you could use a conventionally scripted 2Dsymbol.

CUTPOLY, CUTSHAPE andWALLHOLEAC 5.1, AC 6.x and AC 7.0 provide additional Cuttingcommands which enhance the opportunities in 3D.

With CUTPOLY, you can define a convex polygo-nal hole shape using a syntax similar to PRISM, andthen drive it through the whole model, like the ac-tion of a ‘Cookie cutter’!!

CUTPOLYA and WALLHOLE are improvements onCUTPOLY that allow Polylines. WALLHOLE acts onlyon Walls, so you have to imagine its effect when you

are in GDL. You do not see the result until you do a3D View of the main ArchiCAD model.

The requirement to be convex is a real pain. Manyholes in the 3D real world do not conform to this.Complex holes or edge cuttings have to be done by alot of CUTPOLYs or CUTPOLYAs , all declared beforethe cut part of the model is built. Let’s hope that therewill be a CUTPOLYB before long allowing complexhole-shapes.

Examples of CUTPOLY and CUTPOLYA appearin exercises in the Voyager sections.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 88: Cookbook3_1

1.74

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

!CircleGrid - 2D Script

IF fan<10 THEN fan=10IF fan>360 THEN fan=360 ang=fan/numangHOTSPOT2 0,0LINE_TYPE lindot

!Draw the actual gridFOR k=0 TO fan+0.001 STEP ang ROT2 k LINE2 0,0, lrad,0 ARC2 0,0,rhotm,-4,4 ARC2 0,0,rhot,-3,3 HOTSPOT2 rhot,0 HOTSPOT2 rhotm,0 DEL 1 NEXT k

!Show angular increment as TextIF shodat AND fontz THENDEFINE STYLE 'angtext' 'Arial',fontz,1,0SET STYLE 'angtext'angstr=STR(numang,3,0)+'@'+STR('%6.3dd',ang)TEXT2 rhotm,0,angstrENDIF

Shadows in section/elevationTry turning on the ‘Special’ menu (using ‘regedit’ on PC or‘resedit’ on Mac, or the Alt-Control key at start up). Thereis a FANTASTIC option to turn vectorial hatching on in yoursections/elevations thus eliminating the need to tediouslyhatch them up manually.

CircleGrid – 2D

GDL can be useful in creating 2D entities thathelp you to lay out models or drawings, but

which do not have any 3D existence – I call them draft-ing aids – Dimensions, Grids and parametric furnituremodules for example.

CircleGrid is a simple example. It also illustratesthe usefulness of the FOR...NEXT Loop used with an-gles, instead of distance or number.

ParametersYou define your own requirements. In this CircleGrid– that was written in earnest for a project and not justfor the exercise, there was a main circle and a minorone. Hotspots at each point allow one to drop objectsaccurately into position. The grid does not trace a fullcircle, so a sweep angle is specified. The text blockallows one to know how much rotation to give the ob-jects, and the inner circle gives secondary hotspotswhich make it easier to rotate the objects to line upwith the radiating lines. The object is not stretchy, so Aand B are not used.

2D ScriptFirstly, title your script, even a 2D one. ‘Ang’ definesthe angular separation of each line in the grid. Place aHotspot at the Centre – so you can pick it up. Decide ifyou want it made of solid or dotted lines.

• A FOR...NEXT loop is used for the main routine.Rotating around the centre, each line consists of a LINE2command, followed by ARC2 commands which placeshort lines to display the circle, and then Hotspots atthe intersections. DEL the ROT2 command each timethe loop is used. The deliberate error of 1/1000 degreeis essential, or GDL makes tiny rounding down errorsand miscounts the number of lines to draw.

• When you ROT2 in 2D the positive direction of ro-tation is anti clockwise.

• If Text quality is important, it’s essential to DEFINESTYLE first. If the text element contains more than onepart, you have to construct it first, using something like‘angstr’ in which all parts are defined as strings joinedby plus signs. In this, you can concatenate ‘numang’(the number of angles) as an integer string, an @ sym-bol, and then, to print the degrees symbol, you canuse a ‘%dd’ method (see the manual to test this fur-ther). Try this and experiment with changing thenumber of digits to be displayed.

If either shodat or Font height is zero then the text willnot print. Text is a fixed size in mm.

ROT2 bad for your DWGs?Objects in drawings exported from AC65 or AC70 to DWGoften behave unexpectedly in the 2D symbol – because ROT2may cause problems. If you can use Trigonometry, you canoften avoid the use of ROT2. Unfortunately it is a lot moredifficult to think out. for example, use this in the Circlegrid:FOR k=0 TO fan+0.001 STEP ang LINE2 0,0,lrad*COS(k),lrad*SIN(k) ARC2 0,0,rhotm,k-4,k+4 !Avoids using ARC2 0,0,rhot,k-3,k+3 !ROT2 HOTSPOT2 rhot*COS(k),rhot*SIN(k) HOTSPOT2 rhotm*COS(k),rhotm*SIN(k)NEXT k

Use the routine(below) in the loopinstead of this one,if you want toavoid using ROT2

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 89: Cookbook3_1

1.75

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

IT is possible to give a certain amount of decision makingcapacity to the object. Use the CAR PARK BARRIER. The bar-

rier lifts and drops depending on the distance from the camera.Thus, if you fly or walk through the model, the barrier will ap-pear to be active.

The same algorithm can be applied to:

• 2D trees and human figures rotate to look full bodied to the camera• The density of branches & leaves on trees can vary.• People and car objects can simplify hugely when camera is far.• Lights come on in rooms, Televisions change their image.• Curved objects change their RESOL value to higher values when the

camera is near, and reduce to as little as three when it is far.• Complex objects like Planar fittings and Louvres decide not to draw.

It works with Sun Studies and Flythoughs; with ArchiCAD6.x, italso works with VR Panorama cameras. Doors and Windows canopen during an animation, but must do so based on framenumber. They do not work correctly with ‘location awareness’.

Distance or Time?: Other aspects of animation, such as windturbines whose blades turn, buildings stacking themselves up,cars moving, human figures moving, sea undulating, yachts heel-ing, Doors and Windows etc are better done by using the globalvariable N_ (GLOB_FRAME_NR frame number in the animation)to determine the action – which is equivalent to TIME.

The Location-aware routine uses Global Variables. ArchiCADtells GDL the Camera location and the Object’s own location. Bycomparing the distance differences in X, Y and Z (a simple sub-traction that works whichever sector the model or camera is in),you use a 3D Pythagoras calculation to reveal the real distancedd from camera. dkx is the difference between the GVs ‘K~’ and‘X~’ – the object and camera positions in the X direction. Thesame idea applied in the Y & Z direction generates dly and dmz.

An ArcTan (ATN) calculation reveals the Azimuth (or direc-tion) by dividing the X distance into the Y distance.

If there is no camera, e.g. in an axonometric or an elevation,you need a ‘get-out-clause’ to set a false distance from the cam-era. This is to avoid a ‘divide by zero’ error when calculating theazimuth. Thus the variable dkx is given a tiny value of 1 mm.

3D Script150: Subroutine 150 calculates the camera distance and returnsa value of the variable ‘rotarm’. It is possible to make the Carpark barrier lift slowly based on the number of metres distant. Ituses a number of IF statements to compare the actual distancewith the opening distance, then decides what angle the bar shouldbe at. It begins to raise the barrier when the user is twice thedistance away, and at the chosen distance, the arm is fully up.

THIS location awareness routine can be used again –keep it in your Scrapbook. I have done models where

EVERY GDL component was location aware to keep therendering time under control.

Azimuth is a difficult calculation. Because objects could be inpositive and negative quadrants, this calculation could result ininversion. There is an interesting and complicated procedure for100% accurate azimuth which will have to go on another page.

Location-aware Capability

Rebuild each FrameThis routine will work for still views with dif-ferent camera distances. To ensure that thisworks during a movie flythrough, you need aREBUILD EACH FRAME to happen duringanimation. In AC6, this can be enabled in thedialog box just prior to starting a Flythrough.

In AC5, this is only possible by enablingthe ‘Special Menu’.(see Voyager course)

I was told by a member of Graphisoft that‘Rebuild Each Frame’ was added to AC6 as aresult of my lobbying them to do it. If so, thenThankyou Graphisoft!

Parameters: Offer a Boolean choice,autoarmang, to activate Location awareness,and opdis for an operating distance.

The user must define the point at whichthe object opens or changes. Here, the bar-rier will lift when the camera is less than 10metres away.

150: !Check distance/angle dkx=K~ - X~:IF dkx=0 THEN dkx=0.001 dly=L~ - Y~ dmz=M~ - Z~

dr =SQR(dkx^2 + dly^2) !Plan distancedd =SQR(dkx^2 +dly^2 +dmz^2)!Distanceazi=ATN(dly/dkx) !Azimuth

LET rotarm=90 IF dd<opdis*2 THEN rotarm=45 IF dd<opdis THEN rotarm=0 IF dd>opdis*2 THEN rotarm=90 RETURN

The eye positions K~, L~, & M~ can also be calledGLOB_EYEPOS_X, Y & Z, and the Object positionsX~, Y~ & Z~ can be called SYMB_POS_X, Y & Z.

Add thissubroutineto the Carpark barrierto automatethe value of‘rotarm’

These are examples of the actionsthat might result, once you know thedistance

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 90: Cookbook3_1

1.76

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

!People outlines - Master Script

!Location Awareness Checkdkx=K~-X~:IF dkx=0 THEN dkx=0.001dly=L~-Y~azi=ATN(dly/dkx) !Azimuth

VALUES "type" "1 Femme", "2 Homme", "3 Famille", "4 Couple", "5 Homme 2"

This location awareness routine omits the Z factor (unlessyou want your people to lean over backwards when thecamera is above eye level!)The Value list could be in the Parameter script or in theMaster script

!People outlines - 3D Script

PEN pcolMATERIAL matln = SPLIT (type, "%n", nbre, reste)IF x_loc THEN ROTz (90+azi-SYMB_ROTANGLE) !W~ ROTX 90 GOSUB 100+nbre:!Make corresponding shapeDEL TOPEND !-------------------------

101 : !Femme et chienPOLY_ 334, 0.023074, 0.31415, 1, 0.029777, 0.302984, 1, 0.036477, 0.291072, 1, 0.038707, 0.279906, 1, 0.038024, 0.266892, 1,!etc, etc. etc.!Hundreds of lines of the polys for all the!people shapes follow. Each one starts!with the line number according to their!order in the Value list, i.e. 101, 102,!103, 104, 105.RETURN

This shows you how to organise the Executive portion ofthe script. Put all the POLY_s into subroutines.

!People outlines - 2D

!People - 2DPEN pcol

PROJECT2 3,270,1

IF x_loc THEN ROT2 (90+azi-SYMB_ROTANGLE) !W~HOTSPOT2 0,0CIRCLE2 0,0,0.25LINE2 -0.25,0, 0.25,0

IF labl THEN ROT2 180 !Flip the lettering round DEFINE STYLE "STYLE_1" "Arial",2,5,0 SET STYLE "STYLE_1" TEXT2 0,0,type DEL 1 ENDIF

People – outlines which face camera

THIS little object comes from Geoffroy Magnan ofBelgium. It’s a useful little ‘People-object’ derived

from my original Lioness Picture object. He has offeredit back to me, as a technique to write up for the GDLCookbook. It can also be used for shrubs/landscape.

You can make your own figures easily. Scan somepeople or objects from photographs or magazines. Donot worry about Alpha Channels. Copy the scan fromyour scan software, paste it into ArchiCAD and place iton the origin. Resize the figure until it is the correctsize for the people in the image.

Using the Fill tool, draw the outline patiently aroundthe figures. Do not do it too quickly, or two single clickswill be misinterpreted as a double click (closing theoutline prematurely). In this case, 5 distinct outlineshave been created. Open a new Library part, open the2D script window (floating) and drag the outlines intothe 2D.

Idea and GDL from Geoffroy Magnan, article by DNC

!This arrives in the 2D scriptPEN 1SET FILL "% 50"POLY2_B 6, 3, 2, 91, 0.0, 0.0, 1, -3.386397, -0.390738, 1, -3.82055, 1.519537, 1, -0.955137, 1.345876, 1, 0.607815, 9.768452, 1, 0.0, 0.0, -1HOTSPOT2 0.0, 0.0HOTSPOT2 -3.386397, -0.390738HOTSPOT2 -3.82055, 1.519537HOTSPOT2 -0.955137, 1.345876HOTSPOT2 0.607815, 9.768452HOTSPOT2 0.0, 0.0

!Simplify it to this and copy to 3D scriptPOLY_ 6, 0.0, 0.0, 1, -3.386397, -0.390738, 1, -3.82055, 1.519537, 1, -0.955137, 1.345876, 1, 0.607815, 9.768452, 1, 0.0, 0.0, -1The syntax of the two POLYs is so similar, you only haveto modify the top line.

End noteYour finished people will only be flat 3D cutouts. How-ever, if you: take the scans and cut out the backgrounds;convert background to alpha channels; define figuresas textures; master COOR and VERT (in Voyager)... youcan accurately plant the photographs onto the peopleoutlines. Do this with trees and you can get them tocast realistic shadows. Two articles in Voyager (‘Castshadows with alpha channels’) take this further.

Adding the label ensures that youare getting the right variety of peoplein your scene. The Line helps you to

know if the people are rotatingcorrectly.

Page 91: Cookbook3_1

1.77

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Binary HackingWhen you don’t have the time for codeSlices and Dice: Re-invent!!

The 'Binary hack' can be distilled intothree related processesSTEP 1: Diagonal DistortionThis is circular geometry stretched into a elliptical ge-ometry with binary conversion. It makes things moregraceful. When you have approximated the curvedform you seek with conventional ArchiCAD tools [in-cluding objects made with ArchiForma or parametricGDL code], visualize the direction of displacement re-quired. This might be a broad rotation, wild scalar dis-tortion or merely a minor deviation. Time to play.

1: Save the component [viewed in the 3D window] asa binary object, rotated somewhat diagonally fromyour view azimuth. This adds a lateral displacementfactor to the regular geometry of the object. Whenstretched, the object distorts obliquely in the hori-zontal plane. [Spheres become ellipsoidal]. The ob-ject is controlled separately in the vertical plane.

If you need an elliptical ‘swoop’, or wish to flatten aradius slightly, reduce that scale component. To em-phasize tilt, wildly exaggerate vertical size. Straightedges cannot be distorted; you can rely on straight partsto remain so.

STEP 2: Slicing and DicingThe 3D cutting planes and 3D cutaway functions trimthe object in any direction. The special ‘Use sectiontool in 3D’ command1, Marquee tool and 3D Cutawaydeliver precise vertical trimming cuts.

2: Cut the distorted object up into components to mir-ror, stretch and save diagonally again. The relationalintegrity of the object remains; the object stays use-ful: hotspots can be linked to key points fordimensioning. [Sections through the distorted ob-ject must be exploded into line segments to buildreal life form work for casting].

There’s use for GDL here, as the materials should becontrolled at the end of the binary script. Substituting‘0,0’ for ‘1,1’ will allow standard material changes, oth-erwise the object ignores the object material definition.

1 See article on ‘Special Menu’ in Voyager

Binary hacking is visual: lay the piece down, stretchit, mash it, cut it. It is creative and instructive because itshows surprising transformations. Binary hacks allowform refinement in a more sculptural way than cod-ing, or even accurate design. You could discover some-thing exciting in the distorted form. As an object isstretched and re-scaled, the inherent ‘family of order’in the piece is revealed. Once made binary an objector a group of objects saved as one binary object act asa block of infinitely stretchy and twisty plastic.

FROM time to time, a shape can’t be created fromregular geometry, or what is needed can’t be ex-

actly predicted or designed. ‘Binary hacking’ exploresthe implications of shape within ArchiCAD. This messy,experimental technique results in form that respondsto notion and feeling more than science. Many of theresults obtained with binary hacking can be achievedwith GDL commands like MUL and CUTPOLY, but notwith any degree of intuition.

The translucent wings at Kelowna Airport:Twisting and radical re-scaling of a binary wingelement. See permutations.

Machina Metronoma: Chopped the top arc into agraceful form. Stretched and re-scaled vertically.(Inset, photo of the finished structure, as built.)

by DwightAtkinsonMAIBC

Page 92: Cookbook3_1

1.78

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

STEP 3: Re-saving the IterationEach change should be saved in sequence. Pasting‘Dwight’s Universal Rotator’ script into the evolving bi-nary object simplifies future transformation (make thertx, rty, rtz parameters too). These orientation trans-formations accompany vertical and horizontaldisplacements to evolve the next iteration of yoursculpted piece. You can save your object in the samename as the previous (current one) unless you need tokeep a backup of a previous stage.

Some ObservationsSymmetrical objects can be given a directional bias.Cut the object in half, save as a new binary object, puttwo together, stretch one, squish the other.

If you want perfect symmetry, cut your starting ob-ject in half and flip a copy of the resultant trimmedpiece. By trimming the object only where the surfaceangle is perpendicular to the cutting plane, no seamwill show when you mirror for symmetry.

Try – it’s Fun!

The Shadocaster: A series of trimmed roof planessaved binary diagonally, twisted and then radicallyscaled: used to indicate the various shadows cast indifferent configurations.

Sphere: Transform it to a surfboard

Metronoma: Tops in process (above) Shadocaster: Permutations

Wings:Permutations

Note: The only way you can save a binary GSM is to view it in the 3Dwindow first. Once made, the binary code is embedded in the GSM, so youhave to add the ROT commands above the 3D script.

Page 93: Cookbook3_1

1.79

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

ParametersIn this Exercise, the seat and back are fixed sizes, and parameters Aand B are ignored. You can swivel the chair in the project plan win-dow, so it is not worth making the chair swivelable by the user. Notethat this parameter box is set out in Millimetres. If you are in the USA,you might have to set it in feet and inches!!

3D ScriptThis is a highly modular, structured program, in which the entirechair is analysed into essential elements – and each element is solvedin an independent subroutine. No matter how humble your ob-ject, try to apply this structured approach.

Write in the subroutines, empty at first. The subroutines called inthe executive script will build up the chair methodically, physicalelement by physical element. However, if you try to run this scriptbefore the subroutines have been written, you will get a ‘Subroutinenot found’ error. So you could write in some dummy routines, just toavoid an error. Then gradually, you fill in the details.

For curvature, we are using TOLER which gives good results whenmixing items of large and small curvature.

Swivel ChairTHIS CHAIR is the ultimate 3D

object of the Discovery Course.It is a very important exercise in:

• Some of the more easy and usefulGDL commands – CONE, PRISM_,CYLIND

• Some of the more difficult but use-ful GDL commands – bPRISM, TUBE

• More advanced GDL techniques –CUTPLANE, Polylines

• Making the subroutines modularand using DEL rigorously

Making the leg and the feet

300: To make the leg, you need to make onefoot first, and when it is working correctly,repeat it around the centre. Because there are5 feet, you rotate them by 72 degs each. Eachfoot is complicated because each one has itsown set of Cutplane commands, so make it asubroutine 350.

350: Each foot is to be cut 3 times, once forthe top surface, and two mitring cuts wherethe feet meet. Declare the Material before theCuts. (In reality, you would not need to mitrethe feet because the cylinder of the leg cov-ered the joint, but it’s a very good learningexercise with CUTPLANE and FOR… NEXT.)

With PRISM_ (underscore) you can form acurved end to the toe. First make the PRISM_as a square ended object, ready to mitre. Thenchange the end to a curve by changing 13 to1013. Now go back and insert the cutting rou-tines.

Note: If you are doing this on a Lift Off course, you have atutor available to help. Parts of this exercise march boldlyinto Voyager territory, so if you are teaching yourself, do nottry it until you have tried easier tasks first!

!Swivel Chair - 3D script

SHADOW ONPEN inkTOLER 0.002

GOSUB 300:!Foot of chairGOSUB 400:!Vertical shaftGOSUB 500:!SeatGOSUB 600:!BackEND:!-------------------------

300:!Foot of chairRETURN

400:!Vertical shaftRETURN

500:!SeatRETURN

600:!BackRETURN

Create the Dummysubroutines to avoidan error – you can fillthem in later...

300:!Foot of chairMATERIAL mmat ADDz 0.05FOR j=1 TO 5 ROTz (j-1)*72 GOSUB 350 DEL 1 NEXT j DEL 1RETURN

350: !Toe of FootMATERIAL mmat ADDz 0.05 ROTy 8CUTPLANE !Top of toe DEL 2!Mitre Feet ROTy -90: ROTx -(90-36):CUTPLANE DEL 1

ROTx +(90-36)CUTPLANE DEL 1+1

!still part of 350!Foot shapePRISM_ 5, 0.05, 0 , 0.04,13, 0.2, 0.02,13, 0.2,-0.02,1013, 0 ,-0.04,13, 0 , 0.04,-1

CUTEND:CUTEND:CUTEND

ADD 0.2,0,-0.05

!'Toe - little coneMATERIAL dmatCONE 0.05,0.03,0.01, 90,90 DEL 1RETURN

Page 94: Cookbook3_1

1.80

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

350 continued: To give the foot more realism, the end is curved –using the 1000 polyline definition.

Hot Tip for Polylines: The 1000 must come at the node after thesurface which you wish to have curved, but the change of 15 to 13must come at the node before you wish to have a smooth curve. 13removes the visible vertical lines.

Next, insert the CUTPLANE routine above the Prism forming thefoot. You should attempt the routine 350 which mitres the foot cor-rectly. You need 3 cuts altogether to make the foot into the correctshape. The mitring angle to achieve a spacing of 72˚ is 36˚ (half of 72˚).Just as in picture framing, you cut wood to a mitre of 45º to achieve ajoint of 90º. Every CUTPLANE has to be followed by a CUTEND.

Finally, The conical ‘toe’ is added as part of each foot. This could bea castor wheel, but requires more ROTs and ADDs.

Back to 300: Finally (if you haven’t already done this) having got 350working, you return to subroutine 300: and spin the feet to producefive, using a FOR... NEXT Loop.

Levels of DetailYou and only you can decide what level of detail and quality to displayin your models. If you did not bother to mitre the toes, it would not benoticed, and it is done here only to teach you the use of CUTPLANE.The next section, the vertical shaft, would entirely hide the centre junc-tion.

400: When the foot is perfect, block out the foot subroutine with a !sign, and work on the shaft.

The shaft can be done with a couple of CYLIND commands. Thenmanoevre the cursor to produce the adjusting knob. The heights ofeach part are calculated by working back from the seat heights andthickness.

500: The Seat uses the BPRISM_ command – but to make things moreinteresting, it also uses Polylines in the definitions. Enter the seat atfirst as an octagonal shape so that everything ends in 15, then experi-ment with the 1015 definition until you get it right. The 1015 shouldcome AFTER the line which you wish to be curved. Change the 15’s to13, and the vertical lines will be concealed. This speeds up drawing in3D.

When you first make the BPRISM_, it comes out upside down, butthe MULz -1 reverses it vertically, so it finishes up the correct way up.By the way, you can enter a minus figure as the depth of the BPRISM.This is to get a tighter radius of curvature.

Here the top surface has been trimmeddown

Here, the centre point has been mitredHere is the basic toe element beforecutting

400: !vertical shaft ADDz 0.10MATERIAL dmat CYLIND sht-0.25-sth,0.03MATERIAL mmat CYLIND sht-0.1-sth,0.02MATERIAL dmat ADD 0.04,0, sht-0.25-sth-0.05 ROTy 90CYLIND 0.02,0.04 !knob DEL 3RETURN

The five toes combined into a foot

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 95: Cookbook3_1

1.81

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

500: !Seat ADDz sht MULz -1GOSUB 550 !get the seat DEL 2RETURN

550: !Seat or BackBPRISM_ smat,dmat,smat, 5+4, sth, 0.8, -0.15,-0.20, 13, 0.15,-0.20, 13, 0.20,-0.15,1013, 0.20, 0.15, 13, 0.15, 0.20,1013, -0.15, 0.20, 13, -0.20, 0.15,1013, -0.20,-0.15, 13, -0.15,-0.20,1013RETURN

600: !Back supportMATERIAL mmat ADDz sht-sth ROTz 90TUBE 4,7,63,-0.03,+0.01, 0, 0.03,+0.01, 0,+0.03,-0.01, 0,-0.03,-0.01, 0,

-0.10,0, 0 ,0,-0.05,0, 0 ,0, 0.20,0, 0 ,0, 0.23,0,0.02,0, 0.25,0,0.05,0, 0.28,0,0.30,0, 0.28,0,0.40,0

MATERIAL dmat ADD 0.29,0,0.25 ROTy 90+6!Adjusting knobCYLIND 0.02,0.04 ADDz -0.08 ROTz 90!Back is Seat,but smaller MUL 0.8,0.8,1.0GOSUB 550 !Back or seat DEL 1+6RETURN

The seat shape is contained in sub-routine 550 because it gets calledagain later to do service as the back.To get the BPRISM to be curvy, youneed to use TOLER, as the best re-sult of RADIUS is still too rough,RESOL is too smooth. Experimentwith TOLER. Here, 2 mm gives agood result for both the seat curveand the curved edge.

600: The Seat back support is using the very difficult TUBE command.Type it in and then try changing the locations to see how it responds.Look it up in Voyager.

The Back Panel: The Back is the same bPRISM as the seat, but reducedin dimension a bit each way, using the MUL command. You can MULx,MULy or MULz, but if you just MUL, you can do all three directions in asingle command.

TUBE - a dip into the deep endTUBE is a good way to get a continuous section moving through 3D space.Once TUBE is mastered it is one of the most useful commands – and a loteasier to use.

With TUBE, you first define the cross sectional POLY shape that willtravel through 3D space. You draw it on the X-Y plane, as if you weredefining the outlines for a POLY2 command. Use a ‘masking value’ ofzero for each point. Next, you define the path that it must follow – theXYZ points along its trajectory. The trick with TUBE is that the FIRST andthe LAST location points along the tube are phantom points, there to tellGDL what angle to start mitring the first and last faces on the tube. Youmust remember to put a zero at the end of each path X-Y-Z location to tellit you want clean junctions – it is possible to twist the section and distortthe mitre by putting angle values in there.

If TUBE baffles you now, just type it in for now and enjoy looking at it.For later reference you will find more explanation and examples in theVoyager course.

2D ScriptFinally, you need a 2D view. Because the chair is quite complicated, a 2Dscript would make it display too slowly on the Project Plan. As the chair doesnot change in width or depth, and as it does not swivel, there is no need for aPROJECT2 command.

Give it a PROJECT2 command temporarily, look at the 2D Full View, SelectAll and Copy. Open the 2D Symbol Window, and Paste to Original Location.Now you either delete the whole 2D script and the 2D symbol will take over;or you can replace the Project2 command with: FRAGMENT2 ALL,1. You willget bounding box Hotspots.

Profile XY points

Pathway XYZ points,with twists of 0 at eachpoint.. You could workout these points bylooking at a sideelevation of the chair(with the back inposition but no tube)and clicking in thesection window alongthe lines of the tube.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 96: Cookbook3_1

1.82

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Libraries

LIBRARY organisation is the biggestthing you must get right. Know where

your library is, and what it is called, andhow to load it. Discard libraries that arenot relevant to your scheme. Use ‘LoadLibraries’ to sort it all out.• Avoid having duplicate libraries of thesame name on the same disk, or evenloaded in the project. You may havespent time improving a library object,only to see the old one come back nexttime, because you had the same object(the new and the old) in the same library,but in different folders.• When you move to a different compu-ter platform (Mac<->PC) or transportyour file on zip cartridge, you should saveas ARCHIVE (using the .PLA suffix) whichincludes all your library objects in theirright folders.• Archive does not copy across PICT andTIFF files (unless they are used as tex-tures), so these files may have to bemanually copied over. If you move com-puter but stay on one platform, the bestplace for your library is a sharedFileServer so it is available from everymachine, and where you cannot createduplicate libraries.

Tips and TricksGeneral Advice and warnings, all in one pageAs annually issued to my First year module at the University of Nottingham School of Architecture.

Building the Model

AS you build the model, a very disci-plined approach to using Layers, and

storeys will save you much time and grieflater. For example, you can hide the‘Roofs’ layer, which will reveal the inte-rior and let sunlight in. Or you can Hidethe ‘Window Tracery’ or ‘Trees’ layer,which is slowing down your render. Orhide ‘Lecture room chairs’ while yourender the exterior. Therefore, assignobjects to layers as early as possible.• If, when starting a model, you find re-ally wierd layer names, storey settings,dimensions, grid and materials (left thereby the previous user), use the ‘New andReset’ feature (by holding down ‘Alt’ keywhile you create a New file. This restoresthe usual default ArchiCAD settings.• Some people try to build multi storeyobjects or buildings all on the one sto-rey. ArchiCAD has the ability to workwith several stories. Bet you didn’t knowthat. (:-)• Set and Display a Ghost storey – makesit easier to trace the other storeys.

Making Library Objects

A little bit of GDL scripting – withCones, Cylinders, Blocks etc, will

produce more manageable library ob-jects than similar objects built withcurved Slabs.• Converting groups of built elementsto Library objects is a way of groupingthem. In 5.1 & 6.X, you have a Groupcommand, but making the group into aLibrary Object is more powerful, port-able and editable.• Look around before embarking oncomplex objects, as they may alreadyexist in the ArchiCAD or special objectslibrary. For example, the Roof>Dometool in ArchiCAD produces very clumsy,data heavy domes of many little roofswhich fall apart if touched; whereasthere is a nice little GDL Dome in theArchiCAD Library that is more paramet-ric and controllable.• If you script an object from scratch, itwill not have a 2D symbol unless youcreate a symbol. Use the PROJECT2command to view the object in 2D. Ifyou have the time, write a short para-metric script with CIRCLE2 and RECT2that imitates the Project 2 command;then delete the Project2 command. Ifthe object is not intended to be para-metric, use the button in the Library ob-ject window to copy a 3D view to Sym-bol – otherwise it will take too long toregen the Project Plan.• Curved tracery etc, is best done withcurved walls than with the slab tool. Youcan later control the curvature when itis saved as a Library object by insertingRESOL commands into the 3D script.• When you make library objects, givethem distinctive names, so that they areeasily found with the ‘Find and Select’command. If you call your object ‘Col-umn’ or ‘Cylinder’, you will probably findthat next time you open your file, youopen someone else’s library objectwhich is different but has the samename. Use names like ‘Column_ntc’which is unlikely to be confused withanother.• For objects which are not intended tobe stretchy, open the Library part, Sym-bol window, and put your own hotspotsin – in places where it is easier to pickthe object up.

Rendering

W HILE developing the model,ALWAYS have your 3D settings as

RASTER, not ANALYTIC, and contours asDRAFT. 3D windows also render quickerif they are smaller – there is no need forthem to be 1000 pixels wide.• Never select Vectorial Shadows or con-tours unless your machine is very fast.• Photorendering (with ambient lightand no shadows) is always faster thanAnalytic 3D drawing.• To see what a camera is looking at,you must first click on the camera andthen select 3D view. Dropping camerasinto the plan is quicker than tweakingthe perspective viewing tool in the 3DProjections window. Another techniquefor storing views is to use the Naviga-tion palette and ‘plant cameras’ whenyou see a view you like.• Putting a 'Marquee’ around the bit youare interested in will dramatically reducerendering times, and has the effect ofgiving you instant sections and details.Using the 'thick’ marquee will show allstories, the 'thin’ one only shows thecurrent storey.• Set your rendering window size thesame as the 3D view size (or make it thesame aspect ratio) – if not, you getstrange borders in your rendering.• You may spend too much time on col-oured renderings, and forget that Archi-CAD produces very good scale line draw-ings, in 2D and 3D – and that these canbe brought together in Plotmaker.• Top quality colour renderings are bestleft to Artlantis – quicker and higherquality. But in ArchiCAD you can still doa lot with light and shade and usePhotoshop filters like ‘water colour’ foradded effects. In ArchiCAD, you could trysome of the ‘fun’ rendering styles likeCarboni or Toon.• If you have done a LOT of work withtextures in ArchiCAD, avoid usingArtlantis as you may have to start overagain with texture positioning.• If you feel confined by the set of ma-terials in ArchiCAD, try making somenew ones – there are many spare tex-ture images for wood, stone and brickin the ArchiCAD library – with these, youcan make your own materials.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 97: Cookbook3_1

1.83

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Rules of good conduct and safe passage in GDL

• Number One! Always have paper, preferably a bound notebook(for looking back weeks later).

• Think about the investment potential of the object – or is it really a one off?• If it’s a one off, then dirty, brief coding may suffice.• If it’s an investment, you need to revisit, tidy, improve code, leave it for

others to finish: so write it well.The following remarks apply to ‘investment’ models. Read on.

Philosophy• You might make an object model that will be suit-

able for the immediate purpose – but is there anychance you can think of it as a Tool that could beused again?

• Are you making an object for others to use in theoffice, perhaps long after you have departed? Howmuch ‘idiot proofing’ do you need to build in?

• How ‘open’ is your code? Will others be able to re-pair it?

StructureSorry for repeating these points, but they need to bedrilled until they become second nature.• Structure the program rigorously – every physical

element of the model should be a subroutine.

• Use the Master script for calculation and prepara-tion work. This leaves the remaining scripts to fo-cus on their jobs without clutter.

• Subroutines must always return the Cursor to thesame location as where it started – so that any ele-ment of the model can be omitted without destroy-ing the remaining model. When you exit a subrou-tine, you get the 3D cursor to the same place byusing the correct number of DELs.

• Remember that a few well scripted super objects(that can be changed parametrically) are far moreefficient in use than a profusion of different but simi-lar objects.

Typography and Layout• Document the program clearly – use ! marks for

‘Comment’ statements; never forget to do this at thestart of all subroutines.

• At the start of the script, put the object name, thedate, and your name. Plus any further informationthat could be useful – all hidden behind commentmarkers (!).

• Be disciplined in your typographical layout. Alwaysuse UPPER case for COMMANDS and lower casefor variables and comments.

• Indent Cursor movements by at least two spacebartaps. Indent DELs and NEXTs. Indent the XYZ di-mensions in PRISMs and TUBEs. Line up commasin Prisms etc.

• Leave plenty of space (carriage returns) and rowsof ------------------’s between sections.

• GDL ignores carriage returns in almost all cases, sothat XYZ coordinates for prisms, tubes etc can bewritten on separate lines, providing you end eachline with a comma. This looks cleaner than trying towrite on one line.

Maths• Don’t be scared of maths problems – remember, you

only really need to know Pythagoras’ theorem andthe SOH-CAH-TOA rule of trigonometry.

• Use names for your parameter variables that makesense – like ‘length’, ‘width’, ‘spacing’ etc. Never usea command word, like ‘revolve’ or ‘prism’ or ‘del’ or‘log’ for a variable, or any word that might be usedin future versions of GDL – like ‘read’, ‘frame’ or‘wend’.1 Use single letter variables only for Loopcounters.

Development of the Script• As the script develops, keep putting ‘END’ after the

bit you have just done so you can keep track of the3D cursor location. Very early on, write an END state-ment so you can start making subroutines.

• Block off working part of the script when you de-bug parts which don’t work, by Commenting (!) sub-routines, or by putting in temporary ‘END’ or ‘GOTO’statements. A temporary END enables you to seewhere the cursor has got to.

• If you use global MUL, ROT or ADD statements, becareful not to DEL TOP during the program.

• Use temporary PRINT commands to see if the re-sults of calculations are correct.

1 Since I first wrote that in Cookbook 1, many of the words Isuggested came into use in 6.5 so I have had to think of somenew ‘unused’ words.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 98: Cookbook3_1

1.84

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Good scripting practice• Never use GOTO as part of the script unless abso-

lutely forced. IF... THEN... ENDIF or Subroutines arethe best way to avoid using GOTOs.

• Avoid multi-statement lines (separated by colons).like ADDz 0.1: ROTy 90. No economy is achievedby doing this. It is much more difficult to debug later.

• Use FOR... NEXT Loops to speed up repetitive mod-elling. Consider using REPEAT... UNTIL or DOWHILE... ENDWHILE which offers more flexibility.

• When you have to use a TUBE or REVOLVE orCOONS or similar, use a PUT routine first, to assem-ble the parameters in memory. It is easier to dumpthe XY locations (using GET(NSP)) into the TUBE ifyou have done all the arranging beforehand.

• Make frequent use of the swivelling 3D views inAC6.x to verify the shape of models.

• Don’t panic if you get error messages. There aresome bugs in GDL, but errors are 98 percent YOURfault, not the computer. A little bit of analysis or sim-plification of your script will reveal the error.

• If using objects first created with the wall/slab tool,make sure you make them on the main model’s Ori-gin in the ArchiCAD floor plan. Use ‘snap to grid’ toget clean looking scripts.

User Interface• Try to imagine how your ‘user’ will enter data. Write

the description of a parameter with the user in mind.Can the user understand what you are asking? Radiiare always best entered as Diameters and then con-verted in the script. Is the number you require a Di-mension, a ‘Real’ number or an Integer?

• Use a Value List whenever a choice is required. Thiscan reduce the risk of errors as it forces the user toenter valid data that doesn’t need error checking.

• Consider a Pictorial Value list, using the User Inter-face in ArchiCAD 6.5 onwards.

• If you wish to use a Boolean parameter, make sureyou frame it as an ON or OFF question. If the choicesfacing the user are more than two, use a Value list.

• Alway put a picture in the Preview window.

2D scripting• Use the PROJECT2 command if the model is chang-

ing in 3D so much that it cannot be scripted. If youare able to, use 2D scripting. Turn PROJECT2 on tomake sure your script is working. When it is work-ing correctly, turn PROJECT2 off.

• Scripting the 2D view for complex models will saveredraw time in the main floor plan, and reducesmodel size. It’s not difficult to do once you havemastered the art of 3D scripting.

• If the model is parametrically variable, the samestructure as you have in the 3D script can be fol-lowed. For example, use the same subroutine num-bers. If it’s exceedingly complex and parametricallyvariable, find out how to use FRAGMENT2, or scriptit fully in 2D.

• If possible, use EXTRUDE in 3D scripts instead ofPRISM as the parameters can be copied and pastedto the 2D script and easily changed to POLY2_.

• Stretchy objects (using Hotspots on A,B) are usefuland friendly to the user, and can reduce the numberof parameters that the user must fill in. StretchyHotspots must occur at the start of the 2D script orthe object will stretch but not shrink correctly.

• You can use TEXT2 to ensure that objects label them-selves correctly – although you need to DEFINESTYLE of text to do this well. If you autosize thefont height to fit the object, it will be free from plot-ting scale problems.

Quality ControlWHEN you have made an object or a library for others

to use, put it through a series of tests to ensure that itmeets good standards. If you wish to transfer an object or alibrary of objects to another user, the safest way is to do a‘Save Special’ from the File menu and save it as an Archive.If your object has macros and associated image files, youmay have to tick the option boxes to include all of the loadedlibraries. If this is so, ensure that the floor plan you are us-ing only contains the library that you wish to transfer. If youhappen to have the entire ArchiCAD library loaded at thetime, your archive file could exceed 100megabytes!!

Let’s assume that you have saved the floor plan correctlywith the library into an archive. Transfer it by floppy or zipor email to another machine preferably a Mac and then aPC, to make sure that the whole thing unpacks correctly onboth machines. The library objects should be saved in thecorrectly named folders and they should all show in thenewly created floor plan.• View the floor plan and check that they are all there.Perhaps you can write an instruction text file into the floor

plan on the use of the library. You could label each object,and put boxes round groups of compatible or matching ob-jects. Objects which have more than one 2D representationshould be placed enough times to show all the 2D views.• Check the ‘Missing Library Parts’ list to make sure thatyou haven’t lost any. Check that you haven’t included li-brary parts that you didn’t want included.• Check the settings of each object to reassure yourselfthat the parameter descriptions look right, are in the rightlanguage and that the 3D view displays correctly.• Check that all objects have an icon in the browser (ifnot, they need a Preview image).• Make sure you have saved each object with sensible de-fault values.• Delete ‘cache’ and other unwanted binary files like .gs&files. If your library objects have to work in listing, then runsome listings to check that they display correctly. Deletesection/elevation views from the floor plan.

If you are quite happy, you could re-archive the file andit is ready for sending to the recipient.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 99: Cookbook3_1

1.85

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Graeme Mair <[email protected]>

I have been using ArchiCAD since version 3.4. Over thattime I have made numerous objects some of which were

parametric (sash and case window with cill and angledingoes for example) but mostly one-offs using the wall andslab tools etc.

More recently as a result of reading the GDL book thatused to sell a few years back and as a result of your ownGDL Cookbook, I now produce objects for use by 7 otherpeople using ‘structured programming’ as advocated byyourself and have found this allows me to come back to anobject at a later date to modify and enhance it withouthaving major headaches for me trying to workout how Iput an object together. The other benefit of being ‘struc-tured’ is that I can add features to an object which alreadybe in use by others but not mess up the object for them.Some examples....- A Tree symbol with 3 versions of 3D object, 4 different2D symbols and in addition with or without 2D fill and treegrille.- 2D North symbol that rotates to match ArchiCAD Sunposition.- 3D column (based on ArchiCAD’s Cylinder_Distort ob-ject) Makes use of RESOL and POLY2_A to both create the3D and 2D symbol that has 6 variations of polygon shapesfrom triangular through to circular. The object can be viewedthrough stories by controlling a ‘height visible’ parameter.- A 2.5D Lift object with options to show activity space,Lift Shaft or just hotspots showing shaft position. This oneis still being developed because I want to have a option tochoose from BS lift sizes.- 3D Curved Kalzip roof which works out how many ribsit requires for a given overall size. The object can also tellyou what radius of curve has been created from the combi-nation of plan size and eaves to ridge height.- 2D parametric Car Space object with options of display-ing area required for disabled space requirement and showa car in the parking space.- 2D Car Elevations: this object uses 6 alpha channelledimages of elevatitions of cars that work in the section win-dow or in 3D model photorenderings.There are more but I had better stop now cos I’m going onto much! Thanks for all your efforts in promoting and en-couraging the GDL /ArchiCAD cause.

Chris Hough <[email protected]>

I have been using Archicad for over 4 years now, startingwith 4.5, and have made extensive use of GDL. At first,

I was using it to make 2D parametric library parts, such asdrawing titles where you could change the text by open-ing the dialog box. Then I moved to making parametricSheet Title blocks, some with company logos, some evenwith the Architect's seal on them. Again, they had editabletext, and would either resize to the scale of the drawing,or allow you to enter in a different scale if you wanted toplot at a scale other than that of the drawing. They alsoincluded a date stamp for automatically giving the datewhen plotted.

Lately, most of my current firm’s work is residential,and I have been making custom parametric 3D eaves tohandle edge conditions in the model. To facilitate the vir-tual building concept, I have used the masking feature tohide the joints between the edge of the roof and the edgeof the objects, to reduce clean up time when going from3D model to 2D lines. Of course, they are stretchable withcustom mitered edges, custom roof pitch for ‘swept eaves’,and one allows you to define multiple roof pitches forgabled conditions. I have also used the Revolve statementto make the same profile available in for curved roofs.

I have yet to sell any parts commercially, although I amthinking more and more of heading in that direction.

I've found the custom arched top windows and win-dow surround objects to be my current challenge, and prob-ably the most difficult parts I’ve made to date, mostly dueto the nature of the formulae needed to make them trulyparametric. I also trying to use Neil McCann’s techniquefor using CALL statements for a single ‘trim’ object to havemultiple profiles.

Evangelo B. Kalmantis <[email protected]>

I have been using ArchiCAD since 1991. Initially, I foundthe tools sufficient for most projects, but as I developed

my skills, I realized that I was becoming somewhat limitedby them. Within a year, I realized that there was an en-tirely new universe of modeling possibilities if I could onlytap into the power of GDL. Having no programming knowl-edge to speak of, this was a daring aspiration at the time.

To my surprise, I found GDL rather easy to learn, that is-at the basic level. The rewards far outweighed the effort,compelling me to delve deeper into it.

GDL Case Studies

Today, I have a personal library which is constantly evolv-ing and growing. It consists of vehicles, letter signage, guard-rails, exterior siding and panels, special doors, lab equip-ment, office equipment, modular furniture, religious ele-ments and ornaments, special geometric building blocks andclassical columns, all of which are parametric.

Without GDL, I would not have been able to create theseforms in ArchiCAD. I would highly recommend learning GDLto any ArchiCAD user at any level.

Duane Valencia <[email protected]>GDL is the most EFFICIENT way to achieve parametric ob-jects. If you want the power of what parametrics has tooffer, then you have to pay the price. And the price is re-ally time.

Ok, it's not what ARCHITECTs expect to do when theygo to work but then neither is attending a 2-day seminarabout FIRE DOORS, but if you want to know what's goingon, you have commit to a certain amount of "upfront"time.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 100: Cookbook3_1

1.86

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

From Conrado Dominguez <[email protected]>

First of all, the organization using ArchiCAD must becommitted to the use of AC 3D capabilities, otherwise

GDL is no use to them; in such a case, the use of AC will becomparable to using a power boat with oars.

In our case, we are half way committed. We use AC 3Dcapabilities in the initial stages (design evaluations, massmodels, selected views, etc.,). Very early in the game, werealized that AC cannot generate every 3D componentneeded for a realistic representation of any given project.

At that point, we begun a modest effort of creatingobjects with the use of slabs, walls and roofs. We still usethis technique because is it quick to implement and pro-ductive. However, these parts are not parametric and oncethe project is completed, they get forgotten and buried inthe Project Library, not to be reused again. We are a smalloffice (7 AC stations), so we have no formal training pro-cedures for training. When one of us discovers, or learns anew way to do things, we pass it along.

I regret being the only person interested in GDL. Why?I find it challenging. My first incursion into it, consisted ofback engineering some two dimensional symbols foundin the AC Library. I remember displaying the 2D script andexperimenting with the different code lines, introducingchanges to them and observing the effect of those changes.This was a very slow process but a good learning experi-ence.

Nevertheless, I realized that this method and using theGDL manual as a reference was painfully slow. When Itried to venture into 3D scripts it was a nightmare.

At this point, someone recommended the GDL Cook-book which I purchased and gave me a clear and me-thodical guideline to create scripted Library Parts. I con-fess that the learning curve was steep, at times frustrat-ing, but at the end very rewarding. The first challenge, inmy opinion, consists of identifying an object that will beextensively used in a project and possibly used in projectsto come. In my case I was able to identify some railingsthat we seem to use over and over again. The height andlength varies, the picket spacing and intermediate postsalways the same. Now, it is very satisfying to pick thisLibrary Part, insert it over and over in our plans (Balco-nies, exterior exit balconies, etc.), and ready drawn in Sec-tions and Elevations. The great thing about it is to realizethat with very little effort, more parameters could beadded, such as different base, size of pickets and pots,size of end, top and bottom rails, etc. SO MUCH TO LEARN,so little time!!.

From a management point of view (I am not part of ithere), it may be better to rely on outside help for customparts. From the user point of view (my own in this case)comes the satisfaction of learning the use of this tool andits final product, and to remember that whatever we learntravels with us no matter where we decide to go.

Light through wallsFrom: Drazen Slacanin <[email protected]>I am preparing a rendering of a house interior at night. Ionly want one room to have a light and leave the rest dark.However, the light seems to shine through the walls andlights up the neighboring rooms. I even tried to export themodel to Art*lantis 3.5 and the same occurs.

Is that an AC modeling error or did I miss something inthe setup menus (all the settings are at highest qualityand I have the boxes for casting shadows by sun and lightsckecked).From: "LMH DESIGN" <[email protected]>Glad to see that you are using Artlantis. There you havecomplete control over a) whether lights cast shadows ornot, and b) whether individual materials cast shadows ornot (in the materials list). Delete the 'sun' and fine-tunethe rest till it looks right.From: Drazen Slacanin <[email protected]>Playing around in Art*lantis with the lights is definitely away to solve my problem. However, after playing aroundwith different kinds of lights, I found out that the problemdoesn't exist with every type of light. Also, unchecking theambient light in the light-menu seems to help.

Tips and TricksMonitor and Card questionsFrom: Einer Mortensen <[email protected]>1. I am thinking of getting a Mitsubish Diamond Pro 2040w , does anyone have any experience with this monitor?2. Are there any other recomended monitors?3. What graphics card should I get?4 Do any cards improve the 3D performance of AC?From: "Laz" <[email protected]>The Mitsubishi monitors are good. The Sony, Phillips Pro-fessional and Apple 21" monitors are all good. Video cards?– Stick with Matrox Millenium. I believe Graphisoft bench-mark ArchiCAD on the Matrox cards. The G400 dual headis worth noting. they are good cards and later if you wantyou can attach a second monitor. ArchiCAD doesn't relythat much on 3D cards( i.e. you would be wasting yourmoney) - it needs raw processor speed. Get the fastest proc-essor you can afford and a Matrox card.

Case Studies: continued

Modules – another type of‘object’

If after all this, you still still don’t want to save or writethings as Library parts, you can always use Modules. Make

a Module by selecting your area of interest – a bathroomlayout perhaps, and either Filemenu/Save as Module, or justdrag it off the drawing onto the desktop, give it a nameand put it into a folder. Modules can be ‘hotlinked’ back toa project file. The advantage of modules is that you getback your original material, whereas a group such as a roomlayout are encapsulated if they are in a Library part andcannot be separated or reused. You can even open a mod-ule as if it were a project file.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 101: Cookbook3_1

1.87

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

Modify Library Objects

DRAW out a Slab in the Project plan,and then make the Slab into a li-

brary object, which you can now openand view. Now copy and paste the X,Ylocations to write a few mini scriptswhich do things like using the pointsfor a bPRISM command, or putting apattern of Hotspots into the 2D script,or locating a number of round columns/posts at the points on the slab.

IF YOU are on a course with tutors available, you should perhapswork in pairs, or have a seminar first to plan how you would set about

doing these. You should use paper to draw out your ideas. A bit of plan-ning will save you time during scripting. For example consider:• How can the model can be broken down into elements? – sketch it freehand.• Which 3D commands (in GDL) would best achieve the result?• Who is your ‘User’? – will you need to check input errors?• Where should the model’s origin be?• Can you take advantage of symmetry?• Are there hinging elements?• Does it want to be stretchy?• How parametric should the model really be?• What elements are repetitious and can be done with loops?• What maths or circle geometry problems are involved?• You are designers! Therefore, is your model well designed etc?If you are by yourself, this is a test to see how you thrive without thebenefit of a tutor to help you through – just the Cookbook and the Manual!

GDL Cookbook : Questions to ask yourself

External cycle or handrail bar

DECIDE whether is it all curvy tube,or two uprights and a handrail. If

it’s to be a smart object, give the userthe choice to make it either. If the raillength is bigger or smaller than the up-rights, will that change the junction de-tail? It must be a ‘stretchy object’ – con-forming to the dimension A; it could be2D scripted, to save drawing time. Canyou make it error-check to ensure thatas it stretches smaller, the curve radiuscan be modified?

Monopod Circular table

THIS circular table should be parametric in diameter and height. The leg

should look stable, so you may useCone or Revolve to form it (not Cylin-der). The table should perhaps have achamfered edge. Would you be able tomake it stretchy and non circular (ieoval?) Can you do a matching 2-D script?If so, the line of the central circular sup-port should be shown with a dotted line.

Desk Worktops

DESIGN an L-shaped desk worktopthat has a curved internal corner.

The sides of the L can either be 800mmor 600mm. Assume a constant thicknessof 30mm. The length should be 1200mmin one direction, and 1200, 1400, 1600or 1800 in the other. If you really wantto challenge, you can make it stretchyto those sizes. when you drop it into theProject plan at a height of 0.00, it shouldautomatically be at desktop height of760mm.

Hewi style door handle set

THIS uses tubes and cylinders, andcould be a subroutine of something

you might add to a door design – it couldbe CALLed. If it is to be called, reducethe parameters to the minimum – size isfixed, only colour is required.

Tempietto / Bandstand

USE Cylinders for the base andELLIPS for the dome; individual

columns should taper; think about away of making the column bases andcapitals, and use a FOR..NEXT Loop todistribute the columns. For the purposeof the test, make it parametric in height,number of steps and columns (and per-haps column fatness) and colours. Canyou make it stretchy? Can you also scriptit in 2D, so it draws quickly?

Do not bother with complex capitals– use a short CONE or no capital at all.Remember you need to find ways ofvarying the resolution of curved sur-faces.

Television/Monitor

MAKE a TV or monitor with a slightlybulging, not flat screen. Trick is to

use a very flat ELLIPS, then use 4CUTPLANES to cut it to the rectangle ofa TV. Then mount it into a PRISM withthe rectangular hole in it.

By inserting the script for a picture ob-ject, you can form an image on thescreen.

SLR camera

ALTHOUGH this is too small to appear in one of your architectural

models, it is a good exercise in usingPRISM, CYLIND, REVOLVE, and RULED.Draw it freehand first, to decide whichelements you will include. You couldask the user to specify the angle of thelens – from 28mm to 200mm, this willhave an effect on the length and diam-eter of the lens mechanism. For 2D justuse Project2.

If you are still a ‘Discoverer’, have a look at the task list that is at the beginning ofthe Voyager Course. Some of those tasks may appear to you to be something thatyou now feel ready to tackle.

Window or Door

Using scripting (not the old slabmethod), make yourself a door

that can be opened and shut in 2D andin 3D. Use PRISM or BLOCKs for theDoor. It should be able to change mate-rial, and have a scripted 2D symbol. Ifyou are really bold, then offer the choiceto glaze the door, and have a choice ofdoor handle or knob.

Grid

MAKE a stretchy 2D Grid tool that canvary the spacing of the verticals

and horizontals.

Page 102: Cookbook3_1

1.88

The GDL Cookbook 3 – Discovery

Copyright Marmalade and David NicholsonCole ©1998, ©1999, ©2000, ©2001

AppendixThings that didnt quite make it into the main book

Azimuth for Location awarenessIn the Location Awareness using the Global Variables,there is an ambiguity about the final true azimuth. Ap-plied to people and tree objects, you do not mind ifobjects flip 180˚ as that merely helps the randomnessto look more authentic. But if you need accurate rota-tion, this routine from Frank Chin of Brunei provides afix. It is more complicated than the ArcTan of the quickand easy method – but it works!

Frank writes: Below is the routine that I used for find-ing the bearing of a line from Point 1 (x1, y1) to Point2 (x2, y2). This can be adapted to be a subroutine tocalculate many different lines in a shape.

The IFCo chairOn your CD with GDL_CB_3.01, you will find the IFCochair (the Irvine Furniture Company), one that I haveused in recent 2-day training courses. This is more el-egant than the ‘Simple Chair’ in the GDL CB and takesconsiderably more space would allow it to fit in thisedition. But you can examine it for ideas.

It is a demonstration of the way that GDL is mov-ing, towards a more specific definition of objects, ratherthan the generic stretchy ones we have been used to.This IFCo chair allows for a custom chair to be de-signed by the specifier (at high cost no doubt) usingstretchiness and parameters. For the more cost con-scious, this chair is available in 6 preset sizes, includ-ing a choice of arms in two of the styles. If a specificchair is chosen, the custom parameters are locked. AUI tells the specifier more about the chair range.

!FINDING BEARING OF LINE - Master Scriptdx=x2-x1dy=y2-y1hypo=SQR(dy^2+dx^2) !Hypoteneusesinq=dy/hypocosq=dx/hypo

!angla is the angle the line!makes with the horizontal X-axisIF dx=0 THENIF dy>0 THEN angla=90 ELSE angla=270ENDIFIF dy=0 THENIF dx>0 THEN angla=0 ELSE angla=180ENDIFIF dx<>0 AND dy<>0 THEN GOTO 120GOTO 130

120:angla=SGN(ASN(sinq))*ASN(sinq)!to get angle between 0 & 90 degree onlyIF SGN(sinq)= 1 AND SGN(cosq)= 1 THEN angla=anglaIF SGN(sinq)= 1 AND SGN(cosq)=-1 THEN angla=180-anglaIF SGN(sinq)=-1 AND SGN(cosq)=-1 THEN angla=180+anglaIF SGN(sinq)=-1 AND SGN(cosq)= 1 THEN angla=360-angla130:

!Test of Frank's Azimuth algorithm!2D ScriptPEN ink

HOTSPOT2 0,0HOTSPOT2 x1,y1HOTSPOT2 x2,y2

CIRCLE2 0,0,0.1 !Origin

LINE2 x1,y1,x2,y2 !Line itselfCIRCLE2 x1,y1,0.02 !StartCIRCLE2 x2,y2,0.01 !End

DEFINE STYLE 'angtst' 'Arial',4,8,0 SET STYLE 'angtst' TEXT2 0,0,angla !Label ARC2 x1,y1,hypo,0,angla !AngleArc

A Value List can be used to write a Copyright state-ment with a web address, and the web address shouldalso be written into the Comment Field of the object.

See the IFCo chair for anexample of a User Interface

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 103: Cookbook3_1

The GDL

Cookbook 3

The SOURCE of all that

is good in GDL

Part 2

GDL Voyager

Page 104: Cookbook3_1

2.1

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Cookbook 3 Voyager Course

Some useful guidelines

WHENEVER possible you should apply rules ofquality control to all objects. Some of these qual-

ity control aspects are:

• Even for the smallest model, try to structure the scriptinto subroutines that represent physical componentsof the model. When you start a model, it is OK totap in preliminary code, but the moment you aregetting it to work, enclose it into subroutines.

• Ensure that the subroutines are totally self containedin terms of cursor location. DEL the exact numberof cursor moves in each subroutine.

• Distinguish between parameters that the ‘user’ willbe allowed to change and ones that your script needsto know. Make sure that the user parameters areclearly explained in the dialog box.

• Can the parameters be grouped into hierarchicalmenus? Could you form a series of User Interfacepages?

• Pay attention to RESOL on all circular elements –efficiency in speed of rendering is a quality issue.

• Always work with plenty of paper and pen handy,and be prepared to sketch out every small problemon paper – this is more efficient that tapping thingsinto the script and being annoyed by error messages.

• !Document all your !subroutines and !decisions with!comments in the !script.

• Put all key words into UPPER CASE (e.g. BLOCK,MUL, DEL etc) and keep all variables in lower case(e.g. len, wid, higt, x1, z0 etc). Do this even for

quick and dirty library objects. It’s easer to de-bug later.

• Although it’s tempting to use PROJECT23,270,2 for all 2D scripts, try to replace

these with 2D scripts if you want effi-ciency in display in the Project Plan.

• Do not be afraid to try new com-mands and polylines and masks inGDL – some of these may be betterthan ones you have got set in yourways of using. Use Trial and Error

if at first you do not get them work-ing – if that fails, try LogicalThought!

THIS Voyager section is for GDL enthusiasts who have had enough experience to venture intomore difficult territory. The section starts with a series of questions posed to the intrepid voyager, which

(if you feel bold) you should set yourself as tasks. Many of the tasks are solved in the subsequent pages. How-ever, for those who just want to work progressively through, look at the exercises and try your luck. There is alot of GDL syntax dispersed among the exercises. There is a grading sequence in the exercises, but less prescrip-tive than in the Discovery course. Some of the exercises in the Voyager section are useful as a resource fordipping into when you need to remind yourself of certain routines. I wouldn’t attempt any GDL task withouthaving the GDL Cookbook with me as a reference; for all but the obscurest task, the Cookbook can be used inplace of a manual.

Voyager task list

IF you attempt some of the following tasks, assume ahigh level of parametricity in all objects, but try to

keep to the point of the exercise, to keep each onewithin just a few hours. If you are on a GDL course,then you are not on your own during these exercises –the idea is to be thoroughly briefed by a tutor at thestart, and to work on it with a tutor close at hand, butnot writing it for you.

If you are teaching yourself with the Cookbook, tryto do these with a fellow enthusiast. Talk over the bestapproach to each problem.

You do not have time to make each one a totallyfinished product with total error checking, and perfectuser friendliness – but do the best you can in the time.Keep focused on the learning requirement of eachexercise, and avoid distracting side issues.

No matter how experienced you are, make frequentuse of the HELP windows and manual.

Deployable‘Pinero’ scissorspace frame:model by DNC

Page 105: Cookbook3_1

2.2

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Table LampLIGHT, Revolve, Articulating form, Lamp, Cylind, Ellips

MAKE a small anglepoise lamp. Avoid excessive detail in the body of the lamp,as the purpose of this is to use the Light command. Include a toggle switch.

The Lamp head should swivel. Set two of the lights on a table, and photorender tosee how the pools of light work together.

Extruded SectionDXF Conversion, CutPlane, Revolve, BPrism

OPEN a 2D DXF or DWG file from Autocad or similar, convert it to a slab, thenconvert to a library object and either:

• write a 4 directional Mitring routine for the 3D section, or:• write a Curving routine for the 3D section, with parametric curvature.In either case the section should be able to be tilted around X and Y.

If you dont have a DXF sectional drawing like this to hand, draw one quickly inArchiCAD (using floor slab) view the object in plan, and save it as a DWG or a DXF2D drawing. Reload it, convert it to a SLAB using space bar snap, and view in plan.This time, save it as a library object.

StaircasePUT & GET, BPRISM, REVOLVE, TUBE

CREATE a routine for generating a staircase with parametric rules for number ofsteps, risers, tread, material etc. Plan ahead to see how you would organise

this, if you wanted:a] Straight stair with handrailb] Theatre seating in the round,c] Spiral Staircase

Although these stairs would be used in different parts of a building the routines aresimilar and if you have time, write both main routines in the same object.

HandrailsTUBE, PUT & GET, Circle Geometry, RESOL

DESIGN a long handrail for exterior use, such as for a racecourse. One of theproblems here is that you cannot use ELBOW and RADIUS, because if you get

the RESOL right for the curve, you have an unacceptable number of polygons forthe surface. Also, you need to distribute uprights evenly along the circular rail. Howwould the rail be defined? By chord length and bulge is better than by radius.

Ensure (by masking) that the tube looks clean and is not cluttered with lines. Try tomake it go up a slope – by defining upper and lower heights (e.g. round a stair).

Geodesic ExerciseCan you build using trigonometry?

THIS exercise is surprisingly easy if you combine the power of loops and trigo-nometry, because the icosahedron (20 sided) is so very regular. It has a pen-

tagonal pyramid shape at the top and at the bottom, and ten equal triangles formingthe sides. If you use arrays, you can remember the locations, and line all the panelswith tubular edges, in fact, hide all the panels altogether, and perhaps put ball jointsat all the junctions.

Constant Rectangle2D Scripting, Global Variables

DRAW a Rectangular outline to your project that can be a frame for printing onpaper – that stays the same size regardless of the scale of the drawing. i.e. if it

is equivalent to A2 in outline when in 1:100 scale, it is still A2 when your drawing is1:500, and your building is reduced to a speck. The Size of the rectangle is set withA and B, but need not be stretchy. (Hint, you need globals, and it’s 1-line)

Page 106: Cookbook3_1

2.3

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

CatamaranCOONS, MUL, GOSUB, CYLIND

THIS exercise if a must if you are interested in making meshes, and in structuredprogramming.

a) Make the hull of the CAT. First the floats must be made by making half of one floatas a COONs and then doubling it to make one float, and then doubling that. Thewidth of the float and the length and width of the Cat should be parametric.

b) If you have time and the interest, take the Cat a bit further. Make a central Mastand forestay. The mast should be oval in profile. Make a parametric sail and jib thatcan be to Port or Starboard tack.

User InterfaceMastering the UI command set

TAKE an object you already know well, and d evelop a page or a set of pages using the

User Interface command set in ArchiCAD 6.5 o n -wards. If it has Value lists in it, see if these canbe converted to a Pictorial Value list.

Spaceframe / LatticeCylind, Nested FOR..NEXT Loops

A spaceframe Lattice beam was part of the Discovery Course. This pays some re-inspection, this time in the form of a spaceframe roof. This should be paramet-

ric in number of bays, depth and spacing, diameters etc. It involves some FOR...NEXT loops.

For the real challenge, you could make its dimensions based on A and B, and thescript work out the number of bays. But this is not essential.

Ideally, the upper sections should be square, and the diagonals and lower latticeshould be round.

Derrick CraneCircle geometry, Cylind, Tube, Elbow

ALTHOUGH this is a very simplified model of a Derrick crane, it is a good exer-cise in knowing the XYZ coordinates of objects in circular space and using

TUBE to construct it.

Making a hook for the crane, and making this lowerable.

The crane should be able to swivel round.

As the arm of the crane is lowered, the cable should always reach to the pulley at theend of the arm. Try to keep the hook at a constant height.

Hollow ElbowSweep, Cutplane, Prism_, Loops or cutplane

This can be made in two ways – by Defining a hollow tube profile, and drawingit with a Sweep command through a curve, or by Revolve. Make the main ra-

dius, the tube radius, the tube resolution, the surface resolution, the sweep angle,and the wall thickness parametric.

Stretchy Battered Wall tool

ARCHICAD does not provide a tool for this purpose (how many times do archi-tects use battered walls?), but this tool could serve for ramps and earthberms.

Like a Wall, it should have user definable colour on the sides and top Faces, InternalFace, and external Face. You can also do it without GDL, to include windows. Doyou know how?

It is an even greater challenge to make it mitre or turn corners (anglar or rounded),or to include windows, so do not attempt this unless you manage the main task withease.

Page 107: Cookbook3_1

2.4

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Bowstring Truss – 2DTUBE, ELBOW, Circle Geometry, PUT, GET, For... Next

IF you are short of time, do not attempt a 3D Bowstring truss – which has 7 differentcircle centres and radii! This 2D truss is a development of the Handrail task in the

Voyager course – using the TUBE command.A 2D truss only has two circles. It should be parametric in span, height and depth, and

in the quantity of lattice members. But you will need circle geometry to work backwardsfrom Span and Height to calculate Center and Radius. The components of the truss canbe made with the ELBOW command, or the TUBE command, but for realism andmodel quality, both the compression member and the tension member are best done withTube.

Picture Objects and texturesPicture, Alpha channels, making materials, global variables

YOUR models can acheive added realism if you can put scans of photos of people orplants onto a surface. They are even more effective if you can have the surroundings

of the sihouette made transparent by using alpha channels. The same can be done withtextures and materials for entire objects. Scan or photograph something and do thePhotoshop editing on it to achieve a silhouetted outline.At this point it is useful to learn the routine for making objects ‘Location Aware’ so thatflat 2D objects look more solid.

Smooth rounded Bodies!COONS, MUL, Prism, Polylines

FORM part of the front end cabin of a Ford Transit Van. This is done by using COONSmeshes. As the van is symmetrical, you only need to make half of it, and MUL to

generate the other half. It is not as difficult as it looks. You do not need to make itparametric as the van shape is fixed. Every dimensional location of the front end shouldrelate to the same origin. Also, each COON surface is adjacent to the next, so you havefewer XYZ points to calculate. It is worth maintaining a consistent grid in the Y directionto reduce the workload.

Animation in timeCameras, Global Variables, Articulating Model, TEXT

IT is possible to make animated objects change with time. This may not be so usefulin practical architecture, but is a demonstration of the powers of ArchiCAD. Try one

of these ideas, or one of your own.• 3D clock whose hands turn.• LCD type clock whose numbers change with each frame.• Neon lettering for a club/bar, whose letters light up or rotate in sequence.• Reciprocating single cylinder piston and crankshaft.With each frame of a ‘Path’ it is possible for the library object to read the frame number(N_)and react accordingly. If you position 2 cameras in identical locations with many inbetween frames, the object will animate. You must have "Rebuild each Frame" set up inthe special menu.

Carved PolyhedraSPHERE, CUTPLANE, CUTEND, FOR... NEXT

MAKE Cubes (hexahedron) and Spheres your starting objects. Using Cutplane,form these into truncated polyhedra. Make a cube from a sphere. Then try the

rhombicuboctahadron from a cube. Carving, as a way of making these, is considerablyeasier than building these up. There may be a problem with the way that cut surfaces aredisplayed, and you have to get Pen colours and materials right.

Another thing you may try is a sphere that has every facet in random colours (asshown in the Primer in the Cutplane section).

Page 108: Cookbook3_1

2.5

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Fun with Helical formsBPRISM, TUBE, Polylines, Trigonometry

FIRST make a helical shape with the BPRISM command – experiment with this.Then make a smooth tubular helix using the TUBE command, making the frequency,

total and tubular diameters parametric. Finally, try making something like the penguinpool type ramp that is shown in the GDL manual.

Perforated Wall PanelParametric Holes in a PRISM_, PUT, GET, FOR...Next

TRY making a wall panel, perforated with a number of holes. You can make thechoice of Round and Square holes parametrically selectable. Given a number of rows

and columns of holes, your program should work out appropriate sizes and spacing. UsePUT to organise the array of holes, and use PRISM and GET to produce it in 3D.

Can you use the same technique with EXTRUDE, or make a curving object withREVOLVE?

Flexible TubeFile Input, TUBE, PUT, GET

TUBE command allows one to make tubes which are mitred at all junctions. Asequence of tubing could be made by reading a list of points within the script. These

can be in the TUBE command, or can be put into the buffer first using PUT and GET).This is how the spirals are done.

You can also try writing a script that can read in a text file, the SAME script couldgenerate a great variety of tubular structures by reading in text files of XYZ points. Thus,complex structures for piping, geodesics etc could be constructed more easily than withconventional GDL.

Stretchy ObjectsUsing A and B

THE user finds it easiest to place objects into the Project plan if they can be stretched.Conventionally made objects will stretch, but all the elements of the models will

then be wrongly sized. Make a stretchy object that preserves or recalculates the size ofelements. Try one of these:• Soldier, coping or Dental course• Wall radiator (with pipes and valve)• Table (so leg sizes are retained)• Trussed Rafter• Railing with spaced verticals

Kitchen ChairCone, Structured subroutines, Polylines, BPRISM

THIS elegant traditional chair model can be made almost totally from the CONEcommand, except for the Seat, Arm and Back made with PRISM and BPRISM

commands. You should only need to build half of it, and MUL to make the whole chair.

Report WritingProperties Scripting or File I/O

GET the stretchy radiator (or something similar), to be able to read the global variables, and output a report to file,with a unique filename, defining data such as its location in XYZ, storey, orientation, surface area. Assuming you

made it clickable to be double or single panel, make extra clickable choices for the 2D symbol to report on the surface areaof the radiator. Instead of the radiator, you could try something structural. For example, a stretchy Universal Beam/Column– has a sectional area, moment of inertia, modulus of elasticity, radius of gyration. The formulae are available in the MetricHandbook. Or just get it to write a report to the Components window, using a Properties Script.

Page 109: Cookbook3_1

2.6

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

More things you might like to try:• Define Text Styles in 2D symbol, getting 2D symbol to report info.• Making Text autosize, whatever the plotting scale.• Define Materials or Lights in the script.• Revolve, Sweep, Extrude, Pyramid, Tube• Slab, CSlab, Croof, CWall, Bwall etc.• Make a Macro and CALL it.• Time and Date• File Input and Output• Make a scene entirely using Picture Objects• A task requiring Circle Geometry

• Try a 3D truss – using tube or trig.• Try a tree trunk, with random generation of the next set of branches (Difficult)• Try making a simple assembly of shapes, (as used for example in the demo of materialsin ArchiCAD) and then create materials (in either script or in working environment)

which exploit alpha channels, for transparency, bump mapping etc.• Some clever railings that can be level or follow up a stair, and be stretchy• Something that changes position or state as each animation frame progresses.• Something (such as curved glazing) that uses arrays, either in the script, or

even as part of the user input in a parameter box.

Irregular Surfaces

TERRAIN is one of the more difficult tasks in ArchiCAD- the Slab tool is too flat, the roof tool is another solu-

tion, but requires careful tweaking. COONS is only con-trollable at the edges. MESH combined with RND is a use-ful way of randomizing terrain – especially when you com-bine two together, of different colours. MASS is good, butdifficult to exploit randomisation. Try it.

Window 3D (Modelled)

MAKE a window using slabs within the working environment, thenprojected in the 3D window and saved as a Window or Door. It

can then be edited by opening the library element as a Window or Door.• Now try adding a cill to the window.• Now try making the window head arched.• Now ensure that the window fits into walls of varying

thickness and materials.• Allow user to show glass or hide glass.

Smart Structural objects

MAKE a stretchy object containing a number of spaced out three D elements orspaced out holes – such as a cellular or castellated beam (with parametrically

calculated hole positions). Make this beam react to its length by changing in width andheight – with the holes and hole spacing being re-calculated intelligently.

Desktop Clock

THIS can be a totally 2D object, designed to float about on thedrawing – either capable of being to scale with the building (what-

ever the drawing scale) or to be a constant height (whatever the drawingscale). This can display the time to the user, and record accurately thetime and date of printing a document. You need to look at REQUEST,Style definition and drawing scale.

Byzanti
Highlight
Page 110: Cookbook3_1

2.7

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Door – 2D ScriptedArc2, Line2, Globals

MAKE a simple opening door in 3D. Use 2D scripting togenerate the 2D door image, and use global variables to

make sure it is always the right width to fit the thickness of thewall it is put into. Make it show different levels of detail be-tween 1/50 scale, or 1/100 scale.

MAKE a copy of the same door, but do the 2D using 2Dsymbol and make sure that it responds to scale in the

same way, using the Fragment2 command.

Ridge and Hip tilesStretchy objects, Tube or extrude

MAKE a roof similar to the one here, and make a universal stretchy hip and ridge tile that can follow all the hips

and ridges. Make it so that it stretches horizontally in plan,according to the dimension A. Make it so that the pitch isdefined as an angle.

MAKE a copy of the hip-ridge tile, and redefine it so thatyou use the dimension B to define the upper height of

the tile (so that it is no longer based on angle).

User Defined Lines‘Squiffle’

DRAW 2D lines in the Project Plan. Select the lines drawnand copy them to clipboard. From the Options menu,

select ‘Line Types’ and make a new Symbol line. Try making a‘squiffle’ line, and then use that to turn a 3D axonometric intosomething that looks hand-drawn. Use the same technique tomake insulation, or concrete texture, or lines including text orimages.

Library Object conversionPUT and GET, Sweep or RULED

DRAW out a slab in the Project Plan, and save it as a Library object.Look at the script: you will see a cPRISM. Modify it so that you have

a PUT statement of the X,Y locations of the points. Now write an EX-TRUDE statement that uses GET, to feed the locations into the extrusion.Use NSP to determine how many points to put in the extrude.

NOW, try it again this time to make a more complex shape. Spacebarsnap a polygon to the slab, and then shrink the polygon (so that it has

the same number of vertices as the first slab) Move the polygon aside slightly.Spacebar snap another slab to the new polygon. Now save the two slabs aslibrary objects. Now use PUT and GET in the same way (stealing the X,Ylocations so conveniently given to you) and make a RULED command. Bythe way, note that this could also be done with a SWEEP command, usingonly the first set of points used for the Extrude exercise above.

Redefining Magic parametersA, B and zzyzx are what I call Magic parameters becausethey control stretchiness and appear in the info box for theobject. The way to change them is in the info box, in thesettings box, or to stretch the objects.

If you need to change them any other way, you can do itby renaming them. For example if a piece of furniture isvertically stretchy but must not exceed a range of 1.0 to 2.0metres, you can write in the Master or 3D script:

hit=zzyzx !heightIF hit<1.0 THEN hit=1.0IF hit>2.0 THEN hit=2.0

Use hit to make the object’s height. Then the user can stretchit all they like, but the object will stay within those limits. Ifyou want the stretchy buttons to stay in range (or bounceback!) you can write like this:(first, in the Master script)

hit=zzyzxIF zzyzx<1.0 THEN zzyzx=1.0

(then, in the Parameter Script)IF hit<1.0 THEN PARAMETERS zzyzx=1.0

Byzanti
Highlight
Byzanti
Highlight
Page 111: Cookbook3_1

2.8

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Tips and TricksSquiffle

COMPUTER line drawings look tooperfect and determinate and of-

ten mislead the client into thinkingthat your sketch design drawings arelooking like a finished scheme. Schoolof Architecture tutors are especiallyprone to be hostile at crits when facedwith hard exact line drawings whenthe other students are still in the softpencil stage.

Try using ‘squiffle’. Create a LineType by drawing some feathery orwiggly lines in 2D, Copy them to clip-board. Go to Options:Linetypes, makea new one and call it Squiffle (orsomethig similar). Paste in the wigglyline. Modify the scale options if it’s toobig or small.

Now view your model in 3D.Save the model as a 3D Pict,with VECTORED lines andpolygons. Then bring backthe 3D view into the Projectplan with a ‘Merge’ com-mand. Now select all of the3D view you have broughtin. Double click on the linetool in the toolbox. Now se-lect ‘squiffle’ for the linetype.

Lo, your 3D drawing isconverted into somethingthat looks informal, evenhand drawn to the casualviewer. this can be printeddirect, or popped intoPlotmaker.

Above: Ask for a ‘New’ line, and click on ‘Symbol’. Thatwill allow you to paste in some lines.Below: The line can be solid or dashed: move the little flagmarkers. The normal Paste command doesn’t work, you haveto hit the Paste Line Components button.

Draw your own line in the Project Plan window, usingthe 2D line tool.

Right: You willhave to play with‘Scale’ to give theline the‘squiffliness’ thatyou wish for.

Left: Your 3Ddrawing nowlooks moreinformal.

See a later exerciseon ‘Squiffle 2’

Picture Objects

PEOPLE often have trouble gettingPICTURE to work – see the exer-

cise in Discovery, called Lioness.To remind you...The image to be rendered has to besaved from Photoshop into a cur-rently loaded library. It must be TIFFor PICT for Macs and TIFF for PCs. SomePC users recommend ticking the ‘Mactiff file format’ button in Photoshop.

In the parameter box, with Macs,you must call the file by its realname, e.g, tree01.tiff, whereas withPC, you have to omit the suffix (andlet Windows add it on for you), andwrite just tree01. This is a real pain, asarchives which are ported from Mac toPC or back usually transfer parametersdirectly, and could result in images notrendering on the alternative platform.

Even if you use channels (for alphachannel transparency) make sure you

‘flatten the layers’. After amodest amount of copyingand pasting, a photoshop filemay have generated half adozen or more layers – whichprevent the file being saved astiff or pict.

Picture objects lie flat on the floor, soif you want it to stand up like a tree, youneed to ROTx 90 before you issue thecommand : such as

ROTx 90PICTURE “tree01” 8.0,12.0,1DEL 1

When you write an archive for transferPC to Mac or back, the Pictures used inthe Picture objects do not get included– you must copy them over sepa-rately.

Picture objects should be 2Dscripted to make them stretchy –it’s more user friendly.

If you use tiffs on Macs (forportability to PCs) note that tiff alphachannels DO NOT WORK on AC 5.0,but they do work on 5.1 & 6.x.

For facades, record the number ofpixels horizontally & vertically, andensure that the proportions of the PIC-TURE rectangle are perfectly match-ing. 60-80 dots per metre of buildingis an ideal lowest density.

This street scene is easier to modelby photographing the buildingsand making them into pictureobjects. Only the building on theright is 3D modelled.

Page 112: Cookbook3_1

2.9

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

PICT or TIFF or JPEG?

WHEN rendering textures you may be wanting to useAlpha channels – to get transparency. These have

to be made in Photoshop (or similar). Save as PICT or TIFFon Mac, and TIFF on PC’s. If you want to make your filestruly cross platform (through saving as archive files) useonly TIFFs.

These files should be saved in uncompressed form. Ifyou apply compression such as JPEG, one of the first thingsto be squeezed out during compression is the alpha chan-nel. If you are not using alpha channels, you can use anamount of compression, save as JPEG, which will workwell on PC or Mac.

Rendering – Speed

IF the project is large, photorendering often appearsfaster than 3D drawing, analytic or raster. Before em-

barking on a VR walkabout or a flythrough animation orseries of pictures, ArchiCAD tries to draw a 3D of the mostrecent camera used – which can take ages. It does this forgood reasons – it has the effect of an integrity check onthe whole model to make sure that there are no objects,pictures or textures missing.

Therefore, set up one 3D camera facing away from themodel in Raster mode (so that it draws nothing), and im-mediately after, proceed with the VR or Flythrough. It willstart with the rendering almost immediately.

Preview images

IT improves the presentation of your Library objects ifyou can give them a Preview window. If you look in the

object browser (in the Library part settings box) you cansee how drab are the objects without an icon. Previewimage gives them an icon.

Render an image of your object in 130x130 resolution,select it and copy to clipboard, open project preview win-dow and paste image; save. Now try and see if you have apreview.

This is especially good if you are making objects forother users.

Roof Cutting

IN AC5 you have a choice of cutting roof edges vertical, orperpendicular to the surface. With AC6, you can do more.

Just Alt-click on a roof, and then hold the mouse button downon a roof edge until the menu pops up. You now get an optionthat looks like an XACTO knife blade – with which you cancustomise the cutting angle of the edge.

Tips and Tricks

Use the GDL Manual!MANY ArchiCAD GDL commands are covered in vari-

ous sections in the GDL Cookbook. But please notethat it is not the function of the Cookbook to replace themanual. You need to use both. You will find the GDLManual a lot easier to read now you have tried the Cook-book.

The AC6.6 GDL reference manual is better than itspredecessors. The main ArchiCAD reference manual chap-ter on Libraries is an essential read for anybody startingGDL, as it contains fundamental information of libraryobject writing and library organisation (some of which Ibelieve ought to be in the GDL manual.)

The Digital Architectby John Stebbins, Digital Vision, Irvine CA

SOME people think that ArchiCAD needs to do everythingwell. I have never believed this. It does MOST things well

and as far as project THROUGHPUT is concerned, it can't bebeaten for most things. I believe there is no other product outthere as efficient as Archicad for most of what architects do,but occasionally, we have to create spaces, objects and wierdthings with lots of curves.

But, I have always maintained that the DIGITAL ARCHITECTneeds a "tabouret of tools" – a chest of tools – to get the jobdone. Can you build a building with just a hammer?

The supplemental tools the ArchiCAD Digital Architect needsto master and to invest in, in my humble opinion are, in orderof importance:• Photoshop – for image manipulation and photomontage• FormZ – for modelling wierd things• PowerPoint – for slide show, speaker support presenta-tions• Macromedia Director – for multimedia, interactive pres-entations

Of course there are other tools, but as an instructor of dig-ital architecture (UC Irvine Extension), I see these as the mostimportant.

Everyone needs to ask themselves: how digital do I wantto be? The more digital you want to be, the more of the abovetools you will need to master (or have a master as part of yourteam).

I also believe that the more digital you are, the more ‘ofservice’ you can be to your clients, the more additional serv-ices you have to sell, the more efficient you can be, and ifdigital tools are properly deployed, the better architecture youcan create.How digital do you want to be?John Stebbins

FormZ (John Stebbins continues...)I have been a dealer for FormZ since 1991(and an ArchiCADdealer since 1989) and find it is a perfect complement toArchiCAD for modelling organic, spline-based shapes, like cer-tain furniture, light fixtures, hyperbolic paraboloids, etc.

The way you bring these things into ArchiCAD is to use the‘Open Library Part’ command, choose ‘New Object’ and bringthe FormZ model in as an ArchiCAD object via DXF or 3DStudioMetafile, saving it in your loaded library.

Page 113: Cookbook3_1

2.10

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Pens changing when opening DWG filesFrom: Matthew J. Pastula <[email protected]>

I recently opened a dwg file from AutoCAD 14 on the PCside and it changed all the standard pens and colors all

around. Is there any way to get the previous pens and colorsback without reloading ArchiCAD?Duane Valencia writes:THERE are a couple of ways to achieve this...1. If you have an old file that has the pens you want... Justopen it. Then start a new drawing. This new drawing willmaintain the pens from the previous drawing and then be-come part of the new file.2. If you like the factory presets... hold the option(alt) keydown and choose NEW & RESET from the file menu. Thiswill bring all defaults back to factory.If you are asking how you get this AUTOCAD file to use yourold pen setup... then just copy all the elements from the.dwg file and paste into one of the scenarios above. Thepens will remain as they were defined for the blank file.CAUTION: this means the pen weights will also be "preset"and may make your dwg elements different from that in-tended.

Recording contract drawings, long termDuane Valencia writes:

I have been RECORDING the sets that go out by writingPLOT files instead of duplicate layouts. I find this a bit

safer and more efficient. Safer in that 3 years from now, Idon’t have to worry about backwards compatibility withplotmaker. I don’t even need plotmaker to do the plotting.Theo de Klerk writes:

SECOND that! We keep a copy of the PLT file in a folderwith the date with the project folder as an electronic

record of what drawings were issued. If someone asks forextra copies of a particular drawing just duplicate the PLTfiles and drop them all in the spool folder – very quick!Editor’s Note: Another question is, which media is safest forlong term storage. At the time of writing, it seems CD isguaranteed the longest life into the future. Ferromagneticmedia (zip/tape/disk) have a limited life, as do the mecha-nisms. DVD is still undergoing development of standards.

True Line weights in 2D

YOU can set up the Pen palette to give you differentcolours, and you can set up the line weight too, in mil-

limetres or points. But they persistently remain as hairlines,no matter how much you zoom in. The answer to this per-plexing problem is to look at the Options/Display Options..menu where, if you set ‘True line weights’, they suddenlywork. You need to be pretty settled on the scale that youwill be printing at; now that you have set absolute thick-nesses, the relative line weights will change if you changethe drawing scale.

Transferring favourite settingsHaving started a new file, you realise you want the settingsfrom an older file, perhaps one that you started with an olderversion of ArchiCAD. In particular, pens change between ver-sions, and people are known to modify the pen palette ofthicknesses and colours. You can transfer preferred colourand line thickness setup to the new file in the following way:1) Open an old file that has your preferences.2) From there, open a new (blank) document. This will thenhave your palette preferences.3) Merge the file with the ‘wrong’ colour palette into thisopen blank file. It will now have your preferences.4) save this as [filename] of ‘wrong colour’ file to overwriteit.

Stationery File – keep your settings

YOU want to preserve all your hard won material, layerand line settings for the next project? On the Mac, you

can save a ‘Stationery file’. Take a COPY of a file that has allthe ideal settings, linetypes, layers and materials. Clear allstories, clear all objects – so that the file is empty. Save it as‘AC_template’, or some such name. Back in the Finder,Get_Info on the file, and tick the ‘Stationery’ checkbox, andLock it. When this file is next opened, it will offer you a newuntitled window, retain all your preferred settings, but notaltering your original template.

If your project has already started, you can use the ‘Merge’command to bring in another template file that already hasthe Pen settings etc that you want.

Printing in EPSYou might want to prepare a drawing for publication withQuark Xpress or Pagemaker. You do not have a ‘Save as Post-script’ option when saving from the 3D window – but youcan save a drawing as a Plotmaker file. Open a new Plotmakerlayout and bring the .PMK file in. Now you can ‘Save As...’ toPostscript. If your pen thicknesses are all too thick, go backto Plotmaker, adjust pen thicknesses for that image and saveagain. You can adjust each colour used in the image.

Fit a Rendering into a [email protected] wrote:How do you guys fit a rendering into a photograph?From: [email protected] is a very quick answer:1: Use a photo in the background of your 3D view to matchthe model to the background. [Be sure that pixel resolu-tions match]2: Render your image with the model against a white back-ground. Do not use the photo background in ArchiCAD'srender!! Make the sun slightly yellow-brown and the ambi-ent light slightly blue-mauve.

3: Merge the two images [background and rendered modelwith white knocked out] in Photoshop.4: Use eraser to meld edges of model at ground level tophoto background. [Judicious rubber stamping of plant ma-terial will also disguise the edge.5: Fake up a cast shadow to integrate the two images.6: Adjust color balance of background and model to match.[Color photos tend to be warmer than ArchiCAD models.]7: Add diffuse glow and some noise to make the model graini-ness match the film grain of the background.8: Jerk around with it for hours massaging every detail.Now it looks almost half done.• Dwight ‘wait for the book’ Atkinson, MAIBC

Page 114: Cookbook3_1

2.11

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Tips and TricksMaking scripted objects stretchy orsqueezy

THIS topic is addressed in several of the Cookbook exercises, but in a nutshell, here are some guidelines.

• Make the width and depth of the object dependent on ‘A’and ‘B’ in the 3D script.• Your 2D script, which will either be scripted or based on aPROJECT2 must include HOTSPOT2’s based on A and B.

As long as there are Hotspots whose distance apart is equal toA and B, this routine will work. For items which are linear, youcan use HOTSPOT2 0,0 and HOTSPOT2 A,0.

Because these Hotspots are dangerous (move them and yourobject will be distorted) you will always have to use Cmd-D tomove them. It is better to plant additional hotspots at placeswhere it is safe to pick the object up.

If stretchiness is a big feature, plant a 2D crosshair at theA,B points (LINE2 A-0.02,0,A+0.02,0:LINE2 A,B-0.02,A,B+0.02)

Compression Advice

WHEN you save an Flythrough or VR file usingQuicktime, you will be offered the chance to set

options for compression. Quicktime is not only about dig-ital video, it also contains ‘CODECs’ which are algorithmsfor COmpression and DECompression.

The listed types in AC6.0 are: Animation, BMP, Cinepak,Component Video, DV-NTSC, DV-PAL, Graphics, H.263, IntelIndeo Video 4.4, Motion JPeg A, Motion JPeg B, Photo-JPeg, Planar RGB, Sorenson Video, and Video.

The most commonly used are Animation, Cinepak andJPEGs. ‘Cinepak’ achieves astonishing compression, buthas a serious loss of quality, and can take too long for themovie to decompress as it is read in from disk. I use ‘Ani-mation’ most often. You also have a slider bar from Worstquality to Maximum quality. If you haven’t got a problemwith disk space (for example you are saving to Jaz car-tridge or to CD), my advice is to set the slider to Maxi-mum quality, or to No compression at all.

There is a balance to be achieved – with no compres-sion, the disk (or CD) can be too slow to deliver the frames– if there is some compression, the disk can deliver faster,but then you need a fast processor to decompress eachframe. A smaller frame size (320x240) and a slower framerate (16fps instead of 24fps) will also help the speed.

Wirelines in RenderingAaron Sills<[email protected]>

SOMEONE mentioned wantingto produce wireframe within a

rendered view.Save a hiddenline view as 2D

elements (2DL) and then renderthe exact same view and save thatas a tiff or pict. Lay the lines di-rectly over the top of the render-ing in Plotmaker. This gives a ren-dering that is a bit more graphic(for want of a better word) be-cause of the outlines. The 2DL canbe edited before putting it intoPlotmaker to remove any lines thataren’t needed in the final image(all those extra lines on 3D peoplefor example).

Servers with Teamwork – try iMac!

THERE has been discussion about getting Teamwork functions to work swiftly with afile server during Send and Receive. The key isn’t just the speed of transmission, but

how fast ArchiCAD takes to process the changes. There is as little as 10% differencebetween 10base-T (normal ethernet) and 100-base-T even though 100-base-T sendsfiles 10 times faster. Ultra fast SCSI or IDE give the biggest speed increases over com-puters with normal disks, even if equipped with fast processors.One cost saving solution that surprised many: John Zdralek writes:“Are you running ACTW on a Mac network and are *NOT* currently using a G3 for aserver? Here’s a tip. Buy an iMac. The best $1,199 you will ever spend.

I was using a PM7200/120 as a server on a 100bT Ethernet Network. Opening an8.2mb ACTW file with a 200mb library on a G3/300 client took 5 minutes, 48 seconds.Two weeks ago I bought and setup the iMac as the office server, (running plain oldappletalk, NOT appleshare). Are you ready? Same file and library, opening on the sameG3/300 client: 1 min 47 seconds! OK, so you think, "but we need a REAL workhorse forour server. The imac is only 233mz and has an IDE drive." Check out this test – I ALSOsetup a G3/300 minitower WITH Ultra Wide SCSI drive as the server, and opened theSAME file on the G3/300 client desktop. The elapsed time to open: 1 min 40 seconds!!!I am VERY glad I saved $1,100.00, (PLUS the cost of a monitor) by buying the iMac.”

Tracing Scans

MUCH could be written on this. I believe that you arebetter tracing into ArchiCAD yourself, so you selectively

draw what is significant information. For mechanised trac-ing, CorelDraw (with CorelTrace) is highly recommended, ifset to ‘centreline trace’. Bitmap scans cause an unpleasantslow down in AC, and should be deleted as soon as possibleafter tracing, or moved to an invisible layer, or storey.

If the map you are scanning from has a grid (e.g. UK Ord-nance Survey maps have a 100metre grid), set the ArchiCADgrid to the same grid. Rotate the scan until it is level withthe grid. Then you can stretch the scan. To keep the scan in

For example, in onerectangular object:HOTSPOT2 0,0HOTSPOT2 A,0HOTSPOT2 A,BHOTSPOT2 0,BRECT2 0,0, A,B

For another example, in a concen-tric rectangular object:HOTSPOT2 -A/2,-B/2HOTSPOT2 A/2,-B/2HOTSPOT2 A/2, B/2HOTSPOT2 -A/2, B/2RECT2 -A/2,-B/2,A/2,B/2

proportion, tweak the top right corner away, then return itto the previous location, hit Alt-A (which locks the diagonalangle of the scan, and then you can stretch or shrink it,knowing that the scan retains the correct proportions. Youmight have to do this several times.

If you can get a site plan that is already vectorised – e.g.a UK Ordnance Survey map in .dwg format, you can use the‘Find and Select by pen colour number’ to reduce the multi-tude of layers to just a few, such as building outlines, build-ing names, kerbs, levels etc. When all colours are copiedover, delete all the original layers.

Page 115: Cookbook3_1

2.12

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Tips and TricksBounding Boxes in 2D

THERE are occasions when even DNC usesthe conventional method of making Li-

brary objects using walls and slabs. I oftenmake composite objects using GDL objectspreviously made. (By this method, you get thecorrect syntax with the CALL command.)

ArchiCAD puts Hotspots at the ‘boundingbox’ of the object – which can be a nuisanceif the object is very complex or curvy, as itmay not relate to the real object’s position. Italso fills the Project plan with undesiredHotspots which show up when you marqueeanother object. You also get one at the cen-tre point of the bounding box.

If the 2D view of the object is just a 2DSymbol, you should put one hotspot at theorigin of the symbol window, then puthotspots on the real points that you wanthotspotted. Turn off ‘bounding box’ hotspotsin the Library object checkbox, and save. InAC65 hit the ‘Details’ button to find thischeckbox. The bounding box will go. If youwrite Hotspot2 commands in the 2D script inAC65, bounding boxes disappear.

In AC6, 2D symbols have fallen into dis-use. Autoscripted objects generate manyscripted Hotspots, so you can more readilyturn off the bounding box if there is one.

Flythroughs (or drivebys or whatever) can be good but can also be-

come boring. It take hours or days ofcomputer processing to produce justa minute or two of the ‘witchesbroomstick’ flying effect. But justthink... the TV and film industry hasaccustomed us to pans and zooms,cuts to another scene, or from face toface. You could do better to stitch to-gether a series of shorter clips.

Some collected Tips and Trickson effective animation:• Use Storyboards and plan your fi-nal animation before touching thecamera tool. Most viewers get boredquickly, so think of some variety.• Use recognisable items (for exam-ple a fountain) in views so that theviewer does not get disorientated.• Look at varying the speed at whichyou ‘fly’ (vary the distance betweencameras.)• Compile the animation first withonly 3 or 5 ‘tweens’ per keyframe tomake sure you like the route.• Dropping the camera and zoominginto a building is much more effec-tive than the orbiting or landing byhelicopter effect.• Zooming could mean having a se-ries of cameras getting closer to theobject (with the target fixed on theobject). But if you place two camerasin identical location and target, youcan have one set on a zoom angle of90 degrees, and the other on 30 de-grees. With 20 frames in between, youhave an effective zoom. Because theperspective doesn’t change, it seemssmoother.• Avoid making the target switchabout crazily – as you zoom towardssomething or orbit around it, make allthe cameras share the same target lo-cation.• At least one level if not more of Anti-Aliasing is essential, otherwise thinobjects flash on and off erratically.• Overall don’t try and create the ani-mation in one go. Use some videoediting software and include stills andphotographs to get your point across.• Adobe Premiere is good but thereis shareware quicktime editing soft-ware on the web if you look.MoviePlayer 2.51 for the Mac allowsno-cost movie editing. MoviePlayer 4

is available from Apple as a low costpart of Quicktime pro.• Blending or ‘morphing’ one stillimage to another still image usingPremiere or Director will give youseveral seconds of animation withnegligible toil.• You could use something like Di-rector for final assembly.• VR walkabouts can be more inter-esting than a flythrough becausethey are interactive – take less spaceon disk – are easier to downloadfrom web pages – can be combinedwith real photographic environ-ments.• It is becoming more commonplaceto view animations on CD on a com-puter than on VHS. So don’t worryso much about getting it onto tape.• Save animations multi-platform &write CD’s in hybrid format so thatMacs and PCs can share the fun.• An ideal size is 320x240 pixels:fits the aspect ratio of a computerscreen perfectly. If you use resolu-tion bigger than that, then it is go-ing to take longer to render and itwill display more slowly off the CD.• Save the animation sequence in‘PICS’ files on the Mac, and ‘Se-quence targa’ files on the PC; thisway, they are “in the bank” even ifthe machine crashes later. ‘PlayBack’is good at joining PICS files together.• Avoid over compression – givesyou fast delivery, but poor imagequality.• Avoid zero compression – bestimage quality, but if your flythroughis coming from a CD, it will be leav-ing out many frames in its effort tokeep up.• If you use Sound, try it severaltimes, including from CD. Set Soundto be the device which determinesspeed of display. Broken or missingimages are not as bad as broken ormissing sound.• Make your objects Location Awareso that they are ‘simple’ when dis-tant from the camera – and RebuildEach Frame. The time of rebuildingis saved by the vast reduction inpolygons and light fittings.• The ArchiCAD background remainsstatic, which makes your movie a bitsilly – loses its sense of motion. Usea clear sky, or try a cyclorama (seein the Cookbook).

Object on left is what ArchiCAD gives you.But you can change it to the one on the right.

Batch Rendering Stills

YOU can make several camera layers inthe camera settings box. Make one

layer called ‘overnight images’. Set up inthis layer a no. of camera positions in viewsthat you need. Make sure that‘Photorendering settings’ are all correct.Before you go home or to bed, start up aFlythrough, set to render Keyframes only.Turn off the screen and have a good night’ssleep.

Next morning, you have a disk full ofimages that you would never have had thepatience to wait for in the daytime.

Animation / Flythroughs

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 116: Cookbook3_1

2.13

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Tips and TricksVertically Stretchy Objects – zzyzx

ONE innovation of ArchiCAD 6.x is to permit GDL usersto provide a quick way to enter heights of objects with-

out having to open the settings box. With AC5 and withwindow/door making, you can use B for the height, so youcan make the object vertically stretchy. ‘zzyzx’ is the newway of entering heights, if you use them as the height pa-rameter, ArchiCAD will give special treatment to it.Amusingly, the GS team spelt it as ZZXYZ in the final english

language manual, but I gather it didn’t cause much amuse-ment in Budapest after thousands had been printed.

I quote some recent correspondence on the Internet whichbrought me a special email from Budapest – read on.

David N-C wrote toLaszlo Vertesi of Graphisoft-HU,Ha Ha!! Do I guess that some of your programming teamused to play the famous game ‘Collossal Cave’?? Wasn’tthat was the password to get from the Sapphire room backto the House in the Forest??? (and back down again)

Laszlo Sparing of Graphisoft-HU replied,Dear David, I was the fool who suggested this stupid namefor this standard parameter. I looked for a unique namewhich doesn’t make any old library part obsolete. Nameslike Z, ZZ, ZVALUE, ZPARAM etc. can be used anywhere inthe ArchiCAD world, but I hope, this name is strange enough,difficult to remember, and that’s why ideal for the abovegoal.

What is ZZYZX? – The enclosed picture shows you thesolution: a guide-post in California, close to the Mojavedesert. If you drive from Los Angeles to Las Vegas, you canfind it. I’ve never been in this village(?), but its name wasso strange, I made a short video about it. The picture wasdigitized from this film. So, no computer game, only a shortvisit to the city of Casinos after a conference.>Best Regards, Laszlo Sparing, CTO, Graphisoft R&D

To which I replied, firstly to the effect that I was gatheringthat almost everybody who works for Graphisoft seems tobe christened Laszlo, but secondly, I have actually driven acar through the Mojave desert from LA to LV, and althoughI didnt see that sign, I noted that there is a lot of wierdnessout there – and it doesn’t surprise me if there’s someonetrying to make their town the last in the alphabet.You see ZZYZX from 35000 feet if you fly from LondonHeathrow to LAX on a clear day.

PostscriptZZYZX is good and bad....Good in that it’s quick to enter new heights; objects viewedin the 3D window get high level hotspots and are verticallystretchy.

Bad, in that they are not stretchy in the section view, andthe height displayed in the info box is an absolute not arelative height, so if you enter a new altitude for the objectwhich is higher than the zzyzx factor, the object finishes upinverted! If you spell it wrong, your objects will not bestretchy and the reason why may elude you.

Protecting your Scripts

IF you wish to protect your scripts, you may try savingyour Library objects as Binary..... bad idea!! they lose all

parametric qualities.There is no easy fix for this within the legal syntax of

GDL. However, if you talk nicely to the Graphisoft distribu-tor in the country of your residence, and make out a casethat you are writing objects and wish to protect your code,they do have a little application that is only about 25k,that they can send you. Run it, and select the object youwish to protect, and it will do it. The object is fully para-metric, but if someone tries to read your scripts, they arepolitely told that the scripts are unavailable.

However, there is no unprotect or undo command, andyou must be sure to do it to a copy!!

My recent information is that this has not been ex-tended to AC 6.x so will only hide the 3D and 2D scripts.

The policy of Graphisoft and the GDLA is to encourageopen coding of GDL, so maybe you should not worry toomuch about hiding your GDL code.

Page 117: Cookbook3_1

2.14

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Memory Management

THESE days RAM is so cheap, there is no pointtrying to struggle along with 24 or 32 megs.

‘Slam in the Ram’, I say!However, if you are still struggling – for exam-

ple doing a long VR render and anxious to avoidhaving to run out of RAM on the last panorama –two small tips can be used. Options/Preferences/Data Safety gives you the chance to reduce thenumber of Undo steps, which normally force AC toallocate quite a lot of RAM for the purpose. Turnoff virus checkers and your desktop picture if RAMis critically short. Forget lights and shadows – youhave no hope without enough RAM. Ensure thatyour model does not have excessive polygons, tex-tures or picture objects.

Macs can use Virtual RAM, and with MacOS 8.x,this can be used efficiently. The ideal arrangementis 50% more than your real RAM. For a 64 megmachine, increase it to 96meg with VMemory. Ig-nore the ArchiCAD warning against using VM, it isofficially obsolete with OS8+.

Picture objects seems to cause memory prob-lems. A long overnight render (for a VR) may stop inthe middle of the night due to insufficient memory,even though each panorama has been safely savedto disk.

DWG 2D Import – Layers

IF you do this you find that you inherit all the AutoCAD layers which

need to be changed or at least you haveto create all new layers for your draw-ing – not to mention all the default set-tings for everything has to be reset. Thisis very time consuming. Any ideas?

Open that AutoCAD I/O config file(using a text editor) and go to the LayerConvert section. Follow the directionsto ‘automatically convert layers’.

Also, if your imported file has abunch of layers with nothing on themdo the following...

Select-All. All lines will respond and youcan move them to the 2D-dwg. Do thesame for round/wavy 2D lines. Nowclick in the text button, select-all andmove to the text layer.

Now hide those two layers. If any-thing remains visible, move it to a layerof your choice.

When this is done, go to Layer set-tings and Clear all the importedAutoCAD layers except your two newones.

• Open dwg file into ArchiCAD• Select all (make sure no layers are

locked first)• Copy• CLEAR all layers (in layer dialog box)• PASTE back all the elements; only

the needed layers remain.If you want the whole DWG file in a sim-pler layer arrangement of your ownmaking, make a layer for the 2D-dwg, aLayer for the Text-dwg. Now click in the2D lines button in the tools palette and

Tips and TricksRendering – textures

MOST of the material definitions inArchiCAD are in surfaces of a non

specific nature with attributes like col-our, transparency and reflectivity ap-plied, but no texture – for Example‘Whitewash’ and ‘Stainless Steel’. Anumber of them also include textures– for example ‘Grass’ and ‘Pine Shiny’.In renders, these untextured surfacesare prone to look posterised with ar-eas of slightly wierd shading – disturb-ingly visible in VR panoramas.

My tip here is to apply textures to mostof the surfaces you use, even when thetexture you apply is largely a little squareof nothing (just white). With Photoshop,you can introduce the tiniest bit of‘Noise’ to make sure that there is some-thing in the little white square. The bitmap can be a tiny tile as there is zerograin in the tile.

You can still set attribute like shini-ness, transparency. But the main pointis that you seem to get better play oflight over the surface.

Alpha Channels – Another tip is tohave a hard look at these. If you havea wall panel perforated with holes, thatwould be a very complicated GDL taskto model the holes, and would add tothe rendering load (all those poly-gons!!) By using a texture that is justa Bitmap with an alpha channelledhole in it, and making that into a ma-terial, you can apply the material tosolids and they look completely perfo-rated. It’s great for trees, hedges andshrubberies!Use it for wire netting,wired glazing, venetian blinds.

DWG Export [email protected] writes:

WHEN opening an ArchiCAD generated building cross section inAutoCad R14, the windows came in as blocks which could not

be exploded for editing.

Duane Valencia <[email protected]> writes:

IN light of our conversation of PURGING LAYERS, I recommend thefollowing sequence BEFORE sending out DWG’s....

1. Create Layer Set for dwg export.2. Change to HAIRLINES and no wall fills (unless they are needed).3. Export to .dwg.4. Import back into ArchiCAD w/ EXPLODE BLOCKS INTO ELEMENTS selected.5. PURGE unused layers by the method previously discussed.6. RE-export to dwg over the previous file.7. ZIP the file for emailing.DNC adds:If you export to DWG/DXF, you may be surprised to find that you have onlyexported 2D data. The trick is to be have a 3D window open. The exportfunction will then allow you to save as 3D. In fact the same applies to any 3Dexport: 3ds, Artlantis, Strata etc. In the case of Artlantis, you have to have aperspective 3D in view.Mike O’Brien adds:I have found that an apparently empty screen is often due to AutoCAD hav-ing placed objects ‘out in space’ thousands of feet beyond the building. So,everything is so tiny on the screen as to be invisible. To check for this, do a"select all" and see if there are objects (so small as to be invisible) selectedon your screen. Zoom in on them and you are sometimes amazed to see afloor plan. Then, delete the distant object that is way off to one side and isruining everything for you.

Byzanti
Highlight
Byzanti
Highlight
Page 118: Cookbook3_1

2.15

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Memory Settings

On Macs, it is easy.

MAKE sure first thatyou have enough

memory. Then ‘Get Info...’on the ArchiCAD applica-tion Icon, and enter aMinimum and a Preferredsize for ArchiCAD. Alwaysleave at least 16megsfree for System.

Activities like Printing,File sharing and Quickdraw 3D rendering takeplace in the Systemmemory, OUTSIDE of thememory used by Archi-CAD. Leave enough!

Quitting other applicationsreleases more memory! On PCs, it is more complex – beware!

1. QUIT all applications, use the Run... command from the Win-dows Start Menu, type in ‘Regedit’, and click ‘OK’.2. Double-Click ‘HKEY_CURRENT_USER’. Double-click ‘Software’.Double-click ‘Graphisoft’. Double-click ‘ArchiCAD’.3. Double-click ‘Fixed Partition’ and change value from 0 to 1. QuitRegedit.4. Run ArchiCAD briefly, then close it again.5. Repeat operation 1. and 2. again.6. Now you see something called ‘Partition Size’. Double-click.Change it to Decimal with the button, then enter an amount ofRAM to allocate to ArchiCAD. Try not to exceed 112megs.7. Quit Regedit, and run ArchiCAD. If it doesn’t run, you may havegiven it too much memory; repeat the whole operation with a smallernumber. Windows needs at least 16megs.8. If it’s gone very wrong, you may have to re-instal ArchiCAD!

GDL per se requires very little memory, but Rendering, es-pecially with shadows or with VR panoramas requires a lotof memory.

IF you start making beautiful tubular structures now that you havelearnt GDL, you will notice that rendering and shadow representa-

tions are slowed, even when you have tried hard to reduce excessivedetail and smooth curvature. At some point, ArchiCAD may even packup with insufficient memory to complete the rendering.

DXF Import 3Dby Djordje Grujic, ArchiCAD-TalkOK, StepByStep:

TURN the computer on, make coffee/tea/soft/hard drink,assume the most comfortable position. Soft music and

subdued lighting not necessary ;)• Ensure that your modelling application has exported a3D DXF (although if it’s a DWG, these instructions still ap-ply).• Start your ArchiCAD, click on the pulldown Filemenu.• Click on Open Library Part, or use Ctrl+Shift+O keyboardshortcut• In the dialog box that appears, go to the appropriatefolder, choose DXF (or DWG) as the file format, and keep‘Object’ in the ‘OpenAs’ field; if you open this as a door, orwindow, it will not work• Click on Open: A Dialog box appears, asking you for thereal world unit your DXF unit represents; this is a very com-mon place for errors, making your DXFs too big or too small.My preference is to open the object as a 3D Script, becauseI like to meddle and change pieces of it so that I can put insome material parameters, but Binary will be faster; if youhave a conversion file, use it!

• Click on OK and peruse your favourite drink if the DXF isbig.• ArchiCAD Object dialogs will appear; Click on File in thepulldown menu, and choose Save As; give a name, andsave it in a folder with an appropriate name, preferablyMyTrees, or DXFs or something like that; and make surethe folder is one of the loaded library folders. Skip requeststo load font files.• If you want to check the 3D looks of your DXF, click onthe 3D View button (lower left of the main object dialogbox). If there is any 3D elements, your 3D Script windowshould be full of text, and there should be something inthe object’s 3D window, preferably exactly what you want.• The same way as you clicked on the 3D View button, clickon the 2D Symbol button, so that you can see what youwill have in the plan. Add Hotspots if you want to.• Close the library part window. Click on the Objects in theToolbox. Your just-created object should be the defaultone.• Place it on the plan. Activate the 3D window to see it.• Finish your drink, you deserved it!

DNC adds: If you bring 3D DXF’s directly into ArchiCAD,you get the 2D view only, which probably happened to theperson to whom Djordje was answering in such detail.If you bring it in editable, you may be surprised by how bigit is, and you will find the result virtually uneditable; it could

contain thousands of lines. The DXF will have been con-verted into the more obscure GDL commands like VERT,EDGE and PGON, or loads of PLANEs.

DXF’s are big Text Files and DWG are Binary, but Macscan read them from PC disks without any pain.

Page 119: Cookbook3_1

2.16

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Remove that annoying Error message

WHEN you start up, you often get the ‘Missing orDuplicate library Objects’ message. Check ‘Load Librar-

ies’. Only load libraries that you need for that project.There are four reasons for this:1. You probably DO have Missing objects. Find them and makesure that they are in the currently used libraries. Re-load librar-ies.2. If not, then you MAY have Duplicates, and this is bad as youtake pot luck which ones of the same name load first – maybethe one you spent a lot of time writing or editing will not load– last year’s library object of the same name will load insteadand you will not notice until you have spent hours rendering.3. If not, then you MAY have greyed out libraries in the ‘LoadLibraries’ window. If you ignore this you will get the error mes-sage every time. ‘Remove’ libraries that you are not using ordon’t need.

4. If not, and you have followed the advice above, thenyou MAY have material definitions (such as Grass, Wal-nut, RedBrick etc) which depend on textures to renderbut they cannot find the library that includes textures.

When you buy an object from Internet object stores orfrom myself, you will always get that error message. Inorder to keep the file size to a minimum, the object de-veloper will have saved an archive which includes abso-lutely nothing except the object you want – thus omit-ting textures etc. When you have created the temporarylibrary folder that came with the archive, copy the newobject to your regularly used Library, then reload librar-ies and all will be good again.

Varying LineHardnessJavier Aparicio writes,We have a HP Design Jet ; we usethe colors for achieving clearworking drawings. Once our finalplots come out on tracing paper,we then make multiple copies onour blue line machine. As withhand drafting, using differentcolors accomplishes differentthings.

For example: blue prints as 1/2tone; green prints as 3/4 tone; pur-ple as 1/2 tone; red prints just shyof full deep tone; black as full deeptone; purple does not print; etc......

Objects available on the Internet

IT is difficult to write about these without one or the other accusing the author ofthe GDL Cookbook of ‘advertising’, so here is a general note without taking fa-

vours, and some names to look for.There are several systems on the Internet offering objects for download. Some of

these objects are developed by GDL developers for sale and are useful objects orutilities and cost anything from nothing or a few dollars, to more than a hundred. Itdepends on the quality. Some of the objects are in fact Libraries, or are PDF (Acrobat)objects, or collections of Texture maps – BMP or TIFF files. Some of the objects areparts of a larger collection (eg People and More) where you can download a singleobject (such as an ambulance) without having to buy the whole CD.

You will also find an increasing number of FREE downloads – of product objectscreated by or for Manufacturers. The intention is that these should be freelydownloadable so that you are encouraged to use their products.

For some examples, try these: http:// followed by:www. objectsonline.com, www.cadobjects.com, www.add-onstore.com. Look inthe www.graphisoft.com website for more details of resources on the Internet.

If you get seriously into GDL, some of these systems will act as a broker – market-ing your GDL objects for you and sending you payments resulting from sales.

Tips and TricksWriting with Acrobat

Although some applications will ‘exportto pdf’, the best printing quality comes

with the official Acrobat authoring tool.Instead of printing to PDFWriter, print in

the direction of your normal laserprinter, us-ing Acrobat Distiller as your PPD file, thenselect ‘Save Print File’ instead of actuallyprinting. Drag the resulting .PS file onto theicon of Acrobat Distiller, then select the printquality you need (‘print’ or ‘screen’). You willget the best result. It will be saved into thesame folder as the PS file. It doesn’t check tosee if one of that name already exists, it justcharges ahead and overwrites. Single pagescan be stitched into an existing pdf docu-ment, or swapped with existing pages.

Syntax errors with CALL & PICTURE

IN GDL, it is possible to save time by CALLing an object you havealready made for example, a Window object can ‘call’ a Sash, or a

Sink unit can ‘call’ a Tap. These are ‘macros’.However, if the called object is not in a ‘loaded library’ it will not be

found, and you will get error messages.The same risk applies to Picture Objects which call PICT or TIFF

files. You can use the Load Libraries command in the File Menu tohelp your project file find them. On Windows machines, omit the threeletter suffix when stating its name in the settings box.

It is most annoying that there is no pop-up menu of pictures inthe loaded library. You just have to know the name. For a special pur-pose, such as a human-figures Picture object, you could build a Valueslist of all the known names of PICT/TIFF files and make them easier toselect. With 6.5 onwards, you can make a large tiled image of all thesmall images available and then you can build a pictorial Value list,as shown in the GS window and door objects.

Page 120: Cookbook3_1

2.17

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Professional Standards in GDL

Can GDL be a profession?

AT the beginning of the Voyager Course, it’s agood point at which to ask how far we (or

others who learn it) can take GDL.

The normal architectural work you do may not bedemanding enough to need all these GDL skills, butyou can still see a purpose in continuing with GDL –to build investment objects for your office, to sell yourobjects to others, or to work with a manufacturer on aproduct range.

Manufactured products – this is a major areawhere GDL is going. Graphisoft’s Object Initiative ispromoting GDL to be a world platform for 3D objectdescription. Every manufacturer who now thinks thatit is essential to have their products in DXF should nowbe thinking about having the same range of productsavailable to ArchiCAD and AutoCAD users in the formof GDL. This will help to get their product specified.When they see the reality of Smart, Parametric work-ing, they understand the benefits of using GDL. Manyof their existing libraries can easily be adapted to GDLwith a bit of smartness on the part of the GDL author.

GDL needs a new class of user – it should beavailable in a form separate from ArchiCAD. It shouldbe available to lower paid technical staff who just wantto do GDL. If Graphisoft are serious about GDL, theycannot expect a new class of dedicated GDL techni-cians to appear from nowhere, all capable of payingthousands of dollars for the whole of ArchiCAD whenthey just need a development environment.

Metrowerks Codewarrior is available affordably topeople who want to dabble in Java, C++ or Pascal. Theprice for a single box is the same whether you areAdobe or John Doe. In the same way, it should bepossible for a computer science or engineering gradu-ate to buy a GDL interpreter and get on with the job ofproducing some excellent objects – far better andquicker than architects could make. With anaffordable development environment, GDL couldbecome the world language of 3D form.*

The GDL Alliance, formed in 2000, is committedto developing GDL as a professional activity. The defi-nition of achievement levels, the promotion of GDL asa programming language, the enabling of the creationof a new technician class of GDL writer – these are allpart of that mission.

Graphisoft have published on the main website amajor contribution to the professional GDL debate. A70+ page technical standards paper lists in detail therequirements for professional GDL writing –downloadable in pdf format.

_______

* We may get this I have great faith in GDL Technology Incwillingness to bring this about.

Developing GDL Professionally

IF you are a developer these are what youshould aim to achieve. If you are a customer,

these are what you should expect.

These are my list, but the Graphisoft technical papergoes into even greater detail.

• Structured scripting: scripts should debuggableand logical, capable of being repaired, extended, up-dated by you or by others.

• Signed and dated: scripts should identify the au-thor (if you take responsibility for your work), date ofcreation and all subsequent amendments. The filenameshould include the AC version, e.g. 60, or 65.

• Maintainable in future: should be documentedwith comments for each stage of the script.

• Economical LOD: object renders quickly withfewest polygons, and it’s quicker to write.

• Scale sensitive LOD: in 2D and 3D – smart.

• Stretchy: stretchy objects are more user friendly,but they should NOT stretch if the circumstances arenot suitable – if the objects have absolute fixed size.

• Appropriate Hotspots: intelligent 2D and 3Dhotspots make it easy for the user to pick up, identifyand stretch easily (don’t rely on the bounding box!)

• Cascading grouped parameters: these are morelogical to the user. Group them into logical groups likematerials, pen colours, 3D config., 2D quality etc.

• User Interface: your object will look more like anAPI with its extra level of quality – but this quality willtake a lot of time to design and write.

• Preview window: A 128x128 pixel image in thePreview window box will give you a nice browser icon.

• 2D Scripted: objects must not only be good in 3D,they must be quick to draw, look good in the floorplan, and be scale sensitive.

• Correct 2D and sectional lines, fills etc.: lookscorrect in plan view, and when viewed in section.

• Self scaling, self orienting labelling: versatile.

• Error correcting: prevent crashes or non appear-ance of the object. Expect the user to enter silly data,or use value lists to guarantee correct data.

• Include Material definitions: so your objects areportable between countries and versions.

• Consider 3D wireline view: should draw correctlyon a pen plotter, not just look good in 3D render.

• Property: descriptor and components – essentialfor schedules. The manufacturer needs this.

• Dimensional environment: objects must workwhen used in any measurement system.

• Libraries organised: so you can find objects –group windows, doors, stairs, macros etc. logically intheir own folders. Use sensible names that do not rep-licate existing library parts.

(The Checklist for you!! come back to it frequently)

Page 121: Cookbook3_1

2.18

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

PossibilitiesOnce you have got the hang of it, you will then usePUT&GET frequently, even for simple tasks – becauseit reduces the risk of errors, permits objects thatcannot be created any other way, allows you to gener-ate algorithmic shapes; it’s quicker and it’s neater.And it makes stealing from ArchiCAD vastly easier.

• Error correction: for almost any 3D shape suchas PRISM or REVOLVE, the stated number of XY pointsmust exactly match the actual number of XY points inthe list. So, if you build up the list of XY points for a 3Dshape in a list of PUT statements, GDL will constantlycount up for you how many points there are. Thus youcan add or subtract XY points with relative ease andnever get an error statement.

• Unmakeable shapes: You may wish to make aprism that is the web of a castellated or cellular steelbeam with holes drilled in it. You do not know howmany holes there are because the beam may bestretchy, and the number of holes in it are constantlychanging. Furthermore, you cannot define the holeswith fixed dimensions if it is stretchy. You need an al-gorithm which will define a hole, circular or hexago-nal, repeated along the length of the beam. Prism state-ments normally require a rigorous discipline of the po-sitioning of commas, and getting the number of pointsright. If you build up the outline of the prism in a PUTstatement, then follow it with repeated algorithms foreach hole (as many as you need!) these are all storedin the buffer. When you come to produce the beam, asingle PRISM statement with GET will get all thosepoints out – in the right order and with commas in theright place!

Algorithmic shapes: You can set a FOR... NEXT loopcalculating points – perhaps the points on an arch orparabola, using trigonometry. As the loop continues,these values are all stored in the memory buffer usingthe PUT statement. One easy GET, and you have aTUBE or a PRISM with a curved profile.

Quicker: Because you reduce the risk of errors byhaving your list of points added up for you, it has to bequicker – less time spent staring at an error dialog box.

Neater: Prisms and other GDL statements often be-come pages of numbers and commas that stretch so

far down the page, you might get lost scrolling up anddown trying to remember what the numbers were for.If you are in favour of structured scripting or just a clearvisual layout of the script then you can store all thepoints for prisms in subroutines. Your main script cango down, read in the points, return and produce theprism. e.g.:

GOSUB 510:!Put points for beam web PRISM_ NSP/3,0.01,GET(NSP)GOSUB 520:!Put points for flange PRISM_ NSP/3,0.02,GET(NSP)

Each prism becomes a clean one-liner. As the contentsof the buffer are Got, they are neatly separated by com-mas all in the right places so that the syntax is perfectfor the PRISM_ statement.

Stealing from ArchiCAD: On many occasions, youdo not need to write out your own list of XY points –you can draw an outline with the Filltool in the Archi-CAD environment, drag it into the GDL script windowand have a good list of XY points.

POLY2B has almost the same syntax as REVOLVE,EXTRUDE and many other 3D commands. So the listof XY points can be copied and pasted into the 3Dscript, preceded with a PUT command, and followedby the 3D command (e.g. REVOLVE) with a GET state-ment. An example later in this essay will illustrate thisprocess.

You cannot live without it!The Voyager course starts off with PUT & GET, by theuse of examples. If you are to do anything ambitiouswith GDL it is essential to learn the use of PUT andGET, and you will then use it frequently – for all thereasons given here. You need to learn Put & Get to useTUBE. It is also useful in solving difficult COONS andMESH problems.

PUT & GET (etc)ArchiCAD allows you to use an area of memory as atemporary store (or buffer) to hold numbers. Theamount seems to be related to the total amount of RAMallocated to AC.

PUTting into the memory buffer is a bit like push-ing tennis balls through a one way tube. Every timeyou use a ‘PUT item’ command, that item gets put inthe tube. Everytime you issue a GET(1) command, the

GDL Syntax – PUT, GET & NSPPUT&GET are written up in the GDL Manual, but in a way that requires ‘considerable perseverance to under-stand’.1 It does not state what they are used for, and the example given is enough to weaken the stoutest heart.Even when you ‘sort-of’ understand it, it is very difficult to work out what you could use them for.

Let’s start by saying that if you want to do anything ambitious with GDL, you have to get a grip on thepurpose and use of PUT&GET. At its simplest, a PUT statement Puts numbers (parameters) into a temporarymemory. The GET statement Gets them out again. A number called NSP constantly remembers how manyparameters are stored at that moment (Number of Stored Parameters). There’s another command called USE.Surprisingly, that can Use the numbers in the store. That’s it! Sounds easy......

1 This is the polite way of putting it, ha ha!

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 122: Cookbook3_1

2.19

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

! Name : temp! Date : Wednesday,May 5,1999! Version : 6.00! Written by ArchiCAD!MULX A/ 8.599127MULY B/ 5.354173MULZ ZZYZX/ 0.2ADD 0.012093,5.922268,0.2RESOL 36GLOB_SCRIPT_TYPE = 3GLOB_CONTEXT = 3GLOB_SCALE = 100GLOB_NORTH_DIR = 90.0GLOB_FRAME_NR = -1GLOB_EYEPOS_X = 299.259GLOB_EYEPOS_Y = 165.035GLOB_EYEPOS_Z = 1.7GLOB_TARGPOS_X = 289.381GLOB_TARGPOS_Y = 184.934GLOB_TARGPOS_Z = 1.7GLOB_HSTORY_HEIGHT = 2.9!!Slab-001PEN 1ADDZ -0.2GLOB_LAYER = "Floors"GLOB_ID = "Slab-001"GLOB_INTID = 3BODY -1cPRISM_ "Pine","Pine","Pine", 7, 0.2, -0.012093, -0.568094, 15, -0.012093, -5.922268, 15, 5.991071, -5.922268, 15, 5.991071, -3.618351, 15, 8.587034, -3.618351, 15, 8.587034, -3.196507, 15, -0.012093, -0.568094, -1BODY -1DEL 1

This is whatyour Auto-scripted 3DScript looks

like

number that has been stored longest is popped out ofthe far end of the tube. GET(3) would get 3 items.

NSP is a variable (number of stored parameters) thattells you how many numbers are stored in the buffer.GET(NSP) will empty the entire buffer.

Where do the numbers all go to when you get them?Well it depends what you are doing when you get them.If you have PUT the correct number of numbers to forma prism, then GETting them will help write out the prismcommand. Lets try a simple example with Hotspots:

PUT 1.0,2.0HOTSPOT2 GET(2) !gets 2 numbers

It is in your interest to keep emptying the buffer so thatit’s ready for the next time, so it’s better to do this:

PUT 1.0,2.0HOTSPOT2 GET(NSP) !empties buffer

If you have some numbers stored from a previous oc-casion and not emptied the buffer, then those num-bers will be fed into the Hotspot2 command, and youwill get an error, either because they are not the onesyou intended, or because the hotspot has been givenmore than 2 numbers.

The numbers in the buffer are stored with commasbetween each one. So when you get them out, theyare in the perfect condition to drop straight into a PRISMor EXTRUDE statement and produce a 3D result.

For example, if the buffer already contains 4 alter-nating X and Y points for a prism, (8 points in all) thefollowing Prism statement,

PRISM 4,0.5,GET(1),GET(1),GET(1),GET(1),GET(1),GET(1),GET(1),GET(1)

will produce a prism. But this would miss the wholepoint of using PUT and GET which is to make them doall the hard work and save a lot of typing.

This line would be a lot better and do the whole job:PRISM NSP/2,0.5,GET(NSP)

Most 3D GDL commands require you to state in ad-vance the number of points. For example, if the pointsfor a Plane are stored in the buffer then there are 3numbers for each point – the number of points in thePlane will be NSP/3.

Notes on PUT & GETSadly, you cannot store strings (text) in the buffer. thiswould be immensely helpful in property scripting andin self-labelling objects.

When you are building a command using PUT &GET, ‘PRINT NSP’ is a way of finding how many num-bers are stored – it may reveal the unexpected pres-ence of numbers you PUT previously but forgot toempty.

PUT lists are volatile and very limited. If you want to get anumber from the middle, you have to ‘empty the balls out ofthe tube’ till you get the one you want. Once you have a listof numbers from which you wish to selectively obtain ormodify numbers, you KNOW it’s time to learn to use Arrays.

Put & Get Practical:1Look at and modify an AutoscriptThis is the •first• exercise in the Voyager course, because it isvital to master this technique for most of the later exercises. First,we modify an existing library object. Then we look at how thePUT buffer works.

Modifying Library Objects: this script was first looked at in the Discov-ery Course. Make a quick slab that looks roughtly like the one illustratedhere. ‘Save special’ as a Library part, place it in the floorplan, click on it,and open as library object. Look at the 3D script.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 123: Cookbook3_1

2.20

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Put & Get Practical: 2

! Name :temp – Edited 1st stage

ADD 0.012093,5.922268,zzyzx

ADDZ -zzyzxMATERIAL matlPRISM 7, zzyzx, -0.012, -0.568, -0.012, -5.922, 5.991, -5.922, 5.991, -3.618, 8.587, -3.618, 8.587, -3.197, -0.012, -0.568DEL TOP

This is what itlooks like after

pruning.The maskings (15)

have been removedand the PRISM_

reduced to aPRISM.

! Name :temp – Edited with PUT+GET

ADD 0.012093,5.922268,0PUT -0.012, -0.568, -0.012, -5.922, 5.991, -5.922, 5.991, -3.618, 8.587, -3.618, 8.587, -3.197, -0.012, -0.568

MATERIAL matlPRISM NSP/2, zzyzx, GET(NSP)DEL TOP

Now editedusing PUT and

GETThe number of pointsin the PRISM (7) has

been replaced withNSP/2

Editing the ScriptDelete most of the rubbish, except for the ADD com-mand (an offset to relocate the ‘origin’ within the ob-ject). Make the two parameters zzyzx (for height) andmatl (for material). Change the cPRISM to a plain PRISM.

Now, after modifying it as in the left hand panel,use copy and paste to modify it further, as in the righthand panel. You can put the word PUT at the start ofthe list of XY locations; ensure that you do not changethe comma positions.

Why do this??Well now you can prove it to yourself by inserting someextra XY locations somewhere in the middle of the list.Ensure that you maintain the flow of commas. Try toavoid making the prism ‘scissor’ across itself. What youfind is that the Prism continues to work. This is be-cause the number of points in the Prism is recalculatedeach time. As the number of stored points (NSP) is theX and Y of each prism-point, then the number of prism-points must always be NSP/2.

PUT & GET analysedThis exercise shows how the PUT and GET commands work. ThePrint command displays what is in the buffer. PUT and GET willbecome a favourite technique with you, once learnt.

The use of PUT & GET is a form of single dimensional array,but seriously volatile! When you get it, it evaporates.

PRINT This routine will issue print dialogue boxes which showyou how the data is stored in the buffer. It’s a bit annoying, but keeppressing ‘Continue’, and you can see the buffer contents reducing aseach block is generated. You are unlikely to put this into a Projectplan, but if you do, put in a Project2 command for the 2D.

NSP (Number of Stored Points) shows the total number of itemsremaining in the buffer, and as you GET groups of numbers out ofthe buffer, the NSP reduces. You do not need to know how manyitems are in the buffer. NSP knows how many there are.

When you PUT a string of data in, you must separate each itemwith a comma. When the PUT buffer is used for a Prism, GDL putscommas in all the correct places when it GETs the numbers.

One thing you cannot do is to say FOR k=1 TO NSP, because thevalue of NSP is dynamically reducing in value every time you issue aGET command. But you can say REPEAT... .... UNTIL NSP=0 if youwish to.

USE( ) command enables you to use the contents of the buffer with-out destroying it, so it can be used again. It’s most useful when youUSE the whole contents of the buffer, but here we look at three num-bers at a time.

Applications: The Staircase, later in the book, is a good demon-stration of the situation where you MUST KNOW HOW TO USE theBuffer. The prism is made with a PRISM; if it is to be a parametricstair, you can use a FOR...NEXT loop to store the XYs of the steps.Then, with GET(NSP) (as above) you get the stair drawn for you.

!Skyscraper with PUT & GET

MODEL WIREPEN pcol

!Feed the Buffer with values FOR k=24 TO 1 STEP -1 PUT k NEXT k

PRINT USE(NSP) !Display values

d=NSP/4 !How many blocks to build?

!Build the blocksFOR k=1 TO d BLOCK USE(3) x= GET(1): y=GET(1): z=GET(1) BLOCK x,y,z ADD 2,2,get(1)

!Display reducing buffer contentsPRINT "x",x,"y",y,"z",z,"nsp",NSPNEXT k

END:!----------------------

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 124: Cookbook3_1

2.21

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Put & Get Practical: 3Modify Library Object –again!In this exercise, you should make •two•slabs: and then with PUT and GET, youcan make a RULED command which con-nects them. Each polygonal piece of slabmust have the same number of points.

Clean the script up as in exercise 1, andyou should have two prisms. Remove theend XYM (X-location, Y-location, Mask)point of each prism (because it is a repeatof the first point). Copy and paste the twolists of XYM values to become part of aPUT command, as in the script windowhere. Make sure that you organise yourcommas correctly. PUT must be followedby a continuous flow of numbers that areseparated by commas, but must end withNO comma.

Now replace all the 15’s for the firstprism with zero’s – this is a status value,but could also be thought of as the height.Now replace the 15’s in the second prismwith a height. In this case, I have changedthem to 12 – in RULED, this last numberis not a masking value, but means a height– in this case 12 metres.

If this figure (8) isreplaced with

NSP/6, you wouldthen be able to

add more pointsor change points

without difficulty.

Replace MaskingValues with

heights, in thiscase zero and 12

metres

Emptying the bufferThis routine will empty the buffer if youdo not know how many numbers are inthere. Use x or any temporary variable thatyou are not presently using. WHILE willonly carry out the command if NSP has avalue.

WHILE NSP DOx=GET(1)ENDWHILE

POLY2_B 11, 3, 2, 91, 0.0, 0.0, 1, 0.0, 0.111191, 1, 0.02142, 0.11125, 1, 0.035254, 0.052108, 1, 0.044696, 0.052161, 1, 0.149492, 0.015667, 900, 0.0, -136.374, 4001, 0.250528, 0.061553, 1, 0.271068, 0.066688, 1, 0.107231, -0.153264, 1, 0.0, 0.0, -1

Put & Get Practical: 4Steal this potThis exercise is a quick demonstration of ‘Stealing’ fromArchiCAD, aided by PUT & GET.

Using the Origin as a starting point, use the Fill tool to draw theoutline of a pot, making sure all your points are in the positivesector. Finish with one ‘silly’ point deep in the negative sector, soyour fill doesn’t lose points when you close the polygon and soyou can be sure where it occurs in the list. Open a new objectand drag this fill into the floating window of the 2D script. Copythe list of XY points and copy them to the 3D script. Edit them asshown here. Make a new materials parameter called matl. Deletethe last two XYs (the ‘silly’ point and the 0,0 start point) and knockoff the last comma. The ROTy command makes it stand up.

PUT 0.0, 0.0, 1, 0.0, 0.111191, 1, 0.02142, 0.11125, 1, 0.035254, 0.052108, 1, 0.044696, 0.052161, 1, 0.149492, 0.015667, 900, 0.0, -136.374, 4001, 0.250528, 0.061553, 1, 0.271068, 0.066688, 1MATERIAL matlROTy -90REVOLVE NSP/3,360,0,GET(NSP)DEL 1

You get interesting effects if you deliberatelymove the X,Y locations on one step, and thentweak the masking value from 63 to somethingelse – see illustration, right. Try it.

You don’t even have to worry about how thepolylines have been done for the outline of the pot– just copy them!

Byzanti
Highlight
Byzanti
Highlight
Page 125: Cookbook3_1

2.22

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Advanced 3D Commands

TUBE+TUBEA Mental HealthWarning!

TUBE causes more grief that most – because if you don’tget it right, you get error messages. Once you under-

stand it, though, you may find yourself typing in TUBE scriptswith confidence. My solution is to use a series of PUT state-ments first to ensure that one major source of syntax errorsis removed.

However, the way that the sectional outline is drawn inTUBE is verging on the irrational. It is supposed to followthe ‘looking from above’ rules of the other 3D elements.But then it jumps about the origin once the location pointsare entered. It works more reliably if the direction of thetube is mainly horizontal.A lot of trial and error may beinvolved to get itright. A BODY -1command beforeand after the TUBEis advisable.

Phantom Start and EndIn this script, a little ball has beenplaced at the Phantom Start &Phantom End points to illustrate theprinciple.

TUBE works out its own mitres, and wierd thingshappen if you start trying to twist the section. Forsafety, always use a mitre/twist value of zero.In this example, I have used the mysterious commandcalled BODY -1 which does an integrity check onthe 3D form. It’s a lifesaver with TUBE which canoften display irrational errors.

!Display Phantom pointsMATERIAL 0 ADD 0,0,p*7SPHERE 0.01 DEL 1 ADD 0,0,-pSPHERE 0.01 DEL 1

!TUBE Demonstration!Syntax:- TUBE n,m,mask,! section->u1,v1,s1,...un,vn,sn,! pathway->x1,y1,z1,twistangle1,...! ->...xn,yn,zn,anglenLET p=0.05 !one pixel

BODY -1TUBE 4,5+2,63, 0,0,0, 0,p,0, p,p,0, p,0,0, 0 ,0 ,-p ,0, !phantom start 0 ,0 ,0 ,0, !real start-p ,0 ,p*3,0, p*2,0 ,p*4,0, 0 ,0 ,p*5,0, 0 ,0 ,p*6,0, !real end 0 ,0 ,p*7,0 !phantom endBODY -1

Note, here, theuse of ‘p’ to save

having to type inmany zeroes.

TUBE

TUBE is a profoundly useful com-mand. You can draw a profile

through a series of X-Y-Z points in3D space, thus creating complexframeworks without having to useTrigonometry. TUBE does its best towork out a mitring solution at eachchange in the pathway.

TUBE Profile –With TUBE, you de-fine the 2D outline/profile, just asyou do in Extrude or Poly2.

TUBE Pathways – You define anumber of path points that the sec-tion must pass through – as inSweep. At each joint, GDL mitres thejunction.

Design Problems: Because theMitring and Rotational angle can beset with each joint, TUBE requires aStarting and Ending Direction, so itknows how to treat the start and endsurfaces.

So you must position a ‘PhantomStart’ and ‘Phantom End’ point. Thiswill correctly mitre the start and endof the tube object. You need to typein some examples to appreciate quitehow it works. The example here putsa black ball at each phantom point.

The Pathway is defined in XYZ lo-cations – a bit like in Sweep. In

Masking: 1=Base surface, 2=End surface, 16=Base edges, 32=Endedges, 64=Cross section edges visible

Sweep, the section changes by the same scale and angle change, and movesfrom XYZ point to XYZ point. In Tube, the section remains constant, butyou can have a different twist angle, at each mitring opportunity.

TUBE works best if the section is kept simple, and is axially centred onthe origin – like a cylindrical or rectangular profile.

One trick you can do is to lay out a floorslab in plan, save it as a tempo-rary library object, and then steal the XY locations, copying and pastingthem to a TUBE command. These can be the path or profile points for aTube. This is how the Add-On ‘Profiler’ works.

TUBE is by far the easiest way toaccomplish complex lattices like this.As TUBE only needs to know the XYZlocations of the ends, you do not needto move or rotate the cursor

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 126: Cookbook3_1

2.23

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Hot MESH Tip!

If you precede the MESH commandwith a MULy -1 then the script and

the object will be the same way up,and it is easy to enter heights (eventhough the top left corner is now atthe origin).

Notice that the grid is rectangular, but if a surface within a rectangle of the mesh is not planar, it is divided intotwo triangles, and thus can be rendered as two planar surfaces. With triangular subdivisions, ANY surface,however complex can be rendered. It could be quite useful for doing a site, but you cannot drill holes in it, orincrease local detail, or vary its outline. The MASS command (new with AC6.x) is more useful for sites, andpermits holes to be drilled.

Above – it appears invertedBelow – it now appears correctedwith the MULy -1 command

!MESH DemonstrationMESH 15,12,6,5,63, 1,0, 0, 0,0,0, 0,0,-1, 0,0,0, 0,0,-1,-1,0,0, 1,0, 1, 2,2,2, 1,2, 4, 7,6,4

!MESH Demonstration

MULy -1MESH 15,12,6,5,63, 1,0, 0, 0,0,0, 0,0,-1, 0,0,0, 0,0,-1,-1,0,0, 1,0, 1, 2,2,2, 1,2, 4, 7,6,4DEL 1

MESH

M ESH – is limited by beingapplicable to rectangular enti-

ties only.

However, it is easy to use, as youonly need to enter the Z – the height– of each point. Write the mesh outwith all points zero at first. Set themout with the same grid as the ‘n’ and‘m’ factors. Then try tweaking somepoints upwards.

MESH – Try putting in some heightsto tweak the terrain up and down.

Unfortunately, as you view it in thescript and then in the window, the po-sitions of the meshes appear inverted.The bottom left on the mesh is the topleft in the script. The top right of themesh is the bottom right in the script.It is as if you were viewing it fromupside down.

Start off with a flat mesh (all theheights at zero), then tweak thepoints up and down.

!MESH Demonstration!Syntax: MESH a_width,b_length,! m,n,mask,! z11,z12,z13,z14,..z1m,! z21,z22,z23,z24,..z2m,! ...zn1,zn2,zn3,zn4,..znmMESH 15,12,6,5,63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

Masking: 1=Base surface, 4=Side surface,16=Base & side edges, 32=Top edges, 64=Topedges & surface rough.

TUBEA

ARCHICAD 6.x has a TUBEA com-mand. It’s different from TUBE,

in that there is no Twist Angle in-volved at each junction; it is not bet-ter than TUBE, just different.

The section defined is drawn ontothe YZ plane using the same syntaxas REVOLVE (which has to be drawnonto the XY plane), and is ‘extruded’along the X axis. The section definedis the section at the mitres, so thereseems to be a danger of the actual lin-ear section changing erratically alongits length if the pathway is moving alot.

A good feature is that if you leavethe section description unclosed, itwill force the section to ‘grow’ down-wards to meet the XY plane, like awall of changing height.

PEN 1MATERIAL 'surface-whitewash'

PUT -1.0,1.4,0, 0.0,2.8,1, 1.2,1.5,1, 1.2,1.0,1profpts=NSP/3

PUT -1,0,0, 0,0,0, 2, 1, 1, 3, 1, 1.6, 4, 1, 1.6

pathpts=(NSP-profpts*3)/3

TUBEA profpts,pathpts,63,GET(NSP)

TUBEA needs phantom points just like TUBE, so the example here showsthe finished object, and the phantom points in wireline. Phantom startand stop points tell the object how to mitre its ends.

The routine uses PUT & GET, profpts and pathpts and is a classic wayof doing TUBE and TUBEA with the lowest risk of errors. This methodensures that you know where the definition of the profile ends andwhere the pathpoints begin.

Masking: 1=Base surface, 2=End surface, 16=Baseedges, 32=End edges, 64=Cross section edges visible

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 127: Cookbook3_1

2.24

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Use this method!I have evolved a fairly unburstable routine for doing COONS success-fully, and very rarely get an error using this method. Try this one out.

NOW we come to one of the most in-triguing 3D Commands of all –

COONS. I used to theorise that this meantsomething like Coordinated Network Sur-face, but when I asked Graphisoft, it turnedout to be named after a mathematician calledRobert Coons who is admired by the pro-gramming team!

By defining the XYZs of the cornersandedgepoints of a rectangular object, GDLwill try to work out all the in-between loca-tions; the whole surface will be rendered asa myriad of small triangles. It can thereforeadopt any shape.

The overall object need not be an exactRectangle – it just requires 4 corners (so thatit is ‘quasi-rectangular’), and almost anythingcan happen in between. GDL interpolatesand smooths all the points over the surface.

More complex surfaces can be made upwith tiles of COONS elements. Sometimesthe edge points are determined by math-ematical procedure, not by guesswork, sofor this you MUST use the PUT statement.

63 is the best mask, 127 reveals thetriangles, and can be written as 63+64

!COONS Demonstration!COONS Demonstration!COONS Demonstration!COONS Demonstration!COONS Demonstration!Syntax:- COONS n,m,mask,! all XYZs from Point 1 to 2! all XYZs from Point 4 to 3! all XYZs from Point 1 to 4! all XYZs from Point 2 to 3

COONSCOONSCOONSCOONSCOONS 2,2,63+64, 0.0, 0.0, 1.0, ! 1 to 2 0.0, 2.0, 1.5,

2.0, 0.0, 0.7, ! 4 to 3 2.2, 2.4, 1.9,

0.0, 0.0, 1.0, ! 1 to 4 2.0, 0.0, 0.7,

0.0, 2.0, 1.5, ! 2 to 3 2.2, 2.4, 1.9

COONSFreeform surface making

Masking: 4=1st boundary edge, 8=2nd boundary edge, 16=3rd boundary edge,32=4th boundary edge, 64=Top edges & surface rough.Even in AC_65, none of these maskings seem to work except 64. It seems impos-sible to control 3D line representation. If you make a complex surface from sev-eral tiles, the viewer can see how you have tiled it.

The example here happens to have an XYlocation of 0,0. You don’t have to move thecursor to the start of the command.

!COONS Demonstration!COONS Demonstration!COONS Demonstration!COONS Demonstration!COONS DemonstrationCOONS 3,2,63+64, 0.0, 0.0, 1.0, ! 1 to 2 -0.1, 1.0, 1.1, 0.0, 2.0, 1.5,

2.0, 0.0, 0.7, ! 4 to 3 2.3, 1.2, 1.1, 2.2, 2.4, 1.9,

0.0, 0.0, 1.0, ! 1 to 4 2.0, 0.0, 0.7,

0.0, 2.0, 1.5, ! 2 to 3 2.2, 2.4, 1.9

Inserting additional pairs of XYZ points inthe COONS makes the mesh more shapely –the more you put in, the smoother the result.

Hot Tip!Do it with PUT & GET

COONS statements can get very long,and increasingly complex. The same

applies to MASS. Once this happens thechance of errors increases.

By using a series of PUT statements to‘build’ the coons or mass, and by using anNSP statement to define the number ofpoints on the surface, you will have greaterfreedom to interpolate edge points.

I also use PUT and GET for most Prismsand Tubes – it reduces syntax errors. OK! so COONS looks terrifying. But if you take the gradual,

systematic approach demonstrated here, you can getCOONS to be useful for you. It is the only way to do smoothinterpolated surfaces in ArchiCAD.

!COONS Demonstration!COONS Demonstration!COONS Demonstration!COONS Demonstration!COONS DemonstrationCOONS 3,3,63+64, 0.0, 0.0, 1.0, ! 1 to 2 -0.1, 1.0, 1.1, 0.0, 2.0, 1.5,

2.0, 0.0, 0.7, ! 4 to 3 2.3, 1.2, 1.1, 2.2, 2.4, 1.9,

0.0, 0.0, 1.0, ! 1 to 4 1.0,-0.2, 1.0, 2.0, 0.0, 0.7,

0.0, 2.0, 1.5, ! 2 to 3 1.1, 2.2, 1.4, 2.2, 2.4, 1.9

Start with the corners only:

If you follow the rigorous discipline of Points1 to 2, Points 4 to 3, Points 1 to 4, Points 2 to3, then you will be able to use COONS suc-cessfully.

Once it works, then insert the interpo-lated points along the edge. Don’t forget toincrease the stated number of points on thefirst line of the statement.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 128: Cookbook3_1

2.25

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

MOST 3D commands require you to enter the ‘number’ of XY and perhaps Z coordinates in the object,e.g. RULED 6,63 means that there are 6 points on the shape, with a mask of 63. Similar rules apply to REVOLVE,

SWEEP and most complex 3D forms.Masking Values: All complex 3D commands use a Masking value for the whole object – usually 63. Each command hasa different way of using these. Although the Cookbook is not intended to be a total replacement for the manual, I haveprinted the keys to these values for every GDL object command. For more detail, try delving into the manual, where theyare quite well explained once you have got used to the jargon.

The difference between COONS andMASS in a Nutshell

COONS makes a skin, and requires you only to describethe edges of a surface and it tries to interpolate all the

other points – sometimes producing excellent results – butsometimes it smooths the surface in a way that you do notlike. If the surface is too complex in shape to tolerate smoothinterpolation because it has more complex detail (pointy bits),MASS will allows you to be more prescriptive about the ex-act height of points, in addition to making skins or solid ob-jects – but then you will not get the smooth interpolation.Both are difficult to write.

MASS has the advantage that you can build it in Archi-CAD’s normal project window with the MESH tool, then

copy it to GDL and edit to its final form. COONS can only bebuilt the hard way. MASS permits holes to be drilled, or pla-teaux to be formed.

MESH: How does MESH compare with these? Don’t eventhink about it! Very few things in the 3D world are perfectlyrectangular, but worse, you have to calculate every blessedpoint height in the MESH.

MASSMASS is good. MASS is very good. It is the GDL equiva-

lent of the Mesh tool in AC6.x, and forms a surfacefrom a number of X-Y-Z node locations by resolving the re-sulting surface into triangles. It is a great help for surfaceand site making.

A neat trick is to use the mesh tool direct in AC to get thebasic shape worked out, then you can edit the details of theresulting MASS script in GDL. With some thought, you couldgenerate new shapes with MASS such as trigonometrical orrandom surfaces, an interesting adventure to try some time.

After the opening lines of materials and masking, you firstdefine the XYZ nodes in the boundary. Then, if you haveany points within the surface, you define them as a series ofsmall ‘ridges’ or single points, each ending in a -1 maskingcode. As the ridges are added, the whole surface respondswith yet more triangles to ensure that the whole surface willshade. By playing with the object mask, you can also showor omit the side wall (skirt) or the base, and invoke objectsmoothing.

MASS topmat, botmat, sidemat,numbextpoints,numbintpoints,mask,skirtheight,xe1,ye1,ze1,se1,...xen,yen,zen,sen, list of exter-nal points,xi1,yi1,zi1,si1,...xin,yin,zin,sin, list of inter-nal points

The XYZ’s of Holes are considered to be ‘ex-ternal points’, but they need a minus 1 after theexternal shape, as in PRISM_holes.

The end of the definition of the perimeter ismarked by a masking code of -1, and the later XYZdefinitions are ridges or points – also each endingin a -1. The overall object masking code (here,32) can decide if the sides or bottom are to bedisplayed, or if the object is to appear smooth inrenderings.Masking: 1=Show base, 4=Show skirt, 16=Show edge linesfor base and skirt, 32=Edge lines for top are visible, 64=Topedges visible, top surface is not smooth.

SKIN (or ‘LOFTER’)

N o, sorry, SKINdoes not exist.

But it ought to. If youhad a SKIN commandwhich was a combina-tion of RULED, TUBEand SWEEP, how happywe would be. The syntaxwould be to state thenumber of points in the sec-tion, the number of pathwaypoints, and then a sequence ofSkin polygon definitions, andangle. The function wouldthen skin the results to form ashape. My friend Oleg Shmidthas written a GDL Macro calledLOFTER that does just this, although it is com-plex to use. Let’s hope Graphisoft adopt some-thing like LOFTER in a future edition.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 129: Cookbook3_1

2.26

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

RULED gives you a ‘tweaked’solid – whereby you lay out the

plan first, and specify an equalnumber of points higher than thebase (by their X-Y-Z location) andit will try to form the solid.

RULED is most useful, even thoughit lacks Polylines. You always haveto start from flat on the local X-Yplane, and define the lower lines inthe same way as you do for Extrude.Use Status values of zero (0).

The XYZ locations of the upperpoints can, theoretically be any-where. But they should still be pla-nar if possible. If the top is not pla-nar, it may not draw properly. Thesides will draw even if they are notplanar, as they resolve into triangles.

However, you can take risks withthe sides and it will subdivide thesurfaces into triangles in order tomake them capable of rendering.

The mask is 63 (as usual) if you wanta top and bottom drawn.

!RULED Demonstration!Syntax:- RULED n,mask,! u1,v1,s1,...un,vn,sn,! x1,y1,z1,...xn,yn,zn

LET p=0.05 !one pixel

RULED 6,63, p ,p ,0, p ,p*4,0, p*4,p*4,0, p*4,p*2,0, p*2,p*2,0, p*2,p ,0,

p ,p ,p, p ,p*4,p, p*4,p*4,p, p*4,p*2,p, p*2,p*2,p, p*2,p ,p,

!RULED Demonstration

LET p=0.05 !one pixel

RULED 6,63, p ,p ,0, p ,p*4,0, p*4,p*4,0, p*4,p*2,0, p*2,p*2,0, p*2,p ,0,

p ,p*2,p, p ,p*4,p, p*3,p*4,p, p*3,p*3,p, p*2,p*3,p, p*2,p*2,p

RULED

Use a 3D ‘Pixel’ size

Notice a neat trick that I have usedhere. If you can define your small-est dimension, in this case 0.05 me-tres, as an ‘object pixel’, you can usethe variable ‘p’ instead of typing outdozens of decimal figures.

This is one solid where youshould NOT close the polygon.When you get to the penultimatepoint at the lower level, start defin-ing the upper level. This is becauseRULED is usable for sheets, not onlysolids. See the CURTAINS exercisefor an example of this.

Masking: 1=Base surface, 2=Top surface (ifplanar), 4=Side surface, 16=Edges on pla-nar (base) curve, 32=Edges on space curve,64=Side edges edges visible, object rough.

SWEEP – pulls a 2D outline(defined on the X-Y plane) up-

wards through a series of pathwaypoints.

SWEEP is also capable of twistingthe 2D outline, and rescaling it as itpasses. It also attempts to mitre thejoints on the way. If the sides arenot planar, it tries to divide them intotriangles to get the best shading ef-fects.

PYRAMID – it takes the outline(using the same syntax and sta-

tus values and masking as describedas in EXTRUDE) and pulls all to onepoint at 0,0, on the Z-line.

It is useful for building a churchspire (the example in the AC 6.xmanual)

SWEEP

PYRAMID

!SWEEP Demonstration!Syntax:- SWEEP n,m,alpha,! scale,mask,! u1,w1,s1,...un,wn,sn,! x1,y1,z1,...xn,yn,zn

LET p=0.05 !one pixel

SWEEP 6,3,15,0.7,63, p ,p ,0, !Outline of section p ,p*4,0, p*4,p*4,0, p*4,p*2,0, p*2,p*2,0, p*2,p ,0, 0 ,0, 0, !Pathway begins p ,p,p*3, p*2,0,p*6

!PYRAMID Demonstration!Syntax:- PYRAMID n,height,mask,! x1,y1,s1,....xn,yn,sn

PYRAMID 9,0.3,63, 0.00,0.00,0, -0.10,0.30,0, 0.10,0.30,0, 0.10,0.40,0, 0.20,0.40,0, 0.20,0.10,1000, 0.15,0.10,0, 0.15,0.00,0, 0.00,0.00,-1

Masking: 1=Base surface, 4=Side surface,16=Edges on baseStatus: for XY locations: 0=vertical linedrawn, 1=vertical line omitted.Pyramid supports Polylines

Masking: 1=Base surface, 2=Top surface,4=Side surface, 16=Edges on base, 32=Edgeson top, 64=Side edges edges visible, objectrough.Status: for XY locations: 0=vertical linedrawn, 1=vertical line omitted.Sweep can be erratic to control – but

there are times when it is the onlysolution to a problem.

Status: for XY lo-cations: 0=verticalline drawn, 1=ver-tical line omitted.!No polylines arepossible in theoutline

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 130: Cookbook3_1

2.27

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Analytic way of writing amasking value

!EXTRUDE DemonstrationEXTRUDE 9+2,0,0,0.1,16+32, 0.00,0.00,0, -0.10,0.30,0, etc, etc....

EXTRUDE – Masking value here is1 (one) which means draw thebottom, but no top, no top or bottomedge lines. (Vertical lines arecontrolled by Status values)

EXTRUDE – Masking value here is2, which means draw the topsurface, but omit the upper edgelines.

EXTRUDE – Masking value here is32+16, which means draw neithertop nor bottom, but draw the upperand lower edge lines for top andbottom.

If you have typed in the previous EXTRUDE commands, play with different ways of writing maskingvalues. Notice that for all these examples, the same set of X-Y values are used – so you can copy andpaste, then modify.

EXTRUDE – Masking value hereis 63 above, all surfaces visible.

!EXTRUDE Demonstration!Syntax:- EXTRUDEn,dx,dy,dz,mask,! x1,y1,s1,....xn,yn,snEXTRUDE 9+2,0,0,0.1,16+32, 0.00,0.00,0, -0.10,0.30,0, 0.10,0.30,0, 0.10,0.40,0, 0.20,0.40,0, 0.20,0.10,1000, 0.15,0.10,0, 0.15,0.00,0, 0.00,0.00,-1, 0.05,0.1,900, !hole 0.05,360,4000 !holeRETURN

EXTRUDE

EXTRUDE – allows you to definean outline, and then lift it to a

different XYZ location. Simple asthat. Along with the other similarcommands, the subtle variations of-fered by Polylines, Status values andMasking values can help. With 63 asmask, the whole form is drawn. Ex-trude can give you skins or solidforms.

EXTRUDE – Masking value hereis 0 above, only the edge surfacesvisible. (Vertical lines arecontrolled by Status values)

Masking: 1=Base surface, 2=Top surface,4=Side (closing) surface, 16=Edges on base,32=Edges on top.Status: for XY locations: 0=vertical linedrawn, 1=vertical line omitted.

More about masking codesTry playing with the masking values for the sides of a Prism. This is theeasiest way to understand Masking.

Objects can have masking values too. The masking values relevant to a3D object are different for each object; for example, in a REVOLVE, youcan have the ends open or closed, whereas this would not apply to aCOONS. With MASS you have masking to decide whether to show a sideskirt or bottom panel.

Some masking codes do not work correctly. For example, with a codeof 0 for COONS, you still get edge lines. With FPRISM, you get lines evenif you apply codes of zero. Very annoying!

With EXTRUDE you have a set of choices illustrated, above.

For each GDL command you have to check here or in the manual whatthe object masking codes will do. 1, 2, 4 and 8 are usually to do with thesolid qualities (closed or open end etc); 16 and 32 are to do with linedrawing. 64 will roughen the object by drawing all the construction lines.64 is very useful for checking how the triangulation of polygons is work-ing.

You can write codesanalyticallyYou can write masking values as sin-gle numbers, or you can use themanalytically, as shown here below.It does not slow down the machineto read this, but helps you remem-ber what you put in or left out.

You can also multiply the num-bers by Boolean flags of 1 or zero,which switch the values on or off.

For example, if you wanted 27,you could write:

32*0 + 16*1+ 8*1+ 4*0+ 2*1 + 1*0

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 131: Cookbook3_1

2.28

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Polylines explained fully

POLYLINES are the very stuff of getting effectivepower out of the 3D commands in GDL. Polylines

are used in 3D and in 2D. If you make a 2D fill objectin the floor plan, complexify it with many curves, dragit into the 2D script of GDL, you will see that polylinesare used, mostly 900 and 4000.

You can use polylines in creative GDL, indeed, ifyou do not use them, your objects will have hard an-gular lines to them, and you may also be missing outon the labour saving benefits – polylines can save youa lot of trigonometrical and other calculations.

The basic idea of Polylines, Status and Maskingcodes is covered in Discovery, and if you are now aVoyager, you should by now be happy with readingmore about it them. Many of the Voyager exercisesillustrate ways of using Polylines, Masking and Statusvalues.

Here are illustrations of full range of Polylines. I hopeyou will be tempted to try them more often. The state-ments are done with PUT & GET which make it easierto insert and remove lines without causing an error.

1 Polyline 0: This is the standard prism we have already used for

examples of 3D forms. It is PRISM_which requires a masking code of 15at the end of every line, and -1 at theend. The polyline value is zero (i.e.we don’t use or need one) so it isshown here, just to prove that a zerovalue is valid.In these cases, ‘s’ is themasking factor for the prism or poly.

1

22 Polyline 100: dx,dy,100+s – is

for incremental changes frompoint to point. You do not need toknow the Absolute value of the lo-cation, only how far it is from theprevious one.

!Plain PrismPUT 0.00,0.00,0+15, -1.00,3.00,0+15, 1.00,3.00,0+15, 1.00,4.00,0+15, 2.00,4.00,0+15,!<--New points inserted here-> 2.00,1.00,0+15, 1.50,1.00,0+15, 1.50,0.00,0+15, 0.00,0.00,-1PRISM_ NSP/3,1.5,GET(NSP)

!Prism using 100:!'turtling' dy,dx!location incrementsPUT 0.00,0.00,15, -1.00,3.00,15, 1.00,3.00,15, 1.00,4.00,15, 2.00,4.00,15,

0.5,-0.5,100+15, 0.0,-0.5,100+15, -0.5,-0.2,100+15,

2.00,1.00,15, 1.50,1.00,15, 1.50,0.00,15, 0.00,0.00,-1PRISM_ NSP/3,1.5,GET(NSP)

3

4

3 Polyline 200: len,ang,200+s – is for length and angle changes

from point to point. You do not needto know the Absolute value of the lo-cation, only how far it is from the pre-vious one and in which direction.

The angles are based on those inyour 3D settings box – zero is to theright, 90 is upwards, 270 is down-wards.

4 Polyline 300: len,0,300+s – tells the line to continue in its cur-

rent direction for a stated length. Youdo not need to know the Absolutevalue of the location, only how far itis from the previous one. The direc-tion is determined by the precedingline.

!Prism using 200:!length and angle directionPUT 0.00,0.00,15, -1.00,3.00,15, 1.00,3.00,15, 1.00,4.00,15, 2.00,4.00,15,

0.8,300,200+15, 1.2,240,200+15,

2.00,1.00,15, 1.50,1.00,15, 1.50,0.00,15, 0.00,0.00,-1PRISM_ NSP/3,1.5,GET(NSP)

!Prism using 300:!tangential segmentPUT 0.00,0.00,15, -1.00,3.00,15, 1.00,3.00,15, 1.00,4.00,15, 2.00,4.00,15,

-0.2,-0.5,100+15, 0.8,0,300+15,

2.00,1.00,15, 1.50,1.00,15, 1.50,0.00,15, 0.00,0.00,-1PRISM_ NSP/3,1.5,GET(NSP)

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 132: Cookbook3_1

2.29

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Prism using 600+700!starting point, closingPUT 0.00,0.00,600+15,

-1.00,3.00,15, 1.00,3.00,15, 1.00,4.00,15, 2.00,4.00,15,

2.00,1.00,15, 1.50,1.00,15, 1.50,0.00,700+15

PRISM_ NSP/3,1.5,GET(NSP)

!Prism using 800 and 300!set tangent, draw tangentPUT 0.00,0.00,15, -1.00,3.00,15, 1.00,3.00,15, 1.00,4.00,15, 2.00,4.00,15,

-0.5,-1.0,800+15, 1.5,0,300+15,

2.00,1.00,15, 1.50,1.00,15, 1.50,0.00,15, 0.00,0.00,-1

PRISM_ NSP/3,1.5,GET(NSP)

!Prism using 1000!tangential curvePUT 0.00,0.00,15, -1.00,3.00,15, 1.00,3.00,15, 1.00,4.00,15, 2.00,4.00,15,

2.00,1.00,1000+15,

1.50,1.00,15, 1.50,0.00,15, 0.00,0.00,-1

PRISM_ NSP/3,1.5,GET(NSP)

!Prism using 1000!tangential curvePUT 0.00,0.00,15, -1.00,3.00,15, 1.00,3.00,15, 1.00,4.00,15, 2.00,4.00,15-2,

2.00,1.00,1000+15-2,

1.50,1.00,15, 1.50,0.00,15, 0.00,0.00,-1

PRISM_ NSP/3,1.5,GET(NSP)

5 Polyline 600, 700: len,0,300+s, tell the line where to start and

stop. This is useful if using relative(based on 100: and 200:), not abso-lute coordinates. The 700 is a bit likethe ‘go to jail’ card in monopoly.Whatever you put in the XY fieldbefore it is ignored – the line goesimmediately back to the start.

5

6 Polyline 800: dx,dy,800+s, defines a direction for the next line

to go in, not based on angle but basedon a relative move of dx,dy (incremen-tal xy move). The following line canbe a tangential jump (300: or 1000:)which will make use of that direction.

6

7

8

7 Polyline 1000: x,y,1000+s,This value is added to an existing

point and tells the line that is aboutto arrive from the previous point totake off, orbit and land tangentiallyon the point that is so numbered. Ifthe take off and landing line arenicely aligned, you get a very goodrounded effect. If they are not, youcan get some curious bulging effects.

8 Polyline 1000: x,y,1000+s, This often results in a hideous

number of vertical lines that spoil thelook of the object. RESOL determineshow many lines you are going to get.By changing the 15 to 13 in the twoaffected points, you will be able to re-move the vertical visible lines. Thenumber of polygons visible can still becontrolled with RESOL.

!Prism using 2000!tangential curve for!a defined anglePUT 0.00,0.00,15, -1.00,3.00,15, 1.00,3.00,15, 1.00,4.00,15, 2.00,4.00,15-2,

1.4,-120,2000+15,

1.50,1.00,15, 1.50,0.00,15-2, 0.00,0.00,-1

PRISM_ NSP/3,1.5,GET(NSP)

9 Polyline 2000: rad,angl,2000+s, This is similar to 1000 in that it

orbits with from the last point towards the next point, but only goesa specified angular distance.

10Polyline 3000: x,y,3000+s, This will arc around a previ-

ously defined centre, and will arrive asnear as possible (but not always ON)a stated XY location.

Polyline 900: x,y,900 defines centre.

!Prism using 900 and 3000!set centre, draw curve!around centre, to a pointPUT 0.00,0.00,15, -1.00,3.00,15, 1.00,3.00,15, 1.00,4.00,15, 2.00,4.00,15-2,

2.0,2.5,900+15, 2.9,1.0,3000+15,

1.50,1.00,15, 1.50,0.00,15-2, 0.00,0.00,-1

PRISM_ NSP/3,1.5,GET(NSP)

10

9

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 133: Cookbook3_1

2.30

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Tips and TricksLost your Toolbar?

WINDOWS users! There is nothing in thepreferences or display settings or in the

manual that can help you. Do you despair?

No, because you can ‘right-button’ click thegrey bar at the bottom of the ArchiCAD screenand get it back.

11Polyline 4000: r,angl,4000+s,This will arc around a centre

by a stated angl, to a stated radius.

Polyline 900: is required to definethe centre first. If drilling a holethrough a prism, you can only to anangle of 360˚. If you define the cor-ner points, you can cut pie shapedholes with an angle <360. If you wishto avoid vertical lines in the hole, youhave to put the 15-2 masking code tothe last known useful point in theprism. The point that ends with -1 isnot that one, because it is only thereto tell the prism that it has closed.

11

12

!Prism using 900 and 4000!set centre, draw around centrePUT 0.00,0.00,15,

0.0,1.5,900+15, 0,-90,4000+15,

-1.00,3.00,15, 1.00,3.00,15, 1.00,4.00,15, 2.00,4.00,15-2, 2.00,1.00,1000+15-2, 1.50,1.00,15, 1.50,0.00,15-2, 0.00,0.00,-1,

2.0,2.5,900+15, 0.9,360,4000+15

PRISM_ NSP/3,1.5,GET(NSP)

!Thin postsADD 0.0,1.5,0CYLIND 3,0.02 DEL 1ADD 2.0,2.5,0CYLIND 3,0.02 DEL 1

!Prism using 900 and 4000!set centre, draw around centrePUT 0.00,0.00,15, -1.00,3.00,15, 1.00,3.00,15, 1.00,4.00,15, 2.00,4.00,15-2, 2.00,1.00,1000+15-2, 1.50,1.00,15, 1.50,0.00,15-2, !last useful pt 0.00,0.00,-1, !last point

2.0,2.5,900+15, 0.9,360,4000+15

PRISM_ NSP/3,1.5,GET(NSP)

!Thin postADD 2.0,2.5,0CYLIND 3,0.02DEL 1

By the way, the thin poles at thecentres are there for illustration,they are not placed there by thepolyline 900:The 4000 polyline in the outlinecurves through 90˚ and uses thedistance from the start point to thedefined centre as its radius.

12Polyline 4000: r,angl,4000+s,This will arc around a centre

by a stated angl, to a stated radius. Ifit is not drilling a hole, it will workcorrectly – clockwise is negative, anticlockwise is positive. If the 4000 isused as part of an outline, the radiusis ignored (you can write zero) be-cause it assumes that the radius is fromthe point concerned to the definedcentre.

Polylines with masking or statuscodes at nodes are used in many GDLelements:

REVOLVESWEEPTUBETUBEAPOLY2_POLY2_APOLY2_BMASS

POLY_PRISM_CPRISM_BPRISM_FPRISM_SPRISM_CROOF_EXTRUDEPYRAMID

A practical use for FRAGMENT2...Most existing manufacturedproducts are provided bymanufacturers in DXF orDWG. If you are convertingthem to GDL, you can combine3 files into one by pasting eachimage to a different fragment,then having a simple value listto choose whichever youwant.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 134: Cookbook3_1

2.31

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

IF cstyl=1 THEN FRAGMENT2 1,1IF cstyl=2 THEN FRAGMENT2 2,1IF cstyl=3 THEN FRAGMENT2 3,1IF cstyl=4 THEN FRAGMENT2 4,1IF cstyl=5 THEN FRAGMENT2 5,1

!the 1 after the command is!an attributes flag.!Leave it as 1.

FRAGMENT2 in actionFor a very simple example, supposeyou had a Chair object that had 5different Styles. A style might bechosen with a number, or with avalue list.

For examples of the styles,

1=a stool; 2=chair with a back;3=chair with arms and back;4=chair with arms and back andheadrest; 5=chair with arms andback and headrest and footrest.

Now if you used a PROJECT2 com-mand, there could be an unaccept-ably long wait while the whole ob-ject had to be converted to a 3D planview before it would come up in theProject Plan window.

ProcedureFor AC5: Set a chair to each style,then view it in Plan, and send ‘3DView to Symbol’. It will go into Frag-ment 1.

For AC6: Place the object in theProject Plan. Configure to the re-quired shape, select it, then Explodeit. ‘Cut’ the resulting lines, and pastethem into the 2D Symbol windowof the GDL object. The pasted re-sult will be put into Fragment 1.

Put the lines into frag-mentsStart with style 5; now select all linesin the symbol, Cmd-T (Ctrl-T forPCs) the lines and move them all toFragment 5. Fragment 1 should nowbe empty. So now do the same forstyle 4 and so on, down to 1.

In the 2D script, include a rou-tine like this:

...is in my Human Figuremodel. It has a number ofpreset positions, such asrunning, jumping, sittingand standing. As Project2is too slow to wait for,each pose is stored as a2D symbol in plan viewand saved into differentfragments.

Under AC_6.x, it is a lot easier tohide and show the Fragments

A timesaving use forFRAGMENT2...

Advanced 2D

FRAGMENT2

FRAGMENT2 is a system of lay-ering in the 2D environment of

GDL.

All 2D lines, text, circles etc thatyou would normally draw in a 2Dsymbol are put into the top draw-ing layer, called Fragment 1. Nowtry this – open the 2D symbol win-dow, click in the toolbox on the linetool and select all, it will select allthe lines in the symbol. Now Cmd-T for the settings and you are offeredthe chance to move it all to a differ-ent layer (just like, in 3D, you canmove a roof object to the Site andlandscaping layer, if it is a slopinglawn). Select Fragment 2.

If you are using a complicatedsymbol, you might have to repeatthis process for all Text, Circle andFill objects.

Once the whole symbol is inFragment 2, you could draw anothersymbol into Fragment 1, and thenmove it by the same process to Frag-ment 3. In this way, you could buildup a whole series of quite differentdrawings or images in each frag-

ment. You can draw directly in afragment, but have to ‘choose’ thatas the drawing fragment first.

Turn Fragments on and offIn the Library part main dialog box,you will find that all fragments arenormally displayed, as a series ofdark or light numbered buttons. Butclick on the buttons (popup menusin AC5), and you find that you canselect all, or one only, or any groupof fragments to be displayed.

Normally when a 2D symbolis drawn, it is immediately disa-bled when there is an active 2Dscript. However, the two worktogether if the FRAGMENT2 com-mand is invoked.

Syntax:FRAGMENT2 fragment_number, use_attributes

• If the attribute flag is 0, the 2D fragment appears with the pen coloursand line types etc as it was drawn.

• If the attribute flag is 1, the 2D fragment appears with the pen coloursand line types etc as specified in the script or settings box.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 135: Cookbook3_1

2.32

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Fragment Tester

!Fragment Tester

HOTSPOT2 0,0HOTSPOT2 A,0 !Stretchy hotspots

IF A<0.1 AND A>0 THEN FRAGMENT2 1,1IF A<0.2 AND A>0.1 THEN FRAGMENT2 2,1IF A<0.3 AND A>0.2 THEN FRAGMENT2 3,1IF A<0.4 AND A>0.3 THEN FRAGMENT2 4,1IF A<0.5 AND A>0.4 THEN FRAGMENT2 5,1IF A<0.6 AND A>0.5 THEN FRAGMENT2 6,1IF A>0.6 THEN FRAGMENT2 7,1

!Cross hairs for joystickLINE2 A,0.02, A, -0.02LINE2 A-0.02,0, A+0.02,0CIRCLE2 A,0,0.01

FOR k=0 TO 0.6 STEP 0.1 ADD2 k,0 HOTSPOT2 0,0 LINE2 -0.01,0,0.01,0 LINE2 0,-0.01,0,0.01 DEL 1NEXT k

The 7 line fragment2routine could betightened up greatly.Here, it could be rewrittenas simply:-x=MIN(7,INT(A*10)+1)FRAGMENT2 x,1

T HIS EXERCISE takes the cover off themystery of how to use the FRAGMENT2 com-

mand. It also demonstrates the use of the stretchyproperties of ‘A’ as a joystick tochange an object.

Fragments are used a bit like youcould use Layers in 3D ArchiCAD. In3D Project window, you can click onan object, and put it into the ‘Land-scaping’ layer, or the ‘Roofs’ layer, or‘Special constructions’.

In 2D, you have layers (or frag-ments) numbers 1, 2, 3, 4, etc. up to16. Anything you draw initially getsstored in Fragment 1, but can bemoved to another fragment by you.You can display all Fragments, or anycombination.

2D symbols in the project plan aregenerated in one of three ways:

• A 2D Symbol that has been drawnby yourself, or copied and pasted from the main projectwindow into the symbol window.

• A 2D script that you have written, and that uses theparameters in the library box.

• A 2D symbol that is stored in fragments, that couldbe one of several 2D images that you may previouslyhave drawn, and which is revealed as a result of yourscript.

• A combination of these. The 2D symbol could bemainly scripted and could pull in and include differentfragments – a roof detail could pull in different tile pro-files.

OK, this example is somewhat lighthearted, but youwill find a more serious use explained in the sectionon DXF conversion of manufactured objects.

Illustrations of Fragment1: Typical view in ArchiCAD of theobject with a small value of A.2: Click on buttons in theFragments Button bar to hide ordisplay fragments.

3: Draw what you want to drawin each fragment, using the 2Ddrawing tools.

4: Select all 2D objects and movethem to the final fragment.5: In this example, there are 6different fragments, and the crosshairs are put in to show how thefragment changes as the stretchinghotspot moves sideways.

Byzanti
Highlight
Page 136: Cookbook3_1

2.33

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Play with it!This is one exercise where you need to load the example from thediskette and analyse what it does, because it is not all scripted. Foryour own example, you could draw different things, and then selectthem, and move them to the fragment number in which you wantthem to live.

Have another look at Fragment2 in the ‘Advanced 2D’ to remindyourself how it is done, and make one yourself.

When you draw different categories of 2D, you can only moveone category at a time. For example, to move a drawing containingLines, Arcs, a Fill and some Text from 1 to 2, you could ‘Select All’.You would have to do a ‘copy to Fragment 2 four times before theyall got moved. One tip is to Hide the destination fragment. In thisway, as each category of object moves from Fragment 1 to 2, it disap-pears. When nothing is left, it is all in Fragment 2.

SPLINE2.... and SPLINE2_A are usually theresult of autoscripted 2D library ob-jects, and it may take you longer thanit is worth to make parametric splinesbased on typing in coordinates. If ithad some equivalent command in3D, it would be more useful andwould be worth researching.

SPLINE2 consists of naming XY lo-cations and the angle through the linepasses at that point. Smoothing isdone automatically.

SPLINE2_A is similar, but adds theextra quality of ‘Bezier’ levers, allow-ing you to bend or distort thesmoothing action.

POLY2_A andPOLY2_B– are extensions of the POLY2 andPOLY2_ statements. Simply, theygive you ultimate control over thePEN colours, not just of the lines,but of the Fill and the Backgroundcolour to the Fill.

It may be my version of AC, butI have never got the BackGroundPen colour to work correctly inPOLY2_B, but you can make gooduse of POLY2_A.

2D Scripts using CIRCLE2, RECT2 etc will be transparent. If you wishyour 2D objects to be opaque, e.g. furniture to show clearly over a tex-tured floor, then you have to get a hold of POLY2_A, and Polyline syn-tax.

A MAJOR BENEFIT for GDL users in ArchiCAD 6.xis the Master Script.

Previous to ArchiCAD 6.0, any internal parametersthat needed to be calculated (such as the circumfer-ence and sweep angle of an arch) had to be done sepa-rately in the 2D and 3D scripts – and perhaps in theProperties script too. You might have needed severalIF statements to check for bad user parameters. If yousubsequently changed or added to these, you had togo to each script, copying and pasting. Now, with ValueLists, there is even more parsing of internal parametersto be done. A sophisticated user tends to define theirown Materials, set out manufacturer’s rules and set upArrays. The Master Script is the right place for suchhousekeeping tasks.

So you can put all this error checking and param-eter calculation into the Master Script. GDL executesthe Master script early (it reads the Values lists earlier!)and retains all the internal parameters, passing theseon to the 2D and 3D scripts as needed. This way, youonly have one place to check when you want to modifyyour error checking routines. You can make the 2Dand 3D scripts concentrate solely on their main job.

You must never write the END command here – itwill obey! So you cannot use subroutines.

(A small bug in early releases of AC_6.5 stops objectsbeing stretchy if they have a complex Master Script – ifthis occurs, move the script to the 3D Script area.)

Master Scripts

More 2D commands

Fragment Tester: Continued

740:!POLY2_A & B demonstrationPOLY2_B 9,7,4,10, 0.00,0.00,1, -0.10,0.30,1, 0.10,0.30,1, 0.10,0.40,1, 0.20,0.40,1, 0.20,0.10,1, 0.15,0.10,1, 0.15,0.00,1, 0.00,0.00,1

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 137: Cookbook3_1

2.34

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!2Dimensional Car Symbol!Demonstrate PARAMETERS12D Executive Script

!Hood Length as fraction of ‘A’IF cartyp='MiniHatch' THEN hl=0.30IF cartyp='Sedan' THEN hl=0.22IF cartyp='Jeep' THEN hl=0.26IF cartyp='Estate' THEN hl=0.22

PEN carpen

LINE2 A*0.02,0,A*hl,0LINE2 A*0.02,B*0.25,A*0.02,-B*0.25GOSUB 1100:!hotspotsGOSUB 1000:!BodyADD2 A*hl,0IF cartyp='Jeep' THEN MUL2 1.15,1.05IF cartyp='Estate' THEN MUL2 1.22,1.00GOSUB 1010:!GlassGOSUB 1020:!Roof hatchDEL TOP

END:!-------------

W E have been used to A and B controllingwidth and depth, but under AC_6.5, the GDL

Object can dictate a new value for these – a valuablefeature as A and B control stretchiness and may be thewhole basis on which the remainder of the object isdimensioned and built.

The PARAMETERS command in the Parametersscript can read a VALUES list, and as a result of theuser’s choice, change the whole object. This exampleshows it clearly.

Right: It is also possible to enjoy the pleasures of a PictorialValue List

Above: Note the extensive use of PUT & GET in thesubroutines. This is the first and most important thing to becovered in the Voyager Course. Without PUT & GET no seriouscomplex task can be achieved. Note also: Hotspots aredisplayed to reveal their ‘body hugging’ quality!

1000:!Body ALLSET FILL carfilPUT 0,0,

A*0.01, B*0.45,A/4, B/2,A*0.80, B/2,A*0.99, B*0.45,A,0,A*0.99,-B*0.45,A*0.80,-B/2,A/4, -B/2,A*0.01,-B*0.45,0,0

POLY2 NSP/2,7, GET(NSP)RETURN

1010:!GlassSET FILL glasfilPUT A*0.00, B*0.20,

A*0.03, B*0.45,A*0.49, B*0.45,A*0.55, B*0.44,A*0.61, B*0.40,A*0.63, B*0.15,A*0.63,-B*0.15,A*0.61,-B*0.40,A*0.55,-B*0.44,A*0.49,-B*0.45,A*0.03,-B*0.45,A*0.00,-B*0.20

POLY2 NSP/2,7, GET(NSP)RETURN

1020:!Roof hatchSET FILL roofilPUT A*0.13, B*0.10,

A*0.14, B*0.30,A*0.03, B*0.45,A*0.07, B*0.45,A*0.17, B*0.35,A*0.48, B*0.35

IF hl=0.3 THEN PUTA*0.49, B*0.45PUT A*0.55, B*0.44,

A*0.61, B*0.40,A*0.52, B*0.30,A*0.53, B*0.10,A*0.53,-B*0.10,A*0.52,-B*0.30,A*0.61,-B*0.40,A*0.55,-B*0.44

IF hl=0.3 THEN PUT A*0.49,-B*0.45PUT A*0.48,-B*0.35,

A*0.17,-B*0.35,A*0.07,-B*0.45,A*0.03,-B*0.45,A*0.14,-B*0.30,A*0.13,-B*0.10

POLY2 NSP/2,7, GET(NSP)RETURN

1100:!HotspotsPUT 0,0,

A*0.01, B*0.45,A/4, B/2,A*0.80, B/2,A*0.99, B*0.45,A,0,A*0.99,-B*0.45,A*0.80,-B/2,A/4, -B/2,A*0.01,-B*0.45,A*hl,0,A*0.02,0 !Hood

REPEAT HOTSPOT2 GET(2) UNTIL NSP=0RETURN

Note that thereis not a single

Dimensionhere: all is

controlled byparametersbased on A

(car length)and B (car

width)

Hotspots usethe same

points as thePoly-points on

the bodyoutline

!Parameter Script for 2D Car Symbol

VALUES 'cartyp' 'MiniHatch', 'Sedan','Jeep', 'Estate'

IF cartyp='MiniHatch' THEN PARAMETERS A=3.4,B=1.5ENDIF

IF cartyp='Sedan' THEN PARAMETERS A=4.2,B=1.6ENDIF

IF cartyp='Jeep' THEN PARAMETERS A=4.9,B=1.8ENDIF

IF cartyp='Estate' THEN PARAMETERS A=4.2,B=1.6ENDIF

Depending on theUser’s selection, the

PARAMETERScommand in this

script goes off andchanges the funda-mental parameters

of A and B – thusupdating the size

and also theHotspot locations

correctly.

Here are theresulting 2D

symbols,whose fill

patterns canbe tweaked

Modifying Parameters – 2D Car

In this casethe param-eters havelittle crossesnext to thembecause Ihave gone onto make a UIwindow andwant theparameters tobe hiddenfrom theusual settingsbox.

Byzanti
Highlight
Byzanti
Highlight
Page 138: Cookbook3_1

2.35

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

InputHard coded parameters: First, many parameters canbe ‘hard coded’ in the script. These are not user modi-fiable. You might want your script to include the ten-sile and compressive properties of steel or timber, sothat sizes in a truss can be checked by a calculation. Asthese quantities never change there is no point in forc-ing the user to enter them in the settings.

User modifiable parameters: When you create anobject, you build a list of user modifiable parametersin the main library control window – you have in ef-fect built your own dialog box which controls the ob-ject. Parameters can be dimensions and angles, num-bers and integers, materials and pens, text or fill pat-terns, or ON/OFF choices. With the User Interface (6.5onwards) it is possible to make this process even moresophisticated – prompting the user with pictures andexplanatory information.

Calculated Parameters: As the object is stretched, oras a result of some user entered parameters, certaincalculations may be made which will change the ob-ject. For example, if the slenderness ratio of a steel strutis exceeded, the diameter can be increased.

Arrays: The most interesting of the user modifiablesettings is that you can offer the user a spreadsheet-like display which they can fill with an array of num-bers, which then get used by the script.

Text File input: The GDL Script can read informationfrom a text file placed in the ArchiCAD Data folder. Ofcourse, the script needs to know how the data will beoffered. It is equivalent to the READ or the INPUT#commands in BASIC.

Hotspots: Every object has hotspots, to enable it tobe picked up or selected. But Hotspots in the rightplaces can be used to make the object stretchy, or insome cases, the user’s movement of hotspots canchange some other characteristic of the object – analo-gous to a joystick control.

Global Variables: The GDL script can request infor-mation from the current project such as the currentdrawing scale, the current pen and material settings,the storey. the most useful application of this idea is inWindow/Door design where the window can find outthe thickness, materials, radius of curvature and otherproperties of the Wall which holds the window.

REQUEST and REQ: These are similar to GVs in thatthey can obtain information from the project file.

Output3D Output: The first result of GDL is the object in 3D.This is the main purpose of using GDL.

2D Output: [1] Many objects are solely in the form of2D, such as grids, or sanitary/hospital fittings/machinesetc for layouts where 3D is not required. However,you can also get the 2D to be scripted as carefully asthe 3D, so that the 2D symbol can be used to label theobject, or even display a warning when something iswrong and needs modifying – such as warning that abeam is unsafe, or a tube is too slender. 2D can also douseful things like displaying the span of a beam thathas been stretched to fit between supports, or to printchevrons to indicate the upwards direction in an ob-ject that has been tilted.

2D output: [2] The object can also be viewed in sec-tion or elevation. this can be saved as a plotmaker file,or as other re-usable forms, such as JPEG. Or if youselect the section, Copy it, and paste into the Plan, youhave a 2D drawing which can now be grouped,merged, edited, or saved as a DXF. Perhaps you needit in DXF to drive a cutting machine, or simply for send-ing to your engineer or fabrication shop.

Text Output: The GDL script, while executing, canbe made to open a text file, write data to it and close.This could be a table or listing of useful data, such as acutting schedule for a trussed rafter.

Properties/Components/Descriptors: This is an-other way of printing out listings and is more powerfulthan the text file, as it can include plans, section/el-evations or 3D views of the object for the purpose ofcreating schedules or databases.

How do GDL scripts get information withwhich to build 3D and 2D objects?

Programming Concepts

Input / Output

Tips and Tricks: ‘3D View to Symbol’

This command has been lost in ArchiCAD 6. Never mind!If you want a simple 2D Symbol, give the object a 2D

script of PROJECT2 3,270,2. Drop the object into the ProjectPlan. EXPLODE it. Select the Lines in the exploded 2D sym-bol, Copy them. Open the 2D symbol window, and Paste it.It will be in the right place and scale, and if not adjust it sothat it is in the right place relative to the object’s origin.Add some 2D Hotspots. Replace the PROJECT2 commandwith FRAGMENT2 ALL,1.

Oddity of PUT & GET

Although you clear the buffer if you GET all the numbers, you can write all your PUTs in the Master script,

and they are available to BOTH 2D and 3D scripts. You canGET(NSP) in both without causing an error.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 139: Cookbook3_1

2.36

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

do not go any further into the use of arrays until youhave mastered these essential commands.

Declaring an Array: with DIMYou first declare the size of the array with a DIM com-mand. If the array is to be a single list of 16 numberscalled ‘eavht’, and you have another 2 dimensionalarray with 10 numbers for X, Y, and masks for a floorslab, you would write (early on in the Master or 3Dscript),

DIM eavht[20],xym[16][3]

The idea of writing a few more than the number youwant is that it doesn’t do you harm to reserve morememory in case you decide to use more numbers inthe future. 2D arrays go in the order [rows][columns]so xym[16][3] is 16 rows of numbers, 3 columns wide.

Using an ArrayOnce the array is filled, you can use the numbers inthe array as variables, such as:- ADDz eavht[8], whichwould lift the cursor to the height of the eighth eavesheight in your list, say for placing a gutter. To go to thethird point on the floor slab, you could write:-

ADD xym[3][1],xym[3][2],0

In certain cases, such as with PRINT or PUT, you candump the entire contents of the array in one go. e.g.PRINT xym, or PUT xym, but I have tried and it willnot work directly with PRISM because it doesn’t insertcommas. What will work though is:-

PUT xym !fill buffer with array contentsPRISM NSP/3,0.2, GET(NSP) !do it!

Limits to arraysPUT and GET have no limit to the quantity of numbersthat you can place – I have tried 1000, 10000, even100000 without trouble; arrays are declared first with anumerical DIM statement, declaring their size e.g. DIMvx[32]. It is not possible to declare an array with a vari-able, e.g.: pn=32: DIM vx[pn], in which the quantity inthe array results from user input or an earlier calcula-tion. However, it is possible to write it so that the usercan edit small arrays from within the Library object set-tings box. It is very powerful.

For anybody with past programming experiencewith BASIC, it is annoying that GS use their own wayof writing arrays, using square brackets. xym(16,3) ispleasanter to read and write than xym[16][3].

Warning: Objects with arrays in the scriptwork fine, any time, but if they have arrayparameters (as left) they will not work withthe GDL Object Web Plugin.

Arrays – a table of numbers

ANYBODY who has programmed in BASICwill welcome the power of Arrays. An ‘array’

is just a row or a table of numbers or strings (alpha

characters).Imagine a single row of 16 numbers in a spreadsheet

– The whole row can be called ‘pt’.This is a one di-mensional array (e.g. DIM pt[16]). The third number inthe row is called pt[3] – and so on, and so on, usingsquare brackets. Now just imagine a spreadsheet tableof 4 columns and 16 rows (DIM pt[4][16]). This is a 2dimensional array. These numbers are stored inmemory. A statement like LET eavht= pt[4]*1.723 willmodify the fourth item in an array.

The essential difference between an Array and thePUT & GET system in GDL is that an Array of numberscan be played with – manipulated, sorted, aggregated,swapped, multiplied, used again and again.

Note that you can also use arrays to store Strings. Ifyou use strings, you cannot use them with PUT & GET.

With PUT & GET, you PUT numbers into a tempo-rary memory buffer, somewhat like a one dimensionalarray; but you can only get them out in the order theywent in, and the moment you GET them out, you havecleared the buffer – it is emptied! Lost!

The array can be filled from a series of numbersgenerated in the script – for example, by a routine thatworked out the outline of a curved window. With AC-6.x, the script writer can set up a single or 2D arraythat is visible to the user in the Library settings dialogbox, and the user can edit it.

When I first read about PUT and GET, I couldn’tthink of a use for them. After a few models, one real-ised that they were an essential aid for everyday use(with prisms, extrude, tube etc.) and one could notmanage complicated 3D modelling without them. Youmay feel the same way about Arrays. Once you get thehang of it, you may wish to use arrays with many ofyour objects.

It must be said before you read on – unless you havea totally confident command of the use of PUT & GET,

Arrays

Arrays can be 1-dimensional (like this), or can be2dimensional, like a table of numbers. Arrays cancontain strings (alphabetical characters.)

Programming Concepts

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 140: Cookbook3_1

2.37

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Array Tester!Master Script

PUT 0.0, 0.0, 1, -1.014023, 0.0, 1, -1.978175, -1.018731, 1, -3.000176, -1.018731, 1, -3.000176, 2.992141, 1, -1.978175, 2.992141, 1, -0.973213, 2.180441, 1, 0.52862, 2.180441, 1, 0.52862, 0.813158, 1

DIM x[20],y[20] !Declarenump=NSP/3 !CountFOR k=1 TO nump !Fill x[k]= GET(1) !array y[k]= GET(1) nul = GET(1)!throw away NEXT k

Arrays in action!Array Tester!2D Script

HOTSPOT2 0,0FOR k=1 TO nump PUT x[k],y[k] HOTSPOT2 x[k],y[k] CIRCLE2 x[k], y[k],0.1 NEXT kPOLY2 NSP/2,7, GET(NSP)

I don’t know what this structure is, perhaps it’sa garden structure,but it perfectly exemplifies the

use of arrays – when you have a number of X-Y posi-tions which are needed repeatedly for different pur-poses. Open a new object, make one parameter onlyfor Material matl.

Master ScriptThe list of points here were first generated by makinga 2D Fill, dragging it into a 2D script window, thencopying and pasting the list of numbers into the Mas-ter script. The routine uses PUT to store all the pointsinto memory. Then two arrays are declared – there isone for the X points and one for the Y points. Becausethe numbers are all stored in memory, nump is easilycalculated (the total of points). The FOR... NEXT loopthen places all those numbers into the array for per-manent storage. The status code of 1 at the end of eachline (that came over from the POLY2B) is simplydumped as it is not needed for the 3D object.

[By the way, this must be a point to point polygon, nota POLY2_B that uses Polylines like 900 and 4000.]

3D ScriptOn the ground floor, the ADD command uses the ar-ray to place the cone columns. Then it uses the samearray to draw the floor and roof slabs. Having usedGET, the memory buffer is empty, so the buffer is re-filled by a quick FOR… NEXT loop that runs throughthe array PUTting the numbers again. We add a hori-zontal rail and number each column in the structure.

Arrays with StringsThis little string array sends a message to your parrotin the morning – and this is the answer you get!

The handrail is aTUBE command, so

an extra two numbersare PUT for the

phantom points.

This routine definesthe style of the 3D

text. Sizing is basedon ACTUAL size

Fill the memorybuffer again

Now use all thosepoints in memory to

ADD, to get to theright place to plant

the numbers

The 2D script can alsouse the array – for

drawing the outline ofthe slab, and plantingcolumns and hotspots

!Array Tester!3D Script

!Fill the Memory bufferMATERIAL matlFOR k=1 TO nump PUT x[k],y[k] NEXT k

!Build ColumnsRESOL 8FOR k=1 TO nump ADD x[k],y[k],-0.1 CONE 1.3,0.05,0.10,90,90 ADDz 1.3 CONE 1.3,0.10,0.05,90,90 DEL 2NEXT k

!FloorADDz -0.1PRISM NSP/2,0.1, USE(NSP)DEL 1

!RoofADDz 2.4PRISM NSP/2,0.1, GET(NSP)DEL 1

!Connecting BeamFOR k=1 TO nump PUT x[k],y[k],1.2,0 NEXT kFOR k=1 TO 2 PUT x[k],y[k],1.2,0 NEXT k

TUBE 2,NSP/4,63, 0,0,901, 0.03,360,4001, GET(NSP)

!Node numbersRESOL 9DEFINE STYLE 'arrtxt' 'Arial',300,1,0 SET STYLE 'arrtxt'

FOR k=1 TO nump PUT x[k],y[k] NEXT k

!Print all the numbersFOR k=1 TO nump ADD x[k],y[k],2.6 TEXT 0.2,0,k DEL 1 NEXT k

DIM dncstring[10]

dncstring[1]='hello'dncstring[2]='how'dncstring[3]='are'dncstring[4]='you'dncstring[5]='today'dncstring[6]='my'dncstring[7]='fine'dncstring[8]='feathered'dncstring[9]='friend'dncstring[10]='?'

DEFINE STYLE 'arrytxt' 'Arial',2,1,0SET STYLE 'arrytxt'

!Write out correct stringlongstring=""FOR k=1 TO 10 longstring=longstring+dncstring[k]+" " NEXT kTEXT2 0,0,longstring

!Write out scrambled stringlongstring=""FOR k=1 TO 10 n=INT(1+RND(9.99)) longstring=longstring+dncstring[n]+" " NEXT kTEXT2 0,-2* 1.1* A_/ 1000,longstring

Uses aRandom

number – butthis must bean Integer,

and must notbe zero

We fill the array withsome strings, Define a

Style, then concatenatethe strings into one

sentence, and print it outas a text block. The

parrot does the same butin a random order

Whenever you needto refill the buffer,this is the routine

to use

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 141: Cookbook3_1

2.38

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

BINARY: is what all Binary converted Library objects begin with, and either have a value of 3,

2, 1 or 0. There is no use for the command in yourcreative GDL. Binary objects are not editable (exceptfor the odd MUL or ROT in front of them, and therecannot be parameters for them, except for the MUL orROTs.

CALL: brings an existing library object in, to workas part of your existing object, and you have to

opportunity to use the default or new parameters.Whenever you make an Autoscripted library object thatinvolves nesting already-made objects, the CALL com-mand is used.

It is not a good idea to use CALL in creative GDLobjects. It slows the system down (having to read infrom disk) but more importantly runs the risk that ifyou change the name of the called script or object, oreven one of the parameter names of the imported ob-ject and then forget to update the new object, the newobject will then have a chunk missing.

One of the whole points of creative GDL program-ming is that you can have smart, integrated objects thatdo not rely on making CALLs. It is better in my mind,to copy and paste the script of the other object intoyour new object, as a subroutine, and make sure thatparameters you wish to use match up with the ones

you have already set up. Or write a list of parametersat the beginning of the subroutine.

It is most useful when you make a range of objects,and some small component is repeated many manytimes, such as a door handle, or a sink tap; so that adoor or a sink unit can call in a handle or a tap script.The CALLed file might not even be a full object in itsown right – it may be saved as a GDL Macro, a chunkof pure 3D script which can be read in.

Encapsulating: If you wish to use the CALL command,the quickest way to get the scripting correctly writtenis to view the old object in the Project Plan, select it,Save-Special as a library object and you then get theCALL command perfectly autoscripted for you byArchiCAD, with all the parameters correctly spelt. Copyand paste that to your new object, and use it as a sub-routine. I call this process ‘encapsulating’ the object.

GDL Macros

Keeping the macro within your existing 3D scriptAn even simpler use of the concept of theMacro is touse a subroutine inside a script that can be used againand again, with different parameters being passed toit. The exercise ‘Kitchen Chair’ is an example of this,whereby the conical wood turned elements of the chairare all based on one macro.

Here is a tiny example. Supposing you want a Squaresectioned solid that always behaved like a Cylinder –that rises axially about the Z axis. I call it a Squilinder.

100:!SquilinderPRISM 4,hit, w/2,w/2, -w/2,w/2, -w/2,-w/2, w/2,-w/2RETURN

LET squilinder=100!.....!.....w=0.3: hit=0.85GOSUB squilinder ADDx 1.0GOSUB squilinder DEL 1

In this case it is a subroutine, and you just pass pa-rameters to it. To make things smoother, you even ap-ply the name to the subroutine.

Two Golden Rules for organizing your library with macros:• Macros are better as Objects (.ISM files), not as purescripts – thus they can have their own small parameternames, preview image, 3D and 2D script, which makes itmuch easier to write and review them because you cansee them in 3D as you make them.

• It is better that many objects (such as a lot of sink units)should call on a few macros (such as taps); this is moreefficient than a few objects calling on many macros (suchas a lattice repeatedly calling macros for the members).

MANY OF GRAPHISOFT’s Library objects –windows, kitchenware etc – make use of

macros. A macro is a script or object that is usedto often that it is stored as a special component.

An example is a window sash, that could be calledfrom the Library to join a whole variety of window de-signs. It saves having to write it all out again. The sameapplies to a kitchen tap – which can be called to avariety of sink unit configurations. AngleRod (in theVoyager Course) could be used as a macro in a cableor spaceframe structure.

Macros can be used with the CALL command. They

may bring their own parameters (that they were firstsaved with) or may be told to adopt new values in thecurrent script.

CALLing the Macro from another script/object

Save the left hand routine as an object in its own rightwith only hit and w as parameters. Now your currentscript can get it from the library with a CALL command.

!Squilinder macroPRISM 4,hit, w/2,w/2, -w/2,w/2, -w/2,-w/2, w/2,-w/2

MATERIAL “whitewash”CALL squilinder PARAMETERS

w=12”,hit=2”-10”

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Cross-Out
Byzanti
Text Box
better to use subroutines
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 142: Cookbook3_1

2.39

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

GDL requires a 3D spatial awareness, and an essential minimal knowledge of Triangle and Circle Geometry. Architects usually have no

problems with the former, but may need help with the latter.

Let us assume that you are familiar with basic Arithmetic and Algebra. As aVoyager, you have a working knowledge of BASIC. However, there are 3D prob-lems which require considerable analysis before you begin, and I find these pagesuseful for myself when tackling new problems. Sketch onto paper the essentialgeometry of the problem. Then plan the solution.

Maths Primer

Right Angle Triangles

Trigonometry made easy: you need a basicknowledge of the right angle triangle – in fact

all you need to know is the motto SOH CAH TOAso that you can always calculate the characteristics ofa triangle from minimal information. If you don’t knowthis already, learn it by saying it to yourself as a mantrawhilst in traffic queues.

Coordinate Geometry is based on Pythagoras.

The distance between any two points is simplySQR((x1-x2)^2 + (y1-y2)^2). This works even whenpoints have negative values. The gradient ‘m’ of a lineis =(y1-y2)/(x1-x2) – the same as the TAN of its angle.

The formula for a straight line is y=mx+c, orax+by+c=0. If two lines intersect (straight or curved),you can derive a simultaneous equation – both ‘y’ val-ues equal each other.

The gradient ‘m1’ of a line equals (-1)/(m2), m2being the gradient of its perpendicular line – or youcan say that m1*m2=(-1).

Remember: ‘SOH CAH TOA’SIN(angl)=Opposite/HypoteneuseCOS(angl)=Adjacent/HypoteneuseTAN(angl)=Opposite/Adjacent

Pythagoras says (many years ago): Hypoteneuse squaredequals sum of the squares of the other two sides. In otherwords, Hypoteneuse=SQR(Adjacent^2 + Opposite^2)

Nostalgia tripSuddenly all those distantmemories of Maths you didback at school can be dustedoff and made useful.Isn’t it marvellous!!

0°30°270°

270°

90°

180°

60°

Rotation in the Geophysical world

180°

90°

Rotation in the Mathematical world

Rotation Directions

The Geophysical world works with the verticalnorth (0°) at the top and east (90°) is in a positive

direction clockwise. West is either –90° or +270°, de-pending on how you travel there. The hands of a clockwork that way.

In Mathematics, the horizontal is Zero°, and an an-gle grows in the anti clockwise direction, so that 90° isfacing up the page. This is how the diagram for thecamera works in 3D Projection Settings, in ArchiCAD.

In GDL, You can use angles in either the mathemati-cal or geophysical sense, as long as you remain con-sistent in your interpretation.

When you talk about the azimuth of the Sun rela-tive to the site and entering site survey information,this causes confusion. But at least, for GDL use, I hopethis is clear.

Which way toROT??

Consult these pages! You are now looking at the set of pages that I use myself most frequently. The maths Tips andTricks are useful, and some of the formulae for circular and parabolic curves are totally original material.

Hypoteneuse

(The side) Adjacent (to the angle)

The RightAngle

angl

(The

sid

e) O

ppos

ite

(to th

e an

gle)

Byzanti
Highlight
Byzanti
Highlight
Page 143: Cookbook3_1

2.40

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Irregular Triangles

IRREGULAR triangles can be analysed by breakinginto small right angled ones and using SOH CAH

TOA. The SIN and COS rules will enable you to deriveall the facts from any three pieces of information.

Powers can be written with two asterisks e.g.num**2, or as num^2 and square root is SQR(num) ornum^0.5. Cube and other roots would be written asnum^(1/3).

Any three points in space, no matter how irregu-larly disposed can be joined up to form a planar (flat)triangle; a planar circle can be drawn through thepoints. ArchiCAD’s circle tool provides a means of find-ing this centre. The calculation is more difficult.

An Isosceles triangle has two equal sides and twoequal angles. The angles of any triangle add up to 180o.

From this diagram you canwork out any triangle fromany three known facts

A circle can always be inscribed in an irregular triangle.From this, several right angle triangles can be derived.SIN Rule: a/SIN(A)=b/SIN(B)=c/SIN(C)=2*RCOS Rule: a^2= b^2 + c^2 – 2*b*c*COS(A)Hence, if you know the sides,Angle A=ACS((b^2+c^2-a^2)/(2*b*c))Area=(length of any side)*(height relative to that side)/2

b

side cangleA

C

R

a

B

!3D Pythagoras DemonstrationMODEL wirePEN 1x=1: y=2: z=3BLOCK x,y,z

!Calculate length of diagonaldiaglen= SQR(x^2 + y^2 + z^2)

ROTz ATN(y/x)ROTy ACS(z/diaglen)CYLIND diaglen,0.02DEL 2

3D Pythagoras

ONE FACT that I worked out for myself, but mustbe in a book somewhere, and which I have used

for some time, is Pythagoras’ Theorem applied to 3D.The diagonal of a cuboid shape is the Square Root ofthe sum of the squares of the Length, Width and Height.diaglen=SQR(x**2 + y**2 + z**2) [can also be written asSQR(x^2+y^2+z^2) ]

The script here demonstrates it fully. Thus if youhave a linear object arcing around in 3D space (likethe arm of a crane) you know its length and its decli-nation angle from the simple formulae demonstratedhere. (Declination is the elevational angle from verti-cal).

From this theorem, you can work out the reverse ofthe 3D Pythagoras, using Trig. If you know the cranearm's length, its Rotational angle, and its Elevationalangle (from horizontal), you can know its X,Y,Z loca-tion in space.

In the diagram, ‘rotang’ is the rotational angle of thearm from the Y axis, and elvang’ is the elevational an-gle from flat on the floor. ‘clen’ is the length of theCylinder. Hence,

Tips and Tricks – Maths bits

YOU frequently need to ‘toggle’ or convert numbers andflags especially when Boolean choices are involved.

• To find out if a number is odd or even :-IF INT(item/2)=item/2 THEN even=1 ELSE even=0or IF item MOD 2=0 (it is even)

• To find out if number is Negative or Positive (& set a flag):IF item<>0 THEN flag=item/ABS(item) ELSE flag=0(makes 1 or -1, or 0 if item is zero)

• To force a number to be positive: item=ABS(item)• To force a number to be nearest even number

item=2*INT(1+item/2)• To generate 1 & zero alternately in a loop (stepping 1)

flag=2*FRA(k/2)• To make any number into 1 (if real) or 0 if zero.

IF item<>0 THEN flag=item/item ELSE flag=0

• To turn 1 & 2 into 0 & 1• To turn 1 & 2 into -1 & +1• To turn 0 & 1 into -1 & +1• To turn 0 & 1 into +1 & -1• To toggle values of -1 & +1• To generate 1 or 0 randomly• To toggle values of 0 & 1• To make 0=0, and 1,2,3 etc=1• To make 1 & -1 into 0 & 1• To make -1 & 1 into 0 & 1

(item-1)

(item-1)*2-1

item*2-1

(item*2-1)*(-1)

item*(-1)

INT(RND(2))

(1–item)

INT(x/(x-0.1))

-(item-1)/2

(item+1)/2

z

x

y

• X=SIN(rotang)*COS(elvang)*diaglen• Y=COS(rotang)*COS(elvang)*diaglen• Z=SIN(elvang)*diaglen

Byzanti
Highlight
Byzanti
Highlight
Page 144: Cookbook3_1

2.41

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

All triangles can be drawninto a circle. It is useful toknow that in a right angletriangle, the hypoteneuse isalso the diameter of anenclosing circle, and itshalf way point is the Circlecentre.

Circles

THERE will be many situations where the object youare making is circular (curved truss), or parts of it

trace a circular path through space (a swinging arm).In coordinate geometry, the Formula for a Circle isR^2=x^2 + y^2.

The diagram displays the terminology of parts of circlesused in many of the worksheets in the CookBook.

If you are distributing things in a circle (e.g. mullionsin a bay window), you usually know the centre, theradius and the angle in which you are pointing.

Above: You may know the X and Y location, but needto know the Radius and Angle – perhaps you have adiagonal cylindrical tube which must connect the twopoints. Only works if 0,0 is the centre.

Above: On many occasions, you need to derive thefactors of Circles and their inscribed triangles whenyou only know the CHORD length and the BULGE(segment height).

These formulae above can be juggled about.If you already know Radius and A then: angl=ASN((A/2)/radius)In which case, B, the Bulge can be found:B=(A/2)/TAN(90-angl/2) OR B=rad-rad*SIN(angl)

If you know Bulg and angl, then radius is found:rad=B/(1-SIN(angl)

Distance along an Arc whose angle is angl: dist=2 * PI * rad * angl/360Distance between points whose angular separation isangl and radial distance is rad =2*rad*SIN(angl/2)

If your origin is at the centre-base of this chord, thelocations for x and y at angle k from the vertical are:x=rad*SIN(k), y=(B-rad)+rad*COS(k).

Polar to Cartesian conversion

If you are starting from thevertical, moving clockwise

If you are starting from thehorizontal, moving anti-clockwise

If you know rad and angl, theheight of the Bulge israd-rad*COS(angl)

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 145: Cookbook3_1

2.42

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Points to remember:• PI (π) exists as an constant in GDL. Useful...• There are 360 degrees in a circle. But you can safelyissue commands like SIN(angl) when angl is a numberlike 535º (greater than 360) and GDL will not turn ahair (it will return a result of SIN(175)).• A circle’s circumference is 2*PI*R, or PI*diameter• You can make Ellipses by using the MUL commandto shrink or stretch Circular forms into ellipses.Besides the matter of geometry, you need to knowsome of the arithmetical functions offered by GDL, suchas ABS( ) and INT( ), MAX( ) and MIN( ), MOD andFRA( ).

If you are handy at deriving things from first principles and thinking logically, allyou need really is Pythagoras and SOH CAH TOA !

Arch Forms

Ihave developed formulae which can be usedfor raised arches or hanging cables. (See the

‘Arches and Waves’ exercise in Voyager). Theparabola is the perfect form to display the effectof gravity on a linear pathway.

An arch or cable with self weight describes aParabola distorted into a Catenary, which isbased on hyperbolic trig (COSH & SINH) andcannot be covered in this edition.

The formulae below describe several way sofbuilding arches and forms using mathematicalcurves.

Flattish Round Arch(less than 180 degrees of sweep):radius=(span/2)/SIN(2*(90-ATN((span/2)/height)))

Z=radius*COS(ASN(x/radius))-(radius-height)

(Circles and ellipses are much better done by a radialmethod. For an ellipse, you can use the above,

but add, LET Z =Z*height/(span/2)).

The cartesian formula for a Circle is R2=x2+y2 so youcan use y=SQR(R*2 -x*2) for short circular forms.

Gothic ArchFor each side, you can run a profile of the doorwaywith REVOLVE and use a Cutplane to cut it at the ver-tical axial centre. Or by using TUBE you can do it inone sequence.

angl=(90-ATN(height/(span/2)))*2radius= height/SIN(angl)

SIN Wave ArchZ=height*SIN(X*180/span)

Parabolic ArchZ=height–(4*height/(span^2))*X^2

dydx=(8*height/(span^2))*X (‘dydx’ is TAN of theslope at point X – if you want to attach panels.)

For this, you start a FOR…NEXT loop starting fromspan/2 one side of zero and finish up span/2 the otherside of zero – using PUT to store all the XYZ values.Then feed them to a TUBE command or to whateveryou are building.

Inversely, X=SQR((hit-Z) / (4*hit/(span^2))) worksin the Z direction but you get an over flow if you goclose to the peak of the parabola.

Elliptical Arch... is done by applying MULz to a Circular arch, but thismay distort the section of the tubing. Use REVOLVE orELBOW to draw the arch.

If you are doing a ‘Swing the Cat!’, you can multiplythe vertical direction by a factor, to achieve the sameeffect and avoid distortion of the section.

A true Parabolicarch is more

elegant than a SINor circle. It is close

enough to aCaternary for

almost any GDLpurposes.

Ways of avoiding TrigonometryUsing the TUBE or the SWEEP command, it is possibleto link two XYZ locations with a cylinder without need-ing to know the angle and length.

If you are distributing objects in a circle – like mul-lions in a curved window – you may not need to do apolar to cartesian conversion. Just keep swivelling thecursor, and push out an object, delete back, then swivelto the next location. e.g.

ROTz ang: ADDy R: GOSUB 250: DEL 2

This will make sense when you try an exercise (eg theCircleGrid or the Tempietto).

Swing the Cat!:This technique is explained in some exercises (e.g. Long Handrail, Helix). Trace out acircular path, store them and then send the list of points to a TUBE.

If you use SWEEP, the path has to start from 0,0,0 which may affect some of your arch calculations.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 146: Cookbook3_1

2.43

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

The Binary System– for VoyagersOnly read this if you want to...

Using Binary to chooseStatus Values – 0 to 1IN 2D GDL, you only need to decide whether a line is to be drawnor not. Therefore there is a simple choice, Yes or No. In the examplehere, Status codes have been used to define whether lines are to bedrawn or not. Zero (0) means draw the line, and one (1) means donot draw it. Even when mixed with Polyline commands such as 900and 1000, you ADD one or zero to achieve the same effect.

Using Binary for MaskingValues in Prisms – 0 to 15IN 3D Prisms, you need not only to know if lines are to be drawn,but if surfaces are to be visible. This has 16 possibilities – from 0 to15. Here is a table of all the numbers up to 16 so you can see howthey are made; these cover all the masking values for the sides ofPRISMs. In this case, [1] means do the action, and [zero] means donot. So 8 means draw the face, 4 means draw the top line, 2 meansdraw the side line, and 1 means draw the bottom line. Any combi-nation of these can be expressed with a number from 0 to 15.

It is puzzling that with Status values for profiles in Extrude andTube, zero means draw the line, but with Masks, the opposite ap-plies. Graphisoft! – why??

Binary is a numbering system based on 2, rather thanten, which is what we use in normal life – because wewere born with ten fingers. With decimal, we have todevelop a notation for all the numbers between 0 andten, hence 1,2,3,4 etc. With Binary, you have a simplechoice – 0 or 1.

Binary is quite efficient at dealing with CHOICES –which could be simplified down to YES or NO situa-tions. Do you draw a LINE? If yes, it’s *zero* if no, thenit’s *one*. That is how status codes work in 2D entitiesin GDL.

If the base is 2, then to write a number in Binary,you use a series of 1 and 0’s . For example, the number3, being the sum of 2+1 is written as 11. The number 9is made up of 8+ 0+ 0+ 1, so it is written as 1001. 147 is128+ 0+ 0+ 16+ 0+ 0+ 2+ 1, so it is 10010011.

In this example we want to miss out theedges that lie parallel to the Y axis. So placea zero as the status code for that line. -1 isa way of saying ‘finished’. It does notcontrol line drawing.

420:!POLY_ Demo with hole!Syntax:- POLY_ number,! x1,y1,mask,! x2,y2,mask, etcPOLY_ 9+2, 0.00,0.00,1, -0.10,0.30,1, 0.10,0.30,0, 0.10,0.40,1, 0.20,0.40,1, 0.20,0.10,1001, 0.15,0.10,0, 0.15,0.00,1, 0.00,0.00,-1,

0.05,0.1,900, 0.05,360,4000

IF you are a GDL beginner, or if your eyes glazeover at maths, do not bother with this page

right yet. Come back to it, when you are tryingto understand ‘status codes’ and ‘masking values’.

Binary is the key to understanding how to use theStatus and Masking values. It’s the way that all com-puters work actually, but low level programming codeconverts decimal numbers to binary without our know-ing or needing to know how it does it.

ArchiCAD Training

No matter how long one has been driving, or parenting,or architecting (for that matter) there is always some-

thing useful one can learn from others – no matter whetherthey are equals, experts, or newcomers with open eyes. Thefact that you are reading the Cookbook proves that you arenot the sort of person who says ‘I know as much aboutArchiCAD as I need to know.’Training courses (in whatever aspect of ArchiCAD) may seemexpensive, but often they are the kick you need to get up tothe next level of skill or problem solving technique. Takecourses!

Make a black Pen!If you have a pen colour of zero, you could get an error! (InAC65 onwards, pen 1 seems to be adopted.) One way toavoid this is to use REQ to force a pen colour to exist. e.g. ifyou have a Pen color parameter called ‘ink’:

IF ink=0 THEN ink=REQ(‘Pen_of_RGB 0 0 0’)PEN ink

will build a pen colour from the RGB components of zero,zero and zero, i.e. black. As the rgb components have to bewithin the quotes, you cannot use parameters, only num-bers. You cannot use commas to separate them.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 147: Cookbook3_1

2.44

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Analysis12+02+14+0+04+0+14+2+04+2+18+0+0+08+0+0+18+0+2+08+0+2+18+4+0+08+4+0+18+4+2+08+4+2+1

Binary1101110010111011110001001101010111100110111101111

Binary1000011011101001101011110001111100111111100000010101011111111

Analysis16+0+0+0+016+8+0+2+132+ 0 +8+0+0+132+ 0 +8+0+2+132+16+0+0+0+132+16+8+4+0+032+16+8+4+2+164 or 127-6364+ 0 +16+0+4+0+164+32+16+8+4+2+1

Decimal16273943496063 all on6485127 all on

Masking codes 0-7

POLY2_ in 2D scripting uses a binary group of threechoices, draw the Line (1), draw the Fill (2), and Close

the polygon (4). Therefore the range of decimal numbers isfrom 0 to 7. WALLHOLE also uses 7.

Masking codes up to 127USING the same principle, you can now analyse how themasking values work, up to 127. These are used by EXTRUDE,PYRAMID, REVOLVE, RULED, SWEEP, TUBE, MESH, MASSand COONS. If you use 127 or 63, you cover almost all even-tualities, but you may find this table helpful to understandhow to achieve results. By the way, each of the 3D formsmentioned here use masking values slightly differently, so youstill need to check the manual in each case.

Analytical combinations can be done by subtraction as wellas addition. For example, ‘127-2’ is a convenient way to say‘draw everything except the top surface’.

Some people use numbers up to 255, but as things stand, itis clear from the manual that 127 is the highest number neces-sary.

Decimal123456789101112131415

AS there is some white space left, here is my opportunity for a Plug!

Many of you will get this book with ambitious ideas to learn it all,but as the old adage goes, ‘Practice makes perfect’. Most of you arebusy architects with jobs to do and regard GDL as something you arecurious about, but will never have the time, or the opportunity toplumb to its depths. Because I work for other architects, and alsohave students to train (some of whom become very very good atGDL), I have a constant incentive to keep working at it.

I get many of my ideas for techniques and tips and tricks fromarchitects who phone or fax me with requests. An architect can faxme a hand sketch of something that is needed, I can quote a ‘diffi-

Advertising Feature

Obscure Commands

THE GDL Cookbook does not cover ARMC andARME at the moment, as their use is very rare. In

most tubular assemblies, one can allow Cylinders toflow into each other. I guess that ARMC and ARME mustbe the last remains of the RaDar piping design soft-ware that was the birth of ArchiCAD.

culty index’ or price by email, and it can then bedone within a day or two and either emailed byinternet, or mailed on a disk. Your name and per-haps the object itself might appear in a future edi-tion of the Cookbook!

My charges are very reasonable in that I chargemuch less if the object being made is an invest-ment – that can be used again and again.

All my objects for architect clients have a veryhigh threshold of quality – error checking, stretchi-ness, parametric flexibility, 2D scripted quality etc.

Tips and TricksDynamic Line numbers!Normally you GOSUB 100 and that’s it. But if you are mak-ing use of flags, you can use this technique. Where you mightnormally write:

IF hs=1 THEN GOSUB 101IF hs=2 THEN GOSUB 102IF hs=3 THEN GOSUB 103

You can write all of these on a much shorter line:GOSUB 100+hs

The trick of course only works if you organise your sub-routines so that the numbering relates to the flag num-bers. If you (like me) prefer to follow good practice andseparate your line numbers in chunks of ten or more, thenreplace:

IF hs=1 THEN GOSUB 110IF hs=2 THEN GOSUB 120IF hs=3 THEN GOSUB 130

with:GOSUB 100+hs*10

Byzanti
Highlight
Byzanti
Highlight
Page 148: Cookbook3_1

2.45

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

AngleRod – Useful stretchy tool object with TUBE

Ridge & Hiptool

THIS is a useful item to put on your buildings, togive them added authenticity. You have to use the

Section view to nudge them into final position.

PEN L_ and MATERIAL M_ is a useful way to enablesomeone to use the library object setting box – Pen andMaterial are forced to be as specified by the user – thusreducing the amount of clutter in the parameter set-tings. Once in the Project plan, it adopts the materialsetting given to it. If your model contains several com-ponents and materials, then it’s preferable to use thenormal parameters box.

While developing your model, it may have the un-fortunate appearance of being green, so you could putin a temporary MATERIAL 18 command (whitewash).

The idea of highlighting the 2D symbol with a pairof long arrows is to make sure that you have remem-bered all the ridges and hips, and to make it easier topick them up in plan (gives you more hotspots). As itcan cause visual clutter in the plan, there should be aBoolean choice to be turned off.

!Ridge and Hip tile!3D Script

MATERIAL M_PEN L_

IF shape='Base on Angle'THEN len=A/COS(pitch) ENDIFIF shape='Base on Height'THEN pitch = ATN(hit/A) len = A/COS(pitch)ENDIF

ROTz 90 ROTx 90-pitch

RESOL 10BODY -1EXTRUDE 4,0,0,len,55, rad, 0, 1, 0, 0, 901, rad, 180, 4001, 0, 0, 1BODY -1DEL 2

!Values List _ parameter scriptVALUES 'shape' 'Base on Angle', 'Base on Height'

Use a Value list todecide between using

the Ridge by naming aPitch or a final

Height. It’s more userfriendly than a

Boolean choice.

The 2D symbol can behighlighted with large

arrow shapes so that youcan pick it up

A NGLEROD is a prime example of a STRETCHY object which is more properly a

TOOL. It is similar to the Ridge/hip tool previouslydescribed.

AngleRod is most useful for building up anything tu-bular – by placing the object in the project window,stretching it to its endpoint, and then defining height.

ParametersStretchy objects are made by using A and B as the de-fining dimensions – most useful for railings, cornices,kerbs, special walls, beams. Once you have used this,you will always try to make your objects stretchy.

!Ridge and Hip tile!2D Script

PEN L_

HOTSPOT2 0,0 HOTSPOT2 A/2,0 HOTSPOT2 A,0PROJECT2 3,270,2

IF higl THENHOTSPOT2 A/2, 0.5HOTSPOT2 A/2,-0.5

LINE2 0,0, A/2, 0.5LINE2 0,0, A/2,-0.5LINE2 A/2, 0.5, A,0LINE2 A/2,-0.5, A,0ENDIF

Byzanti
Highlight
Byzanti
Highlight
Page 149: Cookbook3_1

2.46

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

3D ScriptThe 3D Script uses the TUBE command –this requires that you specify a ‘phantom’location above and below the real tubestart and end points. By using the A andB dimensions to define these, you getcleanly cut butt ends to the cylinders.

The routine 0,0,901, followed bycdiam/2,360,4001 is the standard routinefor defining a circular section in an ex-trude, revolve, tube or in several othercommands. You might as well get usedto it.

2D ScriptThe key to stretchy objects is to place theHotspots in the 2D script. Hotspot2 0,0,and A,B.

As a complex group of tubes couldhave end and bounding box hotspotswhich would interfere with each other,you should plant Hotspots along the lineof the tube, so you can be sure which oneyou have grasped.

You can get rid of the bounding boxby placing a 2D hotspot at the origin inthe 2D Symbol window – then turning offbounding boxes in the main library box.

Using AngleRod: When you enterthe anglerod into the plan, it’s bestto have the stretchy box selected inthe control box. If you dont, youhave to place it first, and thenstretch it later.

It is important to allow user control over the Resolution. The anglerodcould be used for fine cables (use resol 3) or the giant sections for abridge or pier.

Notice that with the Tube command, you get linear lines along thecylinder. By changing the 900 and 4000 commands to 901 and4001, the lines are cleared.

2D Script: Plant Hotspotsalong the line of the tube.Specify Hotspots before youissue the Project2 command.

Value List: By adding an extra parameter to choose Butt ends orRounded ends, you can add a Sphere at each end of the Tube, giving arounded end. Put this in the Value List. Round ends will add hundreds orthousands of polygons to your model – Beware!

Use it as a Component or as a Macro!By combining AngleRod into tetra-hedral groups, and bygrouping the groups in encapsulated library objects, you canassemble complex tubular and cable/strut structures withoutany need to use GDL or trigonometry!

!AngleRod!3D Script

MATERIAL cmatPEN L_

RESOL rsl

TUBE 2,4,63, 0,0,901, cdiam/2,360,4001,

-A,-B,-z1,0, 0,0,0,0, A,B,z1,0, 2*A,2*B,2*z1,0

!Extension to 3D ScriptIF endshape='Rounded Ends'THENSPHERE cdiam/2 ADD A,B,z1SPHERE cdiam/2 DEL 1 ENDIF

!AngleRod!2D Script

HOTSPOT2 0,0 HOTSPOT2 A*0.25,B*0.25 HOTSPOT2 A*0.50,B*0.50 HOTSPOT2 A*0.75,B*0.75 HOTSPOT2 A,B

PROJECT2 3,270,2

VALUES 'endshape' 'Rounded Ends', 'Butt Ends'

This is what it lookslike as it is beingstretched. One rodon its own doesn’tlook very exciting,but the rods can be combined tocreate complex frameworks.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Rectangle
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 150: Cookbook3_1

2.47

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

This exercise demonstrates of the use of:• The PUT statement in a FOR NEXT loop.• PRISM using GET• CYLIND, TUBE & Polylines for the Handrail• Using Pythagoras and ArcTan to work out the

details

ONE of the problems with any object •stepping•like a staircase is how to make the number of steps

as a parametric quantity.

First, you could make each step a separate object,and use a loop to draw them. But this would be uglywith many surplus lines. It is better programming to dothe stair as one object, and thus ensure a smooth soffitto the underside with faster rendering.

You can make most Staircases with Stairmaker, buthow much more fun it is to make your own, and with agreater degree of control. The technique used in thisexample is used later in the Theatre seating and otherstepping objects.

ParametersFirst put in the parameters that affect the stair itself.Leave all the handrail questions till later. The stair willbe stretchy in width, so use A. The stair risers will beslightly raked – the user can decide on the size of ‘rak’.

3D ScriptAs is common with the Cookbook ethic, a very struc-tured approach is used, whereby the executive scriptis as SHORT as possible, with most of the workloaddelegated to the subroutines.

The majority of shapes used in GDL can be donewith PRISM commands. These always rise up the Z-axis. You have to lay out the PRISM on the X-Y plane,and up it rises. On some paper, draw an X-Y diagramlike this. To make it the right way up, it will have torotate it 90 degrees around Y.

• First, if you do it NON parametrically, you get the‘Bad Stair’ 100: – in which the treads and risers havebeen individually dimensioned, and no parametric pos-sibility is offered.

The ResultThe Stair can beany number ofrisers, any riserheight or going!You can opt tohave handrails ornone, on the leftor the right side,or on both!!

Stair – Parametric

!Stair parametric – 3D Script

MATERIAL matl: PEN pcol

LET width=A !make it stretchy!GOSUB 100: !Stair non parametric GOSUB 200: !Stair parametric

!Left handrail IF hrstyl=1 or hrstyl=3 THEN GOSUB 300!Right handrail IF hrstyl=2 or hrstyl=3 THEN GOSUB 400

END !_______________________

The Handrails will bedone on the next page

Sketch out on paper howyou want to build up thePRISM shape. This methodkeeps the stair in thepositive X and positive Yquadrant. It also helps youdecide how to treat the topand bottom step details.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 151: Cookbook3_1

2.48

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

200:!Parametric Stair! using PUT&GET! Using square or raked risersADDx width/2ROTy -90

PUT 0,0PUT 0,goingPUT (numrisr-1)*riser, numrisr*goingFOR N=numrisr to 1 step -1 PUT N*riser, N*going PUT N*riser, (N-1)*going-rak NEXT N PUT 0,0

!Now draw the StairPRISM nsp/2,width, GET(nsp)DEL 2RETURN !-----------------

First, theBAD stair

You can knock upa quick and dirty

stair like this bydoing it in

ArchiCAD’s Projectplan using Slab

tool, then bring itinto GDL to tidy it

up. But it would benon parametric!

!*WARNING* – do not bother typing!subroutine 100 – it's here as!an example of inefficient!programming – Use subroutine 200

100: !Bad Stair, Nine RisersADDx width/2ROTy -90PRISM 22,width,0.0,0.00,0.0,0.25,1.6,2.25, 1.8,2.25,1.8,2.00, 1.6,2.00,1.6,1.75, 1.4,1.75,1.4,1.50, 1.2,1.50,1.2,1.25, 1.0,1.25,1.0,1.00, 0.8,1.00,0.8,0.75, 0.6,0.75,0.6,0.50, 0.4,0.50,0.4,0.25, 0.2,0.25,0.2,0.0, 0.0,0.00DEL 2RETURN !-----------------

• Second, you can now try the ‘Good Stair’ 200: – inwhich you store all the points in the prism in a PUTbuffer first – allowing you parametric freedom in thenumber of risers that the staircase will have. In the‘Good Stair’ routine, the loop follows its way roundthe prism shape.

This series of PUT & GET statements replace thelong list of dimensions in the ‘Bad stair’ with a per-fectly parametric solution. Once you have used PUTand GET to establish the fixed XY locations of eachend, the intermediate treads and risers are part of a ForNext Loop.

The GET command: If you want a number of itemsfrom the buffer, you write GET(4) if you want 4,GET(12) if you want 12 etc. You can GET the entirebuffer by defining NSP as the quantity; you get whatthe PRISM command requires – a set of numbers, sepa-rated by commas. As the numbers are extracted, thecommas are inserted by the GET procedure.

The PRISM requires 2 numbers on every line, so thenumber of points in the prism is NSP/2

!Stair: Parameter Script

VALUES 'hrconf' 'No handrail', 'Left handrail only', 'Right handrail only', 'Both handrails'

!Stair: Master Script

LET width=A !make it stretchyIF hrconf='No handrail' THEN hrstyl=0IF hrconf='Left handrail only' THEN hrstyl=1IF hrconf='Right handrail only' THEN hrstyl=2IF hrconf='Both handrails' THEN hrstyl=3

HandrailsThe user needs to enter their choice of handrail con-figuration. To show you two different methods of do-ing it, the left has been done with a TUBE, and theright has been done with a CYLIND and some Trig. Inreality, use one method or the other, and use the MULx-1 command to draw it other side.

First make a Value List offering the user some choicein the configuration. Then use the Master Script toread the Value List and turn it into numbers (flags).You can write the Value list in the Parameter Scriptor you can write it in the Master Script just above thelines which turn the result into flags.

Handrail with TUBE CommandSUBROUTINE 300 uses the TUBE command. Peoplefind TUBE hard to learn, but it is very rewarding.

Tube Section: The cross section is determined by twoPolyline commands, one to set the centre of the circle,and the other to describe a circle around it. Radius ishalf the diameter, 360 is the sweep angle, and 4000tells it to draw the circle. The extra one [1] on the endmakes the rail smooth – to avoid the longitudinal linesyou may get along the handrail.

Observe howeconomical the

PUT and GETroutine is.

Hotspots No Show?

We welcome the availability of 3D Hotspots. These canbe planted at the end of furniture legs, or in places

where it would be difficult to place them in the 2D script.They make it easier to pick up objects in 3D view. Unfortu-nately, these cannot be seen in the 2D symbol (not even inPROJECT2) and cannot even be seen in the GDL 3D view.Only in the 3D window in the ArchiCAD environment canthey be seen.

Tips and TricksSection fillArchiCAD 6.5 allows you to define how the objects willappear in section – previously you had no control. So ifyou make a parameter for Section Fill, you can have aSECT_FILL statement, including parameters for the fillname and three pen types. This only works if the Objectsettings are set to ‘Use Symbol Section Attributes’.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 152: Cookbook3_1

2.49

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Theatre in the Round SeatingThis exercise is an interesting demonstration of:• REVOLVE with a parametric profile• PUT and GET statement• Using a parametric offset in the

REVOLVE command• Planning the location of the object and the

origin

You could make curved Theatre seating by makingeach step a separate object (as a piece of slab in

plan), and use Multiply and Elevate to draw them. Whathard work! This piece of GDL is a continuation of theStaircase example, just done, but curving in plan.

The XY locations in the Staircase were sent to a PRISMcommand – a similar technique is now used to send the

same list of points, the sectional outline of the seating/steps to a REVOLVE command. If you do the bank ofseats as one REVOLVE object, you will ensure a smoothcurved soffit to the underside.

As with the staircase, the problem is how to makethe number of steps as a parametric quantity.

Tube Path: TUBE goes from XYZ location to XYZ lo-cation, so there is no need for Trigonometric calcula-tions. The Tube must overshoot at each end by onenode. So a two point TUBE needs 4 defined XYZ loca-tions. The start and end locations serve to define themitring of each end, so a small overshoot of one centi-metre is used. Make sure that they go in the right direc-tion to get the mitring to work correctly.

Handrail with CYLIND commandSubroutine 400 uses CYLIND. This is easier to do, butrequires Pythagoras to work out the length, and ArcTanto work out the angle of the rail.

Getting it right: depends on the real requirements ofthe Handrail design – do you need balusters, do youneed the tubing to turn at each end, or what? This maydetermine your choice of TUBE or CYLIND.

2D ScriptIT IS possible to write a fully parametric 2D script forthis object, but if the redraw time is not unacceptable,it can be left as a PROJECT2. However, even withProject2, you should use the script to place HOTSPOTsat the key positions – makes it easier to pick up. Youcan also add an arrow to the 2D symbol, to indicatedirection.

The 2D script that DEFINEs a style is there so thatyou can offer an option for the 2D symbol to display itspitch to the user, and when the pitch is correct, the usercan turn that feature off. The Font is autosized to bethe height of one going of the stair.

300: !Left Handrail – TUBEstartht=hrht+riserendht =(numrisr+1)*riser+hrht d=0.01 !one cm overshootADDx width/2-hrdiam/2MATERIAL hrmatlRESOL 12TUBE 2,4,63, 0,0,901, !Sets Circle centre hrdiam/2,360,4000+1, 0,-d,startht-d,0, 0, 0,startht,0, 0,numrisr*going, endht, 0, 0,numrisr*going+d,endht+d,0DEL 1RETURN !-----------------

400: !Right H’rail – CYLIND!This requires Trigonometry

startht =hrht+riserhgoing =numrisr*goinghriser =numrisr*riserhrailen =SQR(hgoing^2+hriser^2)hrailang =ATN(hriser/hgoing)ADDx -width/2+hrdiam/2ADDz starthtROTx -90+hrailangMATERIAL hrmatlRESOL 12CYLIND hrailen,hrdiam/2DEL 3

RETURN !---------------

!2D script for StairHOTSPOT2 0,0HOTSPOT2 0,lengHOTSPOT2 -A/2,0HOTSPOT2 A/2,0

PEN pcolPROJECT2 3,270,2 leng = numrisr*going pitc = ATN(riser/going)LINE2 0,0,0,lengLINE2 0,leng,-A/2,leng-A/2LINE2 0,leng, A/2,leng-A/2IF shodata THEN fontz=going*1000/A_ DEFINE STYLE 'show' Arial, fontz,4,0 SET STYLE 'show' ROT2 90 TEXT2 0,0,STR(pitc,4,2) ENDIF

Byzanti
Highlight
Page 153: Cookbook3_1

2.50

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

ParametersThe Bank of seating can be any number of seats, anyheight or going, any radius of curvature and any sweepangle! You can opt to have side staircases or none, onthe left or the right side, or on both!! This is important ifyou are planning to join them together to make largerassemblies. The seating banks do not contain actualseats – like plastic flip up seats – but that may the thesubject of a future variation on the model.

It is important to have a ‘curviness factor’, becausethe usual default curve resolution of 36 on such a smallsweep angle will make the model look toopolygonal. Be warned that making it more curvy willadd more polygons. You have to balance smoothnesswith rendering speed!

When you offer your user two choices, you can usethe Boolian command, but for more complex require-ments, an integer number has to be given, as in stairstyle, or you make a Value list, stating in simple lan-guage what alternatives are available.

The steps at the side sit correctly relative to the seats.On the underside, there is a perfectly smooth soffit –because the location of the points for the underside aredefined by the same subroutine.

Use PUT and GET3D ScriptA structured approach is employed, whereby the pro-gram is as SHORT as possible, with most of the work-load delegated to the subroutines.

If you build it with REVOLVE commands using realdimensional data, it will work, but will be non-para-metric. If you use a PUT GET routine first, like the onein the Staircase example, you can modify this as freelyas the staircase.

Because of the curvy shape, it’s not worth trying tomake it stretchy – just ensure that by the parameters, itis quite clear how the stair should be configured.

The REVOLVE command spins the object around theX-Axis, so one has to be careful how one lays out theprismatic outline. It is done on an X-Y diagram like this.The example shown appears not just to spin aroundthe X-axis, but to touch it. It is a lot easier to work thisway, and to apply a parametric OFFSET, here called'cent’. So design it according to this diagram.

The result – The Nudist convention meets in Epidaurus!

A variety of seatingand stair makingarrangements is

required.

This doesn’t have to beused in a Greek theatre –this object can be used inan ultra modern stadium,and this curved structurecould be set into a steelframe (as one of my stu-dents has done) and thentweaked with the param-eters to fit.

Draw it out first!As with the Staircase, draw outthe shape as if you were tomake it with a PRISM command– these always rise up the Z-axis. Draw it first.

Page 154: Cookbook3_1

2.51

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

The Seats and the Stair use virtually the same subroutine – beforecalling the subroutine, you prime the program with the values ofthe variables that will produce either a seat or a stair – ‘num’, ‘ris’and ‘gon’. In addition, we add the ‘f’ flag, to tell the subroutinewhich structure it is building – stair or seating?

All these ‘alphangl’ rotations are very important to ensure thatthe Origin stays at the front row of seats – and that the axis of sym-metry of the seats remains down the centre. If you had the originof the model at the centre of Rotation of the seats and stairs, youwould have an easier time programming it; but the user would havea nightmare – everytime they changed the parameters, the wholeassembly would jump backwards or forwards, because the originwould be 10s or 100s of metres away.

Looking at the Staircase (previous exercise), one had to feed inthe location of the starting points of the stair, followed by the rep-etition of the x,y coordinates for the stairs themselves. We do thesame here. But there is a small difference – the REVOLVE requiresa small status code after each XY location – to indicate how lines ofthe stairs should be drawn. Using 0 (zero) will ensure that the linesdo get drawn.

PUT & GET: and ‘flags’PUT&GET were explained in the Staircase example. A differencehere is that the same subroutine 400: is used for the seating as forthe staircase even though there are a different number of stairs andseats. Another complication is that you must bring the stair for-ward the length of a step so that the junction of the stairs and theseats is correct. Thus one cannot follow exactly the same algorithmand simply change the riser and going. Here I use the idea of ‘flags’which the subroutine checks to see what the current setting is. Theflag is called ‘f’ which can be ‘0’ when drawing the seats and ‘1’when drawing the stair. A flag can also be used as a factor. If youmultiply something by ‘0’, you get zero. Thus, by subtracting anamount equal to the distance of the Risers from the centre which ismultiplied by ‘f’, you finish up with the correct location. Type it in,try it with and without and you will see how it works.

2D ScriptYou need a Project2, but you also need a bit of tricky thinking towork out the location of Hotspots – needed to help you pick theobject up. You could borrow the script from the Staircase whichprints out the pitch (angle) and have it displayed on the 2D symbolso that you can tweak the seating to fit a steel frame.

!2D script – Theatre Seating

PROJECT2 3,270,3HOTSPOT2 0,0HOTSPOT2 0,numrisr*stgoing ADD2 0,-cent ROT2 90+alphangl/2GOSUB 100 ROT2 stanglGOSUB 100 DEL 2 ROT2 90-alphangl/2GOSUB 100 ROT2 -stanglGOSUB 100 DEL 2END !_______________________

100: !draw hotspotsHOTSPOT2 cent,0HOTSPOT2 cent+numrisr*stgoing,0RETURN

!Curved Theatre Seating!3D Script

IF rs<36 THEN rs=36RESOL rs: MATERIAL matl: PEN pcol GOSUB 100 !seats parametricIF sstyl=1 or sstyl=3 THEN !LeftStair GOSUB 200 !stairs one side ENDIFIF sstyl=2 or sstyl=3 THEN !RightStair MULx -1 GOSUB 200 !stairs other side DEL 1 ENDIFEND !_____________________________

100: !Parametric Seats !using PUT & GETADDy -centROTz -alphangl/2ROTy -90num=numrisr: rak=ABS(rak)ris=srisrht:gon=stgoing: f=0GOSUB 400 !PUT all the values!Now draw the seatsREVOLVE nsp/3,alphangl,63, GET(nsp) DEL 3RETURN !-------------------------

200: !Draw the stairsADDy -centROTz +alphangl/2+stangl/2ADDy +cent GOSUB 300 DEL 3RETURN300: !Parametric Stairs !using PUT & GET num=numrisr*2: ris=srisrht/2 gon=stgoing/2 f=1 !'f'=stepsflag GOSUB 400 !PUT all values!Now draw the stair ADDy -cent ROTz -stangl/2 ROTy -90REVOLVE nsp/3,stangl,63, GET(nsp) !Do it!! DEL 3RETURN !------------------------

400:!----- PUT routine --- PUT 0,0 + cent -f*gon,0 PUT 0,stgoing/2+cent,0 PUT numrisr*srisrht-srisrht/2, numrisr*stgoing+cent,0 PUT num*ris,(num)*gon+cent,0 FOR N=num to 1 step -1 PUT N*ris,(N - f)*gon+cent,0 PUT N*ris,(N-1-f)*gon+cent-rak,0 IF bulrak THEN PUT N*ris-rak,(N-1-f)*gon+cent-rak,0 PUT N*ris-rak,(N-1-f)*gon+cent,0 ENDIF NEXT N PUT 0,0+cent-f*gon,0RETURN !------------------------+

The 2D symbol,with hotspots

Page 155: Cookbook3_1

2.52

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Stair spiral - 3D Script

MATERIAL matl: PEN pcol

GOSUB 50:!Error checking

!GlobalsADDy -A/2ROTx 90

GOSUB 100:!Put the locations for Stair

!Now draw the StairbPRISM_ matl,matl,matl, nsp/3,-width,A/2, GET(nsp)

IF hrhit>riser THEN GOSUB 200:!Handrail

DEL top

END:!———————————————————————

50:!Error checkingIF width>A/2 THEN width=A/2.01IF rakd>going/3 THEN rakd=going/3RETURN

100:!Put the locations for StairPUT 0,0,15PUT going,0,15PUT numrisr*going,(numrisr-1)*riser,15

FOR N=numrisr to 1 step -1 PUT N*going+rakd,N*riser, 15 PUT (N-1)*going,N*riser, 15 NEXT N PUT 0,0,15RETURN

200:!PUT locations for HandrailPUT 0,0,15, 0,0.04,15PUT numrisr*going, numrisr*riser+0.04,15, numrisr*going, numrisr*riser,15

!Now draw the HandrailADDy hrhitbPRISM_ matl,matl,matl, nsp/3,-0.04,A/2, GET(nsp)DEL 1RETURN

Spiral StaircaseThis exercise looks at bPRISM, PUT & GET

bPRISM_ is special

THE Spiral Staircase follows on logically from thetwo previous examples. It is an important example

though, because it shows a reason why Graphisoftmade bPRISM exceptional in being able to tolerate anegative figure for depth. If ‘width’ had to be positive,the stairwell radius could never be smaller than thestairwidth.

3D ScriptAs with all the staircases, the only way to make it para-metric is to master the use ofthe PUT command in a FOR...NEXT loop to allow a variablenumber of risers.

If you wish the origin to bein the centre of the staircase,you need an offset at the startof the 3D script. You also needa ROTx move at the start tomake the staircase stand up-right.

It is very timesaving if youcan use the same technique,with minor variations, to definethe handrail. The drawback of this is that it has to be arectangular section. If you wanted a round tubular sec-tion, you would have to use a helical TUBE routine –similar to the ‘Long Handrail’ exercise in the GDL Cook-book, but applying a height change to each point, ac-cording to the gradient of the stair.

!Spiral Staircase - 2D script

HOTSPOT2 0,0HOTSPOT2 0,-A/2HOTSPOT2 0,-A/2+widthHOTSPOT2 A/2,0

IF stret THEN HOTSPOT2 -A/2,0

PROJECT2 3,270,2 !Do it last

2D ScriptIt would be very tiresome to script this fully in 2D, andunless you have dozens of spiral stairs in the building,you would not get a speed benefit from doing so: there-fore you can be contented with a PROJECT2 command.What you must do is to ensure that you have HOTSPOTsin the right places to help you pick up the stair. Thereis a little IF statement that allows you to make the stairstretchy. If you stretch it, the diameter of the stairwellis changed.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 156: Cookbook3_1

2.53

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

The Secrets of Labels– you can make your own graphic label

LABELS have improved tremendously with 6.5 andpresent some interesting challenges for the GDL

user. There are new Global Variables (GV) relating tolabels.

Your first impression of Labels is that they allow youto place a pointer, drag away slightly and then plant atext label near the dragged line. However, labels canbe more powerful, they can have a graphic design, suchas ones referring to other drawings, to internal wallelevation drawings, wall information etc. A pop-downmenu in the settings box enables you to select a graphiclabel, and you are provided suddenly with a lot of help-ful parameters to apply to the object.

Label objects are 2D scripted objects which can con-tain boxes, circles and lettering or numbers accordingto the way you like labels to be done. You can buildyour own graphic label objects, and use the GVs to actintelligently on user choices in the settings box.

Labels are normally saved to the labels folder alongwith other 2D objects, and they will show in the labelspop-down menu as long as they are in a loaded li-brary. So you could build custom labels specially forone project if a generic one is too much bother to make.In fact they do not need to be scripted at all. You canbuild a static graphic symbol in the 2D symbol win-dow of the Label object, and it will work; or you canwrite a short script for text, and use a FRAGMENT2ALL,1 command to show a drawn 2D symbol.

Of course the true GDL user will have in mind thatscripted objects can be smart and parametric, unlike amere symbol. Label objects can input, process, displayand/or output to a text file the labelled element's pa-rameters or features. Laurent Godel writes:

A nice label I am still working on is the automaticlabel. Instead of typing all your notes repeatedly youhave them stored inside a text file, where each is

identified with a code. Upon creation of the label,the user just types in the desired code and the fulltext of the note is displayed. Very useful for updat-ing! (although this is a complicated matter when itgets to import scripts and User Interface).

Let’s try to make a Label ObjectLabels are helped by using the Global variables – thesehelp you decide on pen colour, font names and char-acteristics. Unfortunately, the GVs do not work whenin the GDL environment, and ‘check script’ always re-ports an error when you use them. So it’s difficult tofind a real error when the error checker constantly flagsup a spurious error. If you save the label and use it inthe floor plan, you can see that the GVs work correctly.

The first example is a text-only label object wherefull use is made of Global variables. Every parameterexcept the actual message is a GV. This object will bedeveloping a box, so boxsh has appeared for shape.This text label may be all you need, as labels have aninbuilt feature to put a box round the label text, but itis very crude and close fitting; you might want an el-lipse or hexagonal shaped box.

One of the graphic labels supplied inyour existing ArchiCAD Library

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 157: Cookbook3_1

2.54

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Label Object – text only

DEFINE STYLE 'labeltext' LABEL_FONT_NAME, LABEL_TEXT_SIZE,LABEL_ANCHOR_POS, LABEL_FONT_STYLE

SET STYLE 'labeltext'PEN LABEL_TEXT_PENTEXT2 0,0,messag

Ultra simple Label objectThere is no need to create any parametersfor the text characteristics, they are all inthe main settings box for the label

Although we have A and B available to use, it isbetter to make the box fit around the lettering – scriptedhotspots do not stretch. The Label tool has internal datastructures that place stretchy hotspots in a label bound-ing box and items with B dimensions will stretch.

So, you have entered a string of text, called messag.Lettering size is calculated by two methods. Width isSTW(messag) and height is LABEL_TEXT_SIZE. Bothof these need tweaking to make them work in metresand to be scale sensitive using A_ (GLOB_SCALE). Thenotional box size is increased all round in proportionto the height of the text.

Bug! I built a User interface (here) for the box shape only tofind that although the box changes shape perfectly in thesettings box, it refuses to change in the actual floor plan.This cannot be intended to happen. In fact, Label objects aresensitive flowers which, if you use the User interface toomuch, the GDL suffers progressive disintegration and all theparameters dissappear or become equal to infinity.

Question! when you have a geometric shape (such as aPOLY2) included in the symbol, the text dances up and downand left and right and never sticks to the right place relativeto the arrow line or to its XY values. It’s another part of theinternal Label toolbox which likes to reposition the entiregraphic according to a position option in the settings box. Ihave got round it here by adjusting all graphics downwards(so that theyare centrallyoriented to thetext) and thenwork thePOLY2 fromthere.

!Label Object – Full 2D Script

IF boxsh='None' THEN bsh=0IF boxsh='Rectangular' THEN bsh=1IF boxsh='Diamond' THEN bsh=2IF boxsh='Hex' THEN bsh=3IF boxsh='Circle' THEN bsh=4IF boxsh='Oval' THEN bsh=5

SET FILL boxfilDEFINE STYLE 'labeltext' LABEL_FONT_NAME, LABEL_TEXT_SIZE,LABEL_ANCHOR_POS, LABEL_FONT_STYLESET STYLE 'labeltext'PEN LABEL_TEXT_PENsthit=LABEL_TEXT_SIZE*A_*2/1000stlen=STW(messag)*A_/1000+sthit/2TEXT2 sthit/4,0,messag

PEN pcolSET FILL boxfilGOSUB 100+bsh

END:!_____________________________

100:!NoneRETURN

101:!RectangularADD2 0,-sthit/2PUT 0,sthit/2,mlin, stlen,sthit/2,mlin, stlen,-sthit/2,mlin, 0,-sthit/2,mlin, 0,sthit/2,mlinPOLY2_ NSP/3,7,GET(NSP)DEL 1RETURN

102:!Diamond – stretchyp=LABEL_TEXT_SIZE*A_/1000ADD2 0,-sthit/2PUT -p,0,mlin, stlen/2,B/2,mlin, stlen+p,0,mlin, stlen/2,-B/2,mlin, -p,0,mlinPOLY2_ NSP/3,7,GET(NSP)DEL 1RETURN

103:!Hexp=LABEL_TEXT_SIZE*A_/1000ADD2 0,-sthit/2PUT 0,sthit/2,mlin, stlen,sthit/2,mlin, stlen+p,0,mlin, stlen,-sthit/2,mlin, 0,-sthit/2,mlin, -p,0,mlin, 0, sthit/2,mlinPOLY2_ NSP/3,7,GET(NSP)DEL 1RETURN

104:!Circle and EllipseADD2 0,-sthit/2MUL2 1,B/stlenPUT stlen/2+sthit/8,0,900+mlin, stlen/2,360,4000+mlinPOLY2_ NSP/3,7,GET(NSP)DEL 2RETURN

105:!OvalADD2 0,-sthit/2PUT 0,sthit/2,mlin, stlen,sthit/2,mlin, stlen,-sthit/2,1000+mlin, 0,-sthit/2,mlin, 0,sthit/2,1000+mlin, stlen,sthit/2,mlinPOLY2_ NSP/3,7,GET(NSP)DEL 1RETURN

Parsing theValue list

Text is almostentirely based

on Globalvariables

Subroutineshandle therest of the

work

As many of thesebox shapes aresimilar, it saves

trouble to usePUT & GET

‘mlin’ is a flag todraw or not

draw the line –so the user can

have a box of fillpattern if they

wish

The Hex andDiamond shapes

need to beslightly longer

than therectangle, and

‘p’ is a smalltweak to the box

width

The ADD2 0, -sthit/2 seems to

be a lifesaverhere

VALUES 'boxsh' 'None', 'Rectangular', 'Diamond','Hex', 'Circle','Oval'

The Value List is inthe Parameter script

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 158: Cookbook3_1

2.55

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Label Arrays – show position

WITH a bit of help from Laurent Godel, we havesussed out how the label arrays work. Here is a

useful little object. This object is a label graphic (.LSMobject) that simply shows the location of the arrow headrelative to the project origin. This could be done withsome neat 2D scripting in a normal GDL object, butyou wouldn’t get some of the smart features that areincluded in the API that governs labels. The additionof a graphic label gives you the best of both worlds.

This can be genuinely useful in manufacturingwhere you can lay out components according to loca-tions in a drawing. It could also be useful in surveyingwhere you want to record onto the survey map the XYlocation of boundary points, trees, fence lines, bench-marks. Simply point the label tool at the point of inter-est and click! you have it. One drawback is that if thelabel is applied to a hotspot, it makes the computerbeep, and doesn’t plant the label. This is a bug not afeature. However, you can place the label next to thehotspot, and then move it and drop the arrowhead onthe hotspot.

The label shows its XY location relative to the mainproject origin, so if you want to work to a differentorigin, you can enter a standard XY offset to each la-bel.

LABEL_POSITION [3][2]

... is another Global Variable, but contains 6 num-bers, arranged in 3 groups of 2. The most importantone is the first group, LABEL_POSITION[1][1] and [2]which show the X and Y location of the actual textelement. The other two show relative distances of theelbow and arrowhead. By working them all together,you get the location of the arrowhead.

2D ScriptThe routine here could be rendered down, almost toone very long line, but it makes sense to break it intoblocks of code and to provide the user with sensiblefeatures. This object allows the user to enter the textsize according to actual dimensions, thus mak-ing it scale sensitive – it remains attached tothe object regardless of the drawing scale(doesn’t blow up and become enor-mous if you change from 1/50 to1/100).

The precision could be useful.If your object is used in a prefab-rication workshop, people areworking to millimetres or smaller.If marking trees in a field, thenlow precision is adequate. Thisworks in metric, but could beadapted for use with imperial.

!LABEL_POSITION!ARRAY [3][2]

!Text insertion pointx1=LABEL_POSITION[1][1]-xoffy1=LABEL_POSITION[1][2]-yoff

!Middle insertion point (relative to 1st)x2=LABEL_POSITION[2][1]y2=LABEL_POSITION[2][2]

!Arrowhead position (relative to 2nd)x3=LABEL_POSITION[3][1]y3=LABEL_POSITION[3][2]

!Decimal precision levelsIF precis='Low' THENlabstringx=STR('%.1m',x1+x2+x3)labstringy=STR('%.1m',y1+y2+y3)ENDIF

IF precis='Medium' THENlabstringx=STR('%.3m',x1+x2+x3)labstringy=STR('%.3m',y1+y2+y3)ENDIF

IF precis='High' THENlabstringx=STR('%.5m',x1+x2+x3)labstringy=STR('%.5m',y1+y2+y3)ENDIF

!Do it now!DEFINE STYLE 'labltxt' 'Arial', fsiz*1000/A_,1,0SET STYLE 'labltxt'

TEXT2 0,0, labstringxTEXT2 0,-fsiz*1.1,labstringy

Value list in parameter scriptVALUES 'precis' 'Low','Medium','High'

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 159: Cookbook3_1

2.56

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

CWALL and bWALL: arecommands that GDL users do

not penetrate, as they are typical ofthe most difficult parts of the GDLmanual; strangely, they spend pagesdetailing the use of GDL commandsthat are only likely to be used inautoscripting. You get to the pointwhere the difficulty of writing some-thing in GDL is only justifiable if youare going to get parametric objects.Otherwise, you are better creatingit with the normal ArchiCAD tools,and saving the result as an object. Ihave tried making objects withthem, but these are all easier tomake with SLAB, PRISM and soforth.

There is also XWALL, for wallswith holes, cuts and everything.

cROOF The same can be said forCROOF, although CROOF is less dif-ficult for someone really determinedto get custom window shapes forrooflighting. I guess these com-mands are not really intended forpeople using creative GDL scripting.If you are a Voyager, you will be ableto cope with the example given inthe manual.

3D GDL –Building Elements

SPECIAL PRISMs

FPRISM allow you to chamfer the top edge of a prism, and to have different materials for each surface. Putan angle in and you get a hipped roof effect. Put in zero for angle, and you get round edges.

RESOL works differently. Usually, in a 90degree curve, you would get 1/4 of the resolution i.e. RESOL 40would give 10 edges. Here, you get 4 times the normal resol figure; RESOL 10 gives 10 edges. TOLER workswith FPRISM but again, it works at 4 times the expected figure.

Most realistic furnishing and other objects have rounded edges; this FPRISM function is a real help; butwhenever possible, use a simple 45˚ chamfer, which can give a rounded look without creating hundreds ofpolygons.

Bug Report:

FPRISM does not havemasking to hide themany horizontal lineson rounded surfaceson the ‘hill’.

FPRISM was bad inearly AC6 releases –could not work withMULZ -1, and the Hillmaterial determinedthe side and bottommaterials.

BODY is used to do a cjeckon the integrity of 3D com-

mands, and I recommend you touse it in the form BODY -1. Allautoscripted object commandshave BODY -1 before and afterthem, and ArchiCAD writes thesein to improve the reliability of theobjects. So it cannot do any harmto write this in after long Prisms,Revolves and other bodies. I havefound in practice that objects madewith TUBE (remember the ‘men-tal health warning’) will rendermore reliably with the BODY -1before and after the command.

Conclusion: Use BODY -1

VERT, EDGE, PGON, BODY,PIPG, BASE, TEVE andCOOR.These commands are vital to importedAutoscripted objects. If you importDXF files, you get them condensedinto pages of scripted garbage usingthese commands. So while it’s usefulto have a way of interpreting DXF im-ports, I doubt if you will use them formaking new objects.

VERT and COOR can be used to ex-ert greater control over mapped tex-tures in photo rendering. See the sec-tion on Texture Mapping later in theVoyager course.

!FPRISM demonstration!Syntax: – FPRISM_ topmat, botmat, sidmat, hillmat,!number of pts, thickness, angle, hill_height

RESOL rsl: PEN 1FPRISM_ "Sandstone","Pine","Zinc","Sandstone", 9+2,0.1,sang,hhit, 0.00,0.00,15, -0.10,0.30,15, 0.10,0.30,15, 0.10,0.40,15, 0.20,0.40,13, 0.20,0.10,1013, 0.15,0.10,15, 0.15,0.00,15, 0.00,0.00,-1,

0.05,0.10,900, !hole 0.05,360,4000 !hole

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 160: Cookbook3_1

2.57

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!SPRISM demonstration!Syntax: – SPRISM_ topmat,botmat,sidmat,hillmat,! number of points,X_begin,Y_begin,X_end,Y_end,height,angle,! x1,y1,mask, x2,y2,mask..... xn,yn,mask

RESOL 10: PEN 1SPRISM_ "Sandstone","Pine","Zinc", 9+2,0,0,0.1,0.1,0.2,-30, 0.00,0.00,15, -0.10,0.30,15, 0.10,0.30,15, 0.10,0.40,15, 0.20,0.40,13, 0.20,0.10,1013,

SPRISM: is a routine for cutting a roofplane throughthe top of a Prism. You can use a normal prism

with a Cutplane to achieve the same result. It has al-ways been difficult to use any of the GDL commandswhich use Vectors (ROT, and one version ofCUTPLANE) because of the effort to imagine the re-

sult, so some trial and error is required. In this case thevector draws a line on the X,Y plane, and the roof iscut at right angles to that line, at the height and anglespecified.

If the roofplane is cutting too harshly (i.e. it cutsthrough the floor of the Prism) it will not get drawn.

Frankly, it’s easier to useCUTPLANE, once you have got thehang of it.

More 3D GDL

LIGHT: I offer an example of the LIGHT command in theDiscovery Cookbook (Standard Lamp), and there is one ex-

ample in the Voyager, in the Anglepoise lamp.

I have looked hard at this topic in the Motorist smart car, inwhich the car headlights are the only lightsources in a model sev-eral miles wide!

Remember that an object (eg bulb in the light fitting) that emitslight can be assigned Material indices. For example, when the lightis ON, it can be ‘Lamp’ and when OFF, it can be ‘Whitewash’.

Only when the light is directional can it cast shadows – a gen-eral brightener does not cast shadows. Lamps which cast shadowsresult in almost disastrous rendering times in ArchiCAD, but arenot too insufferable if used in Artlantis.

Directional LIGHT travels along the X-axis. If you want the lightto act directionally, you have to orient it carefully in the correctdirection. Lamps are only effective if you turn ‘Lamps’ on as a lightsource in the PhotoRendering settings box.

!General Brightener – simple LIGHT 1,1,1, !R,G,B 0,0, !shad,rad 0,0,0, !alp,bet,angfall 0,dist,0 !falloff

!General Brightener – complex gb=G/100 !brightness index LIGHT gb*D,gb*E,gb*F, !R,G,B 0,0, !shad,rad 0,0,0, !alp,bet,angfall 0,gb*dist,(gb-1)^2 !falloff

If you want an easy life, this rou-tine for a general brightenercould use the values of 1,1,1 forRed Green and Blue. But thestandard parameter box for alamp gives you the means tocontrol brightness and to controlthe Red, Green or Blue propor-tions of a light. The complexroutine shows how to do this.

!Headlight IF headon THENMATERIAL "Lamp-Whitebright" ADD 0.3,0,0.5 ROTy -5 LIGHT 1,1,1, 0,0.1, 15,20,0.5, 1,50,0.1 DEL 2 ELSE MATERIAL "White_Bright" ENDIF

Spotlight: This light was used as a car headlamp in Motorist. Thedirection of glow is already horizontal, so a 5 degree tilt is enough tomake the light beam lay correctly on the road. Shadows are turnedoff (it would slow down rendering too much) and the beam is de-signed to project 50 metres in a narrow beam. Two materials havebeen defined for the white disk of the headlight, very white with amaximum ‘emission’ for the light on, and very white and reflectivefor the light off.

Syntax:LIGHT red, green, blue,

shadow,radius,alpha, beta,anglefalloff,dist1,dist2,distfalloff

0.15,0.10,15, 0.15,0.00,15, 0.00,0.00,-1,

0.05,0.10,900, !hole 0.05,360,4000 !hole

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 161: Cookbook3_1

2.58

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

More CuttingCUTPOLY: has huge advantages over CUTPLANE

in that it operates like a cookie cutter through themodel.

You define the profile of CUTPOLY with similar syn-tax to a common PRISM. It grows up from the X-Yplane. The direction of the cut can be modified bymaneouvring it into position (like I advise forCUTPLANE, and just like you would do if you weretrying to manoevre a PRISM to the same location) or itcan defined with a final x,y,z statement at the end ofthe CUTPOLY statement which defines a vector (from0,0,0).

A limitation is that the profiles MUST be CONVEX.Concave or more complex shapes would have to bebuilt from a succession of convex CUTPOLY state-ments.

CUTPOLYA: If you want holes with Polylinesenabled, you can use a variation called

CUTPOLYA which is analogous to PRISM_ in that everyXY location has to be followed by a masking value,usually 15. You are supposed to be able to pointCUTPOLYA in a certain direction and fire it off a de-fined distance, but this feature does not work in AC_6or 6.5 and it is best to assume that the cut profile isinfinite in length.

There is also CUTSHAPE but I have not had occa-sion to use it yet when Cutpoly was perfectly able tomeet the need.

WALLHOLE: has almost identical syntax toCUTPOLYA, but only operates when it is part

of a window object. It supports polylines. It drills aholes through a wall, but must not have any compli-cated peninsulas, or it will not happen, and the win-dow will default to a rectangle based on A and B. Seethe Curvy Windows in both the Discovery and Voy-ager courses for examples. Like CUTPOLY, youmaneouvre it to its destination as if you were moving aPRISM, and the job is done.

ADDx A/2 ROTz 90-angl+ABS(mitr) ROTx 90circle 0.5CUTPLANE DEL 3

Show the Blade!

CUTPLANE is most easily done with the ‘anglemethod’ – maneovre the imaginary cutting blade into

position, then issue the command. Sometimes, you getvery confused with the pluses and minuses of the angles.Put an ACTUAL cutting disc at the same place soyou can see exactly which way it is facing.

!CUTPOLY demonstration!Syntax: – CUTPOLY no_of_cutting points,! x1,y1,x2,y2,...xn,yn! (define a poly cut plane)! [,x,y,z] (optional)! defines the vector direction! of cutting.!Remember to issue a CUTEND after!you have made your object

PEN 1MATERIAL "Gold"RESOL 16 ADDz 0.02 ROTx 90CUTPOLY 4, -0.02, 0, 0.02, 0, 0.02, 0.02, -0.02, 0.02 DEL 2

!Now for the object! CONE 0.04,0.04,0.06,90,90 CUTEND !Close with a Cutend

Teamwork ProblemEric Batte wrote,If you use Teamwork, should you use local drafts instead ofworking direct from the PLP file? If so, why? How do youorganize the drafts? Where are the drafts stored so that theymay be backed-up by the server? This seems to be the rec-ommended working method from GS as well, but I don'tstructure it like this in my office.

Gyuri Juhasz,_Gyuri <[email protected]>Using drafts is good because:– You can save your design without being online.– You can explore multiple design alternatives within yourworkspace and save them as separate drafts under differentnames.– You can work undisturbed in your workspace and send thechanges only when all the details are correct. This means

your teammates will not see any mess of an unfinished stateof your elements.How this works?When signing in, you get a Sign-In ID. Any drafts you saverefer to this ID, regardless of the name of the draft file itself.If you think of your workspace as a whole entity, you canhave multiple stages or variations of that in separate drafts.When you send changes, your earlier workspace contentsin the Team Project will be replaced by the elements of thedraft you send changes from. Sending changes from an-other draft does the same – it replaces the elements youhave just sent from the other draft.The drafts themselves can be stored anywhere. They arepretty much like Solo Projects, the only difference is therights to send changes to a particular Team Project. Think ofthem and handle them accordingly. Hope this helps,

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 162: Cookbook3_1

2.59

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

IN THE DISCOVERY volume, you will find theexercise called ‘Simple Window’. This laid down

rules for building windows with a script. Quite often,you need a window with special jamb details, a curvedlintel, a projecting sill, or some other complication. Thisexercise shows how to provide some of these compli-cations.

Use a Macro for the windowTo save typing the original window again, try usingthe CALL command to bring in the window from theDiscovery course. You can either type in the CALLmanually, or you can make a small wall, put the win-dow into it, save that as a temporary library object,then open that and copy the little bit of text above. Aswe want to be able to redefine materials etc, and usethe same A and B as before, you can use A=A, and soon, using identical parameter names.

Window and Doors always cut a rectangular shapein a wall, so it is important that your A and B param-eters apply to the window itself; but you may need tocut a hole much bigger to accommodate arched lintelsor the like.

More Complex Window

A and B are the official window sizes. The Oversize factors allow you toinsert jamb, lintel and sill elements.

Use GDL for the surroundNow you can make it more complex –add in the parameters for the Lintel andSill. The basic idea is always to keepthe window object rectangular. So youmay have to provide a jamb around thewindow.

If the lintel and sill both project fromthe face of the wall, you can keep thingssimple. Just add them to the 3D model,and they will exist in the 3D model.

This exercise shows you the ‘pukka’method whereby you might also haveto build jambs around the window. Thisalso ensure that you have the correctmaterials on the reveals. A plain win-dow in an ArchiCAD wall will havebrick on the inside reveals, or plasteron the outside reveals – not good! Bybuilding a jamb element, you ensurethat the reveals render correctly.

Writing for older versions

IF you are using ArchiCAD 6.x, the people you send work tocould be dismayed to find that nothing you write works in ver-

sion 5.0 or 5.1. Do not despair. If you have written in 5.0 compat-ible code (avoiding Fprism, Cutpoly, arrays and a few other things)you can email them the 3D script, the 2D script and a list of pa-rameters as text files, and these can be dropped into place. Re-writing the parameters is the longest task.

Calculate the volume of a MeshDarren Park: I need to calculate the volume of a mesh. Isthis easily done? (Using Version 6.5)

Dwight Atkinson: Try selecting the mesh in question andperforming a Calculate> List Elements> Basic. This rou-tine returns a list of the mesh with a ‘volume’ attached.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 163: Cookbook3_1

2.60

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Until you put the 3D surrounding elements in, you can see thespace left around the window

In the Library box where you enter newparameters, you can enter ‘Oversize’ param-eters for width and height. You can enter realdimensions, or can put in variables, or ex-pressions. Here, we want it to cut a hole toconform to the widest element – either thelintel or the sill. Use the MAX factor.

3D ScriptThe window is CALLED from the previousexercise. the Call command refers to the sameparameter names, A,B, fmat and gmat. Liftthe window frame if you wish to control theamount it is recessed into the opening (if youuse ArchiCAD’s control, it may recess thewhole assembly – not good!)

wmax and recp just save you typing laterby establishing them as ‘internal parameters’(calculated from main parameters) to definewindow width and recess distance to the cen-tre of the frame. As it was a 100mm frame,the distance is winrec+0.05.

The Jamb is just a prism built around thewindow frame. It is important to make fulluse of masking, to get it looking right. Theoutside of the prism has a masking value of8 (show face only, no lines) to avoid a lineshowing around the opening. The inside faceof the prism, showing the reveals, is donewith 15, because you want the lines to show.

Two prisms are drawn, one for the exter-nal wall surface, and one for the internal wallsurface. the materials and thicknesses arebased on Global variables G_, H_, I_ and C_.

The lintel face is just another prism.

The Sill is more complicated. Because it isprofiled, it has to be built upwards as a prismand then a ROTy 90 lays it down into posi-tion.

2D ScriptThe one here is simple, but it is not ideal.The Project2 command (first shown to youin the Simple Window exercise) has to be inwireline, but then it shows too much of theconstruction lines. If the window is to be useda lot, it is better to be fully scripted, in whichyou could also add fill pattern, morehotspots, change the constructional detail atdifferent scales and so on. The A and B di-mensions in the Library settings box will con-tinue to apply to the window frame only.

!2D - complex window!This could be better!if fully scriptedROT2 180PROJECT2 4,90,1

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 164: Cookbook3_1

2.61

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!More Complex Window!Voyager

ADDz winrecCALL “windo-discovery” PARAMETERS A=A,B=B,fmat=fmat,gmat=gmatDEL 1

wmax=MAX(lintwo,sillwo) !largest widthrecp=winrec+0.05 !centre point of frame

!Jambs & wall above & below!External faceMATERIAL “Red Brick”!H_PRISM_ 5+5,winrec+0.05, -A/2-wmax,-sillht, 8, -A/2-wmax,B+lintht, 8, A/2+wmax,B+lintht, 8, A/2+wmax,-sillht, 8, -A/2-wmax,-sillht, -1,

-A/2,0-0.01,15, -A/2,B+0.01,15, A/2,B+0.01,15, A/2,0-0.01,15, -A/2,0-0.01,-1

!Internal face ADDz winrec+0.05MATERIAL “whitewash”!G_PRISM_ 5+5,C_-winrec-0.05, -A/2-wmax,-sillht, 8, -A/2-wmax,B+lintht, 8, A/2+wmax,B+lintht, 8, A/2+wmax,-sillht, 8, -A/2-wmax,-sillht, -1,

-A/2,0,15, -A/2,B,15, A/2,B,15, A/2,0,15, -A/2,0,-1 DEL 1

!Lintel face ADDz -0.01MATERIAL lmatPRISM 4,winrec+0.05, -A/2-lintwo,B, -A/2-lintwo,B+lintht, A/2+lintwo,B+lintht, A/2+lintwo,B

!Sill Piece ADD -A/2-sillwo,0,winrecROTy 90MATERIAL smatPRISM 5,A+sillwo*2, 0,0, winrec,0, winrec+0.05,-sillht/2, winrec+0.05,-sillht, 0,-sillht DEL 2

END:!————————————————

3D view in the ‘bottomplan view position’showing the wholeassembly of jamb, lintoland sill.

3D camera view, showinghow there are no linesaround the jamb element –buy using 8 as the maskingvalue.

Just to remind you, youonly need to do the jambelement if you havereceding or hollowelements in the window(such as a fanlight). It isntreally necessary in thisparticular model.

It is vital to apply a RESOL command before writing3D text, or your model may be crippled with too manypolygons. Almost every character has curved surfaces.RESOL 9 is the lowest you can go to. Below that youget vertical lines showing. Above, RESOL 8 and 9

Syntax: TEXT depth,0,string

3D Text: Depth is in metres, zero is always zero, String isin quote marks unless it’s a parameter. Height has to be de-fined with DEFINE STYLE. It’s a curious anomaly, that thedefinition of 3D text height is in millimetres. So if you wantthe lettering to be 0.6 metres high (2’-0”) you write in 600 forthe height and write the depth in metres.

DEFINE STYLE ‘3dtextyl’ ‘Times’,600,1,0 SET STYLE ‘3dtextyl’ RESOL 9 TEXT 0.1,0,’3D Text’

If you use G_, H_ and I_,you can get the fill-in parts

around the window to readthe existing wall parameters

3D Text

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 165: Cookbook3_1

2.62

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Glazing AssemblyTHIS GLAZING infil panel could be useful, andthe exercise illustrates:• Using Subroutines to ensure modularity• Using FOR...NEXT loops for repetition• PUT and GET• 2D scripting, better than PROJECT2• Using an Array in the Parameter boxParameters: You should use A to define windowwidth, zzyzx the height. The user is offered a TILT tothe glazing, because when I first did this, the client hadtilted glazing.

Although this is a Glazing system, it is NOT SAVEDAS A ‘WINDOW’ (in the ArchiCAD definition). This isbecause it is designed to sit in a frame constructionbuilding as an OBJECT – not to be punched into a wall.If it’s in a wall, you have to put an empty hole in thewall first.

Transm is an Array and you can click on the arraybutton – make 5 heights, which can be all zero or anycombination of heights.

3D ScriptThe executive script is resolved into subroutines, sothat each part of the model can be separately drawn.

Use the Master Script to set up variables that are NOTin the parameter box, but will be used in the script,such as mulspac. These are ‘internal parameters’ – theyare there to help you, but are not modifiable by theuser.

As this exercise is for general 3D modelling, it doesn’tgo in for special features like mitring the ends of thetransoms – they just cross through the mullions, andbutt against the jamb sections.

PUT & GETThis demonstrates a economical use of PUT and GET.The Mullion outline is PUT once only, in the MasterScript. The 2D and 3D script use the USE(NSP) com-mand, which uses the outline without emptying thebuffer.

Here, asimplifiedmullion is

provided, butyou could CALL

one that existsas a separateobject, if you

were usingproprietary

components –which mayhave been

supplied to youas

manufacturersDXF profiles.

It is all donewith FOR...NEXT Loops

!WindowWall 3D ScriptROTx tiltang !global tiltMATERIAL mmatlGOSUB 100: !Sole & HeadGOSUB 200: !MullionsGOSUB 300: !TransomsIF shoglas THEN GOSUB 600: !Glass

END !-------------------------

150: !Mullion section!simplified AstrawallPRISM NSP/2,len, USE(NSP)RETURN

200: !MULLIONSlen=height-mulwid*2ADDz mulwidFOR k=1 TO numbay+1 ADDx mulspac*(k-1) ROTz -90 GOSUB 150 !Draw it! DEL 2 NEXT k DEL 1RETURN

300: !TRANSOMSlen=A-mulwid*2FOR k=1 TO 5 IF transm[k] THEN ADD mulwid,0, transm[k]+mulwid ROTy 90 ROTz -90 GOSUB 150 DEL 3 ENDIFNEXT kRETURN

600: !SHOW GLASSMATERIAL gmatl ADD mulwid,-0.1,mulwid: BLOCK A-mulwid*2,0.015, height-mulwid*2 DEL 1RETURN

The user enters heightsfor up to 5 transoms inthe array

!WindowWall!MasterScript wid=A height=zzyzx mulwid = 0.05 muldep=0.12 mulspac=(wid-mulwid)/numbay

PUT 0.000, 0.0, 0.000, 0.05, 0.077, 0.05, 0.077, 0.031, 0.106, 0.031, 0.106, 0.05, 0.121, 0.05, 0.121, 0.0, 0.106, 0.0, 0.106, 0.019, 0.077, 0.019, 0.077, 0.0, 0.000, 0.0

If you use GET here(instead of USE),

you will empty thebuffer and no more

mullions could bedrawn

Remember, this is anObject, not a Window.You can make it into a‘window’ by applying a

ROTx -90 to the whole3D thing, saving it as a

window, and writingthe 2D script that I

recommend forWindows.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 166: Cookbook3_1

2.63

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

This window is a portion of a much larger‘Super Window’ project that I am workingon, which contains 10 different windowshapes in one script. This exercise shows twoof them. There is a simpler version of thiswindow in the Discovery section

VALUES "winshape" "Arched","Pointed"VALUES "transom" "None", "Horizontal at Jamb ht"

Values ListThe window shape is a parameter called‘winshape’, and you have a choice ofputting in a ‘transom’. I tend to use Valuelists even for simple Boolean choices, as itis more user friendly, and leaves the op-tion of adding more choices later witheasier coding. Thus, Value lists allow youa more structured approach.

Curvy topped Window

2D ScriptIt is not practical to use PROJECT2 unless the windowis tilted. If you do it hidden line, you cannot see themullions; if you do it wireline, you get a excessive massof detail in the lines.

The 2D script is similar to the 3D script; it draws themullions as a subroutine in a FOR... NEXT loop, usingthe same Subroutine number in each script (here, 150:).The 2D script reads parameters from the main Param-eter box, and also from the Master Script.

!WindowWall – 2D scriptHOTSPOT2 0,0HOTSPOT2 A,0IF tiltang THEN PROJECT2 3,270,2 HOTSPOT2 0,-height*SIN(tiltang) HOTSPOT2 A,-height*SIN(tiltang)ENDIFRECT2 0,0, A,-0.121 !OutlineFOR k=1 TO numbay+1 !Mullions ADD2 mulspac*(k-1),0 GOSUB 150: !mullion DEL 1 NEXT k!GlassRECT2 0.032,-0.1,A-0.032,-0.08END:!-------------------

Remember theGolden rule ofWindow makingis that you build itwith the externalface flat on theground, with theorigin at the mid-width if possible.

150: !Mullion ROT2 -90POLY2 NSP/2,1, USE(NSP) DEL 1RETURN

PREVIOUSLY, making windows any shape otherthan a rectangle was a bit of a nightmare; you had

to construct chunks of wall around the window, in-vesting it with the exact qualities of the wall around it,and paying deep attention to the line drawing of thePRISM that makes the wall, and mimicking in reversethe profile of the window.

ArchiCAD 6 brings you the command WALLHOLEwhich is a boon to all GDL users. You can define anyshape, no matter how complex, providing it does nothave any concavities, and the shape will be made foryou. If you have concavities in the window outline,then you can use additional Wallholes until the job isdone. Thus you can concentrate on building the win-dow only, letting the Wall reshape itself as if made ofliquid, around the window.

This exercise is useful in several things:• Using Value Lists to set up the parameters• Using Arrays to store numbers• Using TUBE command to make the frame• PUT and GET to build elements• Using circle trigonometry to calculate

curvature variables• Using the WALLHOLE command• Making an object stretchy

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 167: Cookbook3_1

2.64

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Curved top window!for GDL Cookbook!Master Script

!Window ShapeIF winshape="Arched" THEN wsh=4IF winshape="Pointed" THEN wsh=8

!Transom OptionIF transom="None" THEN trnsm=0IF transom="Horizontal at Jamb ht" THEN trnsm=1

tothit=B !Total Heightwinwid=A !Window width

ParametersA and B are always the most importantparameters in window design as theseare what make the window stretchy inits outline dimensions.

You need to specify a Jamb height –the difference between the jamb heightand the total height will determine thecurvature. In case the window is to havea flat top, specify a length for the hori-zontal element, ‘winhor’. The frame isdefined (‘fdep’ and ‘fwid’) and the pro-jection of the sill element. Finally, youneed to specify the materials in case theuser has modified the material index forGlass.

Master ScriptHere, it reads and converts the Value listinto numbers, converts A and B into‘english’, checks for user’s errors (suchas negative quantities) on the entry ofparameters ‘winhor’, ‘sillpro’ and‘jamhit’.

!Limit length of window head winhor=ABS(winhor)IF winhor<fwid THEN winhor=fwidIF winhor>winwid*2/3 THEN winhor=winwid*2/3

fd=fdep/2 !Half Frame DepthIF jamhit<=fwid THEN jamhit=fwid

!Sill Checksillpro=ABS(sillpro) !make sure it’s positive

Always parse theValue Lists first

!Curved top window – 3D Script!Part of Super-window!See MASTER SCRIPT for!Parameter organisation

!Array for window X and Y’sDIM winxy[3][60]

!3D Script begins.....................ADDz fdep/2

!Arched Window ))))))IF wsh=4 THEN GOSUB 140

!Pointed Central>>>>>IF wsh=8 THEN GOSUB 180

nfp=NSP/3 !Number of points in frameGOSUB 210:!Store numbers in an arrayGOSUB 250:!Wallhole commandGOSUB 260:!Draw GlassGOSUB 270:!Draw FrameGOSUB 300:!TransomGOSUB 310:!Projecting SillDEL 1

END:!-------------------------

Where did subroutines 100, 110, 120, 130 etc go to?? Theyare part of my ‘Super window’, offering a variety of shapes.

3D ScriptExecutive Script: the array has to be declared beforeit is used. This can either be done in the Master or 3Dscript. Array winxy will hold all the XY locations andmasking values of points on the window frame.

Subroutines 140 and 180 go off and calculate theX,Y coordinates of the outline shape of the window.Then the remaining subroutines perform tasks (as an-notated in the script). These two windows use what Icall the ‘Swing the Cat!’ routine, going around a circu-lar path calculating X and Y using COS and SIN.

SubroutinesCurvature: The two calculations here establish the Ra-dius and sweep angle of the two curves. They appearthe same but are not. The arched window goes fromround to flat, but the pointed window goes from roundto pointed. So ‘curvwid’ and ‘curvhit’ change places.

Control: If the user stretches or shrinks the windowbeyond reasonable limits, you will get an error. Toavoid this, get it to devise a new value for ‘jamhit’ (jambheight), so a new ‘curvhit’ gets calculated which al-ways produces a correct result (avoiding a ‘divide byzero error’).

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 168: Cookbook3_1

2.65

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Remember these rules:• The polygon of points in a Wallhole must not close

up.

• The ones in the Glass MUST close up.

• The ones for the frame must go round an extra twolengths because of the ‘phantom points’.

This highlights the benefit of using an array – withoutit, you would have to do a complete recalculation everytime.

Finally, if the user wants a transom, they can haveit, as a simple block of the same dimension as the frame.I have not built in more complex routines such as smallglazing bars, but you could have a go at this yourself.

180:!Pointed Arch (Gothic style)>>>>>>!Calculate Curve dimensions curvwid=A/2 !width of curved section curvhit=tothit-jamhit !Height of Curve

!Control jamb heightIF curvhit<=curvwid THEN !Minimum jamhit=tothit-curvwid curvhit=curvwid ENDIF !No need to control maximum

angl=(90-ATN(curvhit/curvwid))*2crad=curvhit/SIN(angl)stng=ABS(angl/10) !Stepping angle

!Locate points on the surface-----------PUT -A/2,0,15, -A/2,jamhit,15

FOR k=stng TO angl-stng STEP stng PUT -crad*COS(k)+crad-A/2,jamhit+crad*SIN(k),13 NEXT k

PUT 0,tothit,13 !Centre point

FOR k=angl-stng TO stng STEP -stng PUT crad*COS(k)-crad+A/2,jamhit+crad*SIN(k),13 NEXT k

PUT A/2,jamhit,15, A/2,0,15RETURN

140:!Arched Window ))))))!Calculate Curve dimensions curvwid=(A-winhor)/2 !width of curved section curvhit=tothit-jamhit!Height of Curve

!Allows window to modify jamb heightIF curvhit<=fwid THEN !Control Minimum jamhit=tothit-fwid curvhit=fwid ENDIFIF curvhit>curvwid THEN !Control Maximum jamhit=tothit-curvwid curvhit=curvwid ENDIF

angl=(90-ATN(curvwid/curvhit))*2crad=curvwid/SIN(angl)stng=ABS(angl/10) !Stepping angle

!Locate points on the surface-----------PUT -A/2,0,15, -A/2,jamhit,15

FOR k=-angl+stng TO -stng STEP stng PUT crad*SIN(k)-winhor/2 PUT -crad+curvhit+jamhit+crad*COS(k),13 NEXT k

PUT -winhor/2,tothit,15, !Centre section winhor/2,tothit,15

FOR k=stng TO angl-stng STEP stngPUT crad*SIN(k)+winhor/2PUT -crad+curvhit+jamhit+crad*COS(k),13 NEXT k

PUT A/2,jamhit,15, A/2,0,15RETURN

All that these two routines are doing is calculating theoutlines of the window opening and PUTTING theminto memory. Nothing else.

Note that the Masking value for the points on the Curveare 13, not 15, to make it look smoother. The start andend points are 15, to draw the corners correctly.

‘curvwid’ and‘curvhit’

change places

Section/Elevation view of the two windows.ArchiCAD puts stretchy Hotspots at the corners if youhave built the window with A and B.

Curve topped window

B

angl

A

radius

RAD

win_bul

x=0,

y=B+win_bul-RAD

angl=(90-ATN((A/2)/win_bul))*2

radius RAD =(A/2)/SIN(angl)

Curved top windowsThis diagram shows how to calculate the cen-tre of curvature if you are using a Prism withPolylines, or using the TUBE command to goround the top of a curved window. From thewindow bulge (win_bul) and the width, youcan calculate everything else you need toknow.

CUTEND time saverGetting tired of adjusting the number ofCUTENDs you have to write? Write anumcut=numcut+1 every time you issuea CUTPLANE or CUTPOLY. This routine canbe left at the end of the script and nevercauses an error.

WHILE numcut DOCUTEND: numcut=numcut-1ENDWHILE

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 169: Cookbook3_1

2.66

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

3D view of the two window shapes, set into a wall.If you put the frame thickness ‘fdep’ into the framethickness box in the parameters box, the window canbe pushed deeper into the wall.

!Curved top window!2D Script!for GDL Cookbook!Part of Super-window

ROT2 180!Just to check that 2D works!PROJECT2 4,90,1DEL 1

!Main FrameADD2 -winwid/2,-fdRECT2 0,-fd,fwid,fdDEL 1ADD2 winwid/2,-fdRECT2 0,-fd,-fwid,fdDEL 1!OutlineRECT2 -winwid/2,0, winwid/2,-fdep!SillRECT2 -winwid/2,0,winwid/2,sillpro

!GlassIF gmat THEN LINE2 -winwid/2+fwid,-fd, winwid/2-fwid,-fd ENDIF

210:!Store numbers in an arrayFOR k=1 TO nfp !Put number into array winxy[1][k]=GET(1) !X coordinate winxy[2][k]=GET(1) !Y coordinate winxy[3][k]=GET(1) !Masking for holeNEXT k

!Extend array to enable TUBEFOR k=1 TO 4 winxy[1][nfp+k]=winxy[1][k] winxy[2][nfp+k]=winxy[2][k] winxy[3][nfp+k]=winxy[3][k]NEXT kRETURN

220:!Frame Outline LocationsPUT 0.00,-fd,0, 0.00, fd,0, -fwid, fd,0, -fwid,-fd,0, 0.00,-fd,0np=5 !Number of pointsRETURN

250:!Wallhole command - all typesFOR k=1 TO nfp !Read in array PUT winxy[1][k], winxy[2][k],15 NEXT kWALLHOLE NSP/3,1, GET(NSP)RETURN

260:!Draw Glass for all typesIF gmat>0 THENFOR k=1 TO nfp+1 !Read in array PUT winxy[1][k], winxy[2][k],1 NEXT kMATERIAL gmatPOLY_ NSP/3, GET(NSP) ENDIFRETURN

210: This routineis putting the

contents of thememory buffer

into an array forfuture use. Thesame numbers

are used for theWallhole, the

Glass and theFrame. The array

has to beextended by a

further fourpoints to

accommodatethe TUBEroutine.

220: This routineis defining the

frame outline, tosave having to

type it in againfor each window

type.

2D ScriptIt is always worth starting with a PROJECT2 4,90,1. Thisdraws a wireline from the position and angle that youwould see it if building the window from slabs. Gradu-ally you build in a scripted solution that exactly matcheswith the project2 command.

The Frames, the Outline, the Sill and finally the Glass.

270:!Draw Frame for all typesGOSUB 220:!Get Frame Profile!FrameFOR k=1 TO nfp+3 !Read in array PUT winxy[1][k],winxy[2][k],0,0 NEXT kMATERIAL fmatTUBE np,nfp+3,63, GET(NSP)RETURN

300:!TransomIF trnsm THEN ADD -A/2+fwid,jamhit-fwid,-fd MATERIAL fmat BLOCK A-fwid*2,fwid,fdep DEL 1 ENDIFRETURN

310:!Projecting SillIF sillpro THEN ROTy -90 ADDz -winwid/2MATERIAL fmatPRISM 5,winwid, -fd,0, -fd,fwid, fd,fwid, fd+sillpro,fwid/2, fd+sillpro,0 DEL 2 ENDIFRETURN

The sill is built upright atfirst, then manoevred into

position

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 170: Cookbook3_1

2.67

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

The 6.5 User Interface – part 2ANYBODY who has used the Graphisoft doors

in ArchiCAD 6.5 will recognise that a profoundimprovement has occurred to the user interface, themost noticeable being the arrival of the Pictorial Valuelist. The GDL-writer can now create a whole series ofcustom designed dialog boxes, offering a wealth ofopportunities for better GDL. The manual does not ex-plain how this is done. Let’s look at how to do this,and make some Golden Rules to ensure success.

Let’s make an example objectOpen and examine the object called UI_Tester.gsm.You may want to examine the 3D script in your owntime for examples of PUT & GET, Cutpoly, Revolve,and Polylines, but for this exercise, it isn’t annotatedwith comments.

ParametersThe parameter box is made as below, and of course,the user who like the traditional parameter box canstill enjoy some new features such as hierarchicallygrouped parameters. The Object is defined with theuse of a Value List, placed in the Parameter Script.

The procedure for producing ‘rocking button’cascading parameter boxes is discussed in theDiscovery section.

3D ScriptThis contains a dozen primary object shapes, and aconventional Values List is used to enable these to beselected from the normal parameters box.

VALUES 'objtyp' 'Cube','Cylinder', 'Sphere','Capsule','Dome','Pyramid',

'Cone','Torus','Tincan','Big_Ell','Dish','Handle'

!User Interface demo!GDL Cookbook!3D Script – Executive portion

IF objtyp='Cube' THEN ot=1IF objtyp='Cylinder' THEN ot=2IF objtyp='Sphere' THEN ot=3IF objtyp='Capsule' THEN ot=4IF objtyp='Dome' THEN ot=5IF objtyp='Pyramid' THEN ot=6IF objtyp='Cone' THEN ot=7IF objtyp='Torus' THEN ot=8IF objtyp='Tincan' THEN ot=9IF objtyp='Big_Ell' THEN ot=10IF objtyp='Dish' THEN ot=11IF objtyp='Handle' THEN ot=12

d2=dm/2 !Half size MATERIAL omat PEN pcol RESOL 20GOSUB 100+ot

END:!----------------

The objectsare solely for

the purposeof

demonstratingthe user

interface

Byzanti
Highlight
Byzanti
Highlight
Page 171: Cookbook3_1

2.68

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

This is Page 1 of the object called UI_Tester.gsm. Thefirst page of an object’s UI should contain the primaryuser information such as shape and size. Note thatOUTfields have to be 4-5 pixels higher than an INfield ifthe text is to line up.

If the User Interface Script has any working commands in it, theuser will see an extra button in the settings box, like this. If yourUI dialog has everything needed for the user, then you can hitthe ‘Set as Default’ button to force it to come up when the li-brary part is first opened.

User Interface Dialog – the straightforward approach

HERE is a typical page containing a number of parameternames and Edit boxes and Popup menus, using a simple

XY method of locating the top left of each box.

UI_DIALOG "User Interface Templates",310,266

UI_PAGE 1 !-------- SIMPLE VERSION --------------- UI_STYLE 2,0 UI_GROUPBOX 'Object Configuration',4,24,302,180 UI_OUTFIELD 'Object Type', 12,48+5,160,24 UI_INFIELD 'objtyp', 160,48,140,24 UI_OUTFIELD 'Governing Dimension',12,72+5,160,24 UI_INFIELD 'dm', 160,72,140,24 UI_OUTFIELD 'Material of Object', 12,96+5,160,24 UI_INFIELD 'omat', 160,96,140,24 UI_OUTFIELD 'Pen Colour', 12,120+5,160,24 UI_INFIELD 'pcol', 160,120,36,24 UI_OUTFIELD 'Show Text label', 12,144+5,160,24 UI_INFIELD 'shotext',160,144,140,24 UI_PICT 'objgroup.tif', 5,205,300,30 UI_BUTTON UI_NEXT,'Next Page',180,238,126,24

101:!Cubed2=dm/2PRISM 5,dm, d2, d2, -d2, d2, -d2, -d2, d2, -d2, d2, d2RETURN

102:!CylinderCYLIND dm,d2RETURN

103:!SphereSPHERE d2RETURN

104:!Capsule ADDz d2 ROTy 90 ADDz -d2CYLIND dm,d2 MULz -1ELLIPS d2,d2 DEL 2 ADDz d2ELLIPS d2,d2 DEL 3RETURN

105:!DomeROTy -90FOR k=1 TO 8ROTx k*45PUT 0,d2/5,13,

d2/2,d2/5,13,d2/2,-d2/5,1013,0,-d2/5,15,0,d2/5,15

CUTPOLYA NSP/3,1,0,GET(NSP)

DEL 1NEXT k

PUT 0,d2,1,d2,d2,1,d2,0,901,d2,-80,4001,d2-dm/10,80,4001,d2,d2,1,0,d2-dm/9,1,0,d2,1

REVOLVE NSP/3,360,0, GET(NSP) DEL 1FOR k=1 TO 8 CUTEND NEXT kRETURN

106:!Pyramid$MATERIAL 0ADDz dm*2/3CUTPLANEDEL 1MATERIAL omatPYRAMID 5,dm,63, d2, d2,1, -d2, d2,1, -d2, -d2,1, d2, -d2,1, d2, d2,1CUTENDADDz dm*3/4CUTPLANE 180DEL 1PYRAMID 5,dm,63, d2, d2,1, -d2, d2,1, -d2, -d2,1, d2, -d2,1, d2, d2,1CUTENDRETURN

107:!Cone CONE dm,d2,0.001,90,90RETURN

108:!TorusROTy -90PUT 0,d2/2,901,

d2/4,360,4001REVOLVE NSP/3,360,63,

GET(NSP)DEL 1RETURN

109:!TinCanPUT 0,0,913, d2,360,4013, d2*9/10,360,4013PRISM_ NSP/3,dm, GET(NSP)CYLIND d2/10,d2*9/10RETURN

110:!Big_EllPUT -d2,0,

-d2,dm, 0,dm, 0,d2, d2,d2, d2,0,-d2,0

PRISM NSP/2,dm, GET(NSP)RETURN

111:!Dish ROTz 180CONE d2,d2/6,d2/16,90,30 DEL 1 ADDz d2 ROTy -30PUT 0, 0.001,1,

d2,0.001,901,d2,-45,4001

REVOLVE NSP/3, 360,0, GET(NSP) ROTy 90CONE d2,d2/50, 0.001,90,90 DEL 3RETURN

112:!Door Handle!EscutcheonPUT 0,0,913,

0,-d2/2,13,d2/2,-180,4013,d2,d2/2,13,d2,0,913,d2/2,-180,4013,0,-d2/2,-1,

!Keyholed2, d2/20,15,d2/1.5, d2/20,13,d2/1.5,-d2/

20,1013,d2, -d2/20,15,d2, d2/20,-1

PRISM_ NSP/3,d2/10, GET(NSP)

!Handle ROTz 90CYLIND d2/2,d2/5 ADDz d2/2ELBOW d2/3,90,d2/5 ADD d2/3,0,d2/3 ROTy 90CYLIND d2/2,d2/5 ADDz d2/2ELBOW d2/3,90,d2/5 DEL 5RETURN

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 172: Cookbook3_1

2.69

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Ha! The Holy Grail of the User Interface – The displayis arranged in little tiled images of the contents of the ValueList. This is done with the UI_OUTFIELD command.

Command Statements in the User Interface (UI)

Let’s remind you of the commands inthe UI. For all of these:

• X and Y are the location of the Top Left point ofthe box or button.• Width and Height are the relative dimensions ofthe box or button from that top left corner to the Bot-tom Right corner.• All dimensions are in screen pixels.• Text expressions are either in quotes or can be avariable that contains a string of text.

UI_DIALOG• UI_DIALOG title [, sizex, sizey]

This starts off every UI script, stating that you want aUI, and defining its size. In normal object making thisis fixed permanently at 310x266, but Graphisoft areleaving it open for the design of future interfaces of adifferent size – no longer having to fit into the existingobjects dialog box.

UI_PAGE• UI_PAGE pagenum

You can have many pages in the UI, so they should beclearly numbered, starting from ‘1’. Everything after thiscommand is on the page referred to until the nextUI_PAGE statement. You can move between pages bymaking buttons for ‘Next’ or ‘Previous’ Page. Unfortu-nately, you cannot make buttons for all pages – youmust move page by page.

The GDL writer should write pages in the order ofsignificance – ‘Main configuration’ first page, perhaps‘Colours and materials’ after that, and perhaps ‘2D sym-bol and display’; and then finally you might want toadd a page with ‘User instructions and information’.

UI_BUTTON• UI_BUTTON type,text, x,y, width,height

You can make buttons to go to the Next Page or thePrevious Page. (I hope that buttons will be available infuture versions to do more.)

type: UI_PREV: goto the previous pageUI_NEXT: go to the next page

UI_GROUPBOX• UI_GROUPBOX text, x,y, width,height

Groupbox gives you a rectangular box around a groupof smaller items, and it can be titled, as in the examplehere, ‘Object Configuration’. The words sit at the topof the Groupbox, and break the top line. If the text is ‘’(nothing) the Groupbox is drawn cleanly without text.

UI_SEPARATOR• UI_SEPARATOR x1,y1, x2,y2

A Separator is just a LINE that can be drawn in the box.The manual says that lines can ONLY be Horizontal orVertical, but if you disobey this and define 2 XY loca-tions with a diagonal relationship (as in RECT2) youmay get a GroupBox that does not print a title.

x1, y1: starting point coordinatesx2, y2: endpoint coordinates

UI_PICT• UI_PICT expression, x,y [,width,height]

You can bring a jpg or tif file from a loaded library anddisplay it as a Picture element in the dialog box.

expression:File name or index number of the pic-ture, with its name in full, including 3-letter suffix. Ifyou use an index number of zero (0), it will display thePreview picture of the library part, the advantage be-ing that it doesn’t need to be in the loaded libraries.

width, height: Width and height in pixels; the pic-ture’s original width and height values will be used ifyou leave this blank. If you specify width and height,GDL will squeeze the picture to fit. It is always advis-able to write the width and height, if not the UI isstrangely ‘jumpy’ following parameter changes.

UI_STYLE• UI_STYLE fontsize,facecode

This gives you the choice of three font type/sizes andseveral styles. It uses existing system fonts, and youdo not define an actual font by name – it would causechaos in UI design if you could because the end usermight not have that font. Using system fonts you canbe sure it will work for the user.

Fontsize: On the Mac, fontsize 0 (normal) uses 10-point Geneva, fontsize 1 (small) uses 9-point Genevaand fontsize 2 (large) uses 12-point Chicago. PC us-ers will have fonts of similar sizes like Arial. GDL writ-ers of professional quality must check that their ob-ject’s usser interface fonts work correctly on Mac andPC.

Facecode: similar to the STYLE definition in the GDLManual, but the values cannot be used in combina-tion.

For this, 0=Normal, 1=Bold, 2=Italic, 4=Underline,8=Outline, 16=Shadow.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 173: Cookbook3_1

2.70

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Fonts Display and IF statement: Page 3 shows the varietyof Fonts and Styles available. Use the font size selector tochange the block of text (about Programming) to see howthe font size changes and affects the appearance of the page.If text flows out beyond the limits defined by Width andHeight, it simply gets lost.

IN_FIELD Leading (vertical space between lines) – Page4 of the UI_tester demonstrates this effectively. You canchange the fontsize and the whole page is reformatted witha different value for Leading.

UI_OUTFIELD• UI_OUTFIELD text, x,y, width,height

This allows you to write some text in the UI dialog, forexample the description of a parameter, or some in-struction to the user. We have all been frustrated bylack of space to describe parameters in the old box.Now you have the space to help your user. Maximumlength of the text is 550 letters, so you can write a rea-sonable description. You can also write an IF statementthat changes the text according to the answer. For ex-ample, the text could be displayed in English, Frenchor whatever, and in my example (page 3), the textknows if the object selected is a Cube, a Cylinder orwhatever, and tells the user how the object is made.

UI_INFIELD – the power command• UI_INFIELD “name”, x,y, width,height,versionFlag, pictName, nrImages, nrRows,cellX, cellY, imageX, imageY,imageExp1, text1,...,imageExpn, textn]

This is where the real power of the UI is to befound! The UI_INFIELD can accept user data for Di-mension, Text, Value Lists, Pen colour and all the usualthings either in Edit fields or in Popup menus; but itcan also display a Pictorial Value List (containingthumbnail images of your doors, windows or objects),making it vastly more user friendly. UI_INFIELDknows whether to show an Edit field or a Menu be-cause you have created the parameters and definedtheir type in the main parameter box. If you are usingthe UI exclusively, then you could hide the param-eters from the parameter box so that they are onlyvisible in the UI. The example on the previous pageshows a variety of UI_INFIELDs including Value list(text), Dimension, Material, Pen and Boolean. If as aresult of your choice, other things change (e.g if userselects a circular object, you need to ask the user ques-tions about diameter, and if user selects a polygonalone, you need to ask about sides) then the Interfacescript is re-read and the current page is rebuilt – itcauses a slightly annoying delay, but when you knowwhy it is doing it, you can live with it.

name: Parameter name (defined in the parameter settings)

x, y: The position of the edit text, popup or control

width, height: width and height in pixels

That is all you need for normal Edit field or Popdown INFIELDs.

If you wish for a Pictorial ValueList, you need tohave defined the ValueList first, and then you need thefollowing:

versionFlag: Reserved, so for now, always put 1 in there.

pictName: Name of the image file (jpg or tif) con-taining a gridded arrangement (matrix) of images (asdescribed earlier), in the order in which you want themto be seen.

nrImages: Total number of images in the matrix

nrRows: Number of rows of the matrix

From ‘nrImages’ and ‘nrRows’, GDL works out the ar-rangement and will cut the image of the matrix up intoequal tiles and use them in order from top left to bot-tom right.

cellX, cellY: Width and height of a cell as you wishthem to be seen within the Pictorial ValueList field, in-cluding the image – and the text which must fit thespace, of course.

imageX, imageY: Width and height of the image tilethat is to be fitted into the Cell – this must be smallerthan the CellX and CellY or there will not be space forthe text.

Now you follow with a list of the index numbers andnames of each image tile, in the same order – from topleft to bottom right.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 174: Cookbook3_1

2.71

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Write a User’s Manual! – Page 5 demonstrates how you could usethe UI to write a user’s manual for your object, or insert a copyrightnotice or manufacturer’s address and email. Remember that themaximum letters in one OUTfield is 550.

imageExpi: index number of the i-th image tile in the matrix,starting with 1.

texti: text name in the i-th cell.

For example:- 1,’Cube’,2,’Cylinder’,3,’Sphere’ and so on.

Well that sort-of explains it (in slightly more words thanin the manual) but you will find on these pages a de-tailed description of the process, and of course you haveUI_Tester.gsm to play with and examine until you getthe hang of it.

You want a Pictorial Value List?

T HE first step to making a user interface that incorporates a Pictorial Values List is to generate all the 3D or

Rendered views of your object or objects.

Put them into Photoshop (or similar) and arrange them in avery orderly grid. The graphic matrix in this example is 270x360pixels so that the objects are perfectly arranged in 4 rows acrossof 3 across, with 90x90 pixels each. Set your ArchiCAD render-ing window to 90x90 and patiently produce, then copy andpaste each image into one file. The grid does not have to be inthe same arrangement as it will be seen in the dialog box, but ithelps enormously in composition if you arrange it as you wishthe user to see it. You could make the original image larger, togive you space to move the tiles about, and then re-pixellatedown to the final size. Apply a sharpen filter on the final image.

The order of the tiles should match the sequence of choicesin the Value list, and the same order must be applied in the listof indexes in the UI_INFIELD statement. The tiled image shouldbe kept in the same library folder as your Macros.

Pictorial Value list guidelines• Order – In a typical UI page, write all the other parametersstatement first before you write the code for a PVL.

• Field sizing – When you have a Picture list that containsmore images that can fit in the window at once, a scroll bar of19 pixels width will appear at the right hand side.

The practical usable area with a scroll bar has a maximumwidth of 279 which allows five cells of 52 each, four cells of 65each, three cells of 86 each, or two of 130 each (taking intoaccount the 19 pixel edge width). The Pictorial Value lists inGS’s single leaf doors use 4 cells of 65 width each.

Practical field height is 210, so a cell should be 102-105 forthe images to appear cleanly. Try to make your Photoshop filethe same width as the field of cells, otherwise GDL has to stretchor squeeze the image tiles to fit the space allotted – and this canresult in distortions or unexpected aliasing.

• File format – Although TIFs always work well, you can safelyuse TIFs with LZW compression, or JPEGs.

• Cell sizes – The Cell height MUST be at least 22 pixels higherthan the Imagetile or the text will be omitted. Cell size must beat least 4 pixels higher than the Imagetile.

• Complete the list – If the item in the Value list is omittedfrom the list in the UI_OUTFIELD command, the item will beomitted from the Pictorial Value list. The new look of Library objects with a UI

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 175: Cookbook3_1

2.72

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

UI Design GuideSome golden rules, warnings, advice and notes

• Preview – As you build the Interface script, youcan keep clicking on the Preview button to see how itis going. If you have made a mistake, you usually get ablank grey UI dialog box. Do not panic, check throughyour script for errors.

• UI_Box size – because the box has a surround line,the realistic design size is 308x264 pixels, not 310x266.

• Long texts – in the UI_OUTfield, text blocks workout their own wordwrap on a Lefthand justified basisand if the text (with your choice of font and style) ex-ceeds the box size, it just gets lost. The text all has tobe written on one line in the GDL Interface script win-dow (which is difficult), and has an absolute limit of550 letters (or bytes).

• Leading – (the distance between lines of text) isvery important, as it has to work with the INfield boxeswhich have their own leading. If you do not get Lead-ing right, your UI dialogs will look untidy, and youwill have to use trial and error. I have done researchinto leadings for OUTfields and INfields, to save youhours of guesswork.

For OUTfields, the inbuilt leading of a continuousflow of text is 13 pixels for fontsize 0, 12 pixels forfontsize 1 and 16 pixels for fontsize 2.

For INfields, the edit boxes set themselves, and seemhave a default height of 20 pixels high for size 0, 15high for fontsize 1, and 23 pixels high for fontsize 2,regardless of what you set height to. My recommendedminimum Leading for INfield boxes is 4 pixels morethan the height, i.e. 24 for f’size 0, 19 for f’size 1, and27 for f’size 2.

INfield boxes have shadows round them, to simu-late a hole for Edit fields and a button for Popup menufields (which are included in the Leading figures givenhere). For this reason, Popups look 2 pixels longer thanEdit fields of identical size, so you could artificiallyshorten them.

INfield boxes do very wierd things if you do not getleading and height right according to the numbersabove. If you set the Height to less than the above fig-ures for whichever font, they have their own mind.The rule they follow is: Go to the XY location required;Measure downwards the silly height that in in the script;then measure UPwards the height that the INfield boxought to be. Result is that they appear higher than youwanted.

• DPI issues – Mac screens are different to PC andyou need to program the UI on both machines to besure they work. Infields may not line up with Outfieldsand UI_Picts and scrolling value lists may look quitedifferent! Programming on a Mac first is the easiest,and then tweak it for the PC if necessary.

• Lining up Fields – INfield boxes place the text inthe centre of the box vertically and left justified hori-zontally, whereas text in an OUTfield sits lower in itsrectangle. Therefore, if you wish the text of anOUTfield box to line up with text in an INfield, thenthe XY start of the OUTfield has to be 4-5 pixels higherthan the INfield.(I say ‘4-5’ not ‘4 or 5’ because it isinconsistent)

• Hide Parameters? – if you depend entirely on theUI, then you still need to make the parameters in theparameter settings box, but you may (as in my exam-ple) have a parameter that only has relevance to theUI dialogs; so for that one, you need to click on the‘Hide Parameter’ button so that the user does not getconfused.

• Lock Parameters – some parameters only refer tocertain conditions – for example if the object is circu-lar, then there are questions about diameter and sur-face smoothness. If the object is polygonal, there arequestions about edges – so the smoothness questionsshould be locked. You cannot dynamically Hide a pa-rameter, so the next best thing is to Lock it. You canuse the LOCK command (in the Parameter Script) tolock out parameters that are not relevant to the user’schoice. In the UI, you can have alternative Pages (us-ing a long IF statement) depending on the user’s choiceof object.

• Indents – (X value in boxes and fields) should be12 if you want it to line up with the Title of the dialogbox; if you use a Groupbox, the relative indent willstill be 12. So you should indent OUTfields to 12+theindent of the Groupbox, and the texts will line up withthe Groupbox title.

• PEN – Best width for a PEN INfield is 36 – this willgive you a nice square palette box.

• Buttons – (for Next and Previous pages) are alwaysin fontsize 2 (large) so you need to allow for this. Mini-mum height for a button is 20 high, 24-26 is safe andgood looking. The button should float about 2 pixelsclear of the boundary at the bottom, so I recommend amaximum Y value of 238 for buttons 24 high. Insteadof writing Next and Previous, you can write the titlesor descriptions of the next or previous pages.

• Warning! – Use the UI Preview button to see howyour box is looking, but on no account use the actualfields to change parameters. They may not work, butworse, they may crash your ArchiCAD, and even worse,they may case the script to be erased.

Web Plug in – If *any* UI commands are used, theWeb Plug in will always default to view the UI first,even if the ‘set as default’ button has not been pressed.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 176: Cookbook3_1

2.73

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

UI_DIALOG "User Interface Templates",310,266

UI_PAGE 1 !----------------------------------------- UI_STYLE 2,0 led=24 !Leading of Infield Boxes dy =0 !Distance downwards in Ydy=dy+led UI_GROUPBOX 'Object Configuration',4,dy,302,led*7.5dy=dy+led UI_OUTFIELD 'Object Type',12,dy+5,160,24 UI_INFIELD 'objtyp',160,dy,140,24dy=dy+led UI_OUTFIELD 'Governing Dimension',12,dy+5,160,24 UI_INFIELD 'dm',160,dy,140,24dy=dy+led UI_OUTFIELD 'Material of Object',12,dy+5,160,24 UI_INFIELD 'omat',160,dy,140,24dy=dy+led UI_OUTFIELD 'Pen Colour',12,dy+5,160,24 UI_INFIELD 'pcol',160,dy,36,24dy=dy+led UI_OUTFIELD 'Show Text label',12,dy+5,160,24 UI_INFIELD 'shotext',160,dy,140,24dy=dy+led UI_STYLE 1,0 UI_OUTFIELD 'Page 1:Object config; Page 2:Pictorial Values list;', 12,dy, 290,16 UI_OUTFIELD 'Page 3:Fonts display; Page 4:Infield leading; Page 5:Explanation',12,dy+16,290,16

UI_PICT 'objgroup.tif',5,205,300,30 UI_BUTTON UI_NEXT,'Pictorial Selector',180,238,126,24

1Here, I have used variables called ‘led’and ‘dy’ so that I can experiment with dif-

ferent Leadings. As there are 5 pages, anOUTfield in small font tells the user what theother pages contain. The UI_PICT will squashdown to the specified size 300x30, but if youmake it that size first, there is less distortionand quicker display.

User Interface – all the bells and whistles

2When you get it right, it is amazing howshort the script needs to be!

UI_PAGE 2 !------------------------------------------UI_STYLE 2,0UI_OUTFIELD 'Pictorial Selector',10,25,200,25UI_INFIELD 'objtyp',4,20,300,210, 1,'objselector.jpg',12,4,

92,102, 80,80,1,'Cube', 2,'Cylinder',3,'Sphere', 4,'Capsule',5,'Dome', 6,'Pyramid',7,'Cone', 8,'Torus',9,'Tincan', 10,'Big_Ell',11,'Dish', 12,'Handle'

UI_BUTTON UI_NEXT,'Font display', 180,238,126,24 UI_BUTTON UI_PREV,'Object Config', 3,238,126,24

!User Interface Demo!2D Script

PEN pcolPROJECT2 3,270,2HOTSPOT2 0,0

IF shotext THENDEFINE STYLE 'otxt' 'Arial', (dm/6)*1000/A_,5,0SET STYLE 'otxt'TEXT2 0,0,objtypENDIF

2D scriptWhatever youmake, howeverclever, it will stillonly be a littleblob in your floorplan unless youmake a 2D script!

Turning Pages in the UI

AT the moment, you have to go through pages in se-quence. It would be great if you could select the page

you wanted to go to directly: e.g. ‘2D Settings’, ‘Materials’,‘Options and Info’, and so on.There is an Appendix to the Cookbook which illustrates atechnique to overcome this missing feature.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 177: Cookbook3_1

2.74

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

3This page displays a variety of font sizesand styles (using random numbers) and

shows how an IF statement can be used tochange the contents of the dialog box. As‘fontui’ for the font size is only used in theUI boxes, it remains hidden in the param-eter box.

This also demonstrates that you can usea FOR... NEXT loop in the UI, once you haveworked out line spacing etc.

IF statements and Loops can be risky inUI scripts (instability, risk of crash etc) sodo it to a copy of your file.

UI_PAGE 3 !------------------------------------------IF objtyp='Cube' THEN odstr='Use a cubic PRISM'IF objtyp='Cylinder' THEN odstr='Make with CYLIND'IF objtyp='Sphere' THEN odstr='Make it with SPHERE'IF objtyp='Capsule' THEN odstr='Use CYLIND + ELLIPS'IF objtyp='Dome' THEN odstr='Use REVOLVE+CUTPOLYA'IF objtyp='Pyramid' THEN odstr='Easy! Use PYRAMID!'IF objtyp='Cone' THEN odstr='Easy! Make with CONE'IF objtyp='Torus' THEN odstr='REVOLVE a circle'IF objtyp='Tincan' THEN odstr='Circular hollow PRISM'IF objtyp='Big_Ell' THEN odstr='Make it with a PRISM'IF objtyp='Dish' THEN odstr='Use CONE and REVOLVE'IF objtyp='Handle' THEN odstr='Use PRISM, CYLIND,ELBOW'

spa=16 !Pixels per line for texttextstring1='Your object is a '+objtypUI_STYLE 2,0 !title of pageUI_OUTFIELD 'Font display',4,16+5,150,24UI_SEPARATOR 4,38,300,38

!Display of random sizes + stylesFOR k=44 TO 210 STEP spa*2 UI_STYLE INT(RND(3)),INT(RND(5)) UI_OUTFIELD textstring1,4,k,156,spa UI_STYLE INT(RND(3)),INT(RND(5)) UI_OUTFIELD odstr,4,k+spa,156,spa NEXT k

!Long Text block with Font selectionUI_STYLE 0,1 !select font size for textUI_OUTFIELD 'Font size below>',160,16+5,99,20UI_INFIELD 'fontui',260,16,46,20x=SPLIT(fontui,'%n',fntui)UI_STYLE fntui,0UI_OUTFIELD 'Programming – A program is just a sequenceof instructions. You can read instructions to someoneover the telephone, you can struggle through the instruc-tions for setting the controls on your new video. Thats aprogram!',160,44,148,180 UI_BUTTON UI_NEXT, 'INFIELD leading',180,238,126,24 UI_BUTTON UI_PREV, 'Pictorial Selector', 3,238,126,24

UI_PAGE 4 !------------------------------------------- UI_STYLE 2,0 !Title of pageUI_OUTFIELD 'INFIELD Leading',4,16+5,150,22UI_OUTFIELD 'Font size below>',130,16+5,99,22UI_INFIELD 'fontui',215,16,90,24x=SPLIT(fontui,'%n',fntui) UI_STYLE fntui,0IF fntui=0 THEN spa=24 !Pixels per line for INFIELDIF fntui=1 THEN spa=19 !Pixels per line for INFIELDIF fntui=2 THEN spa=27 !Pixels per line for INFIELDleding="Leading="+STR(spa,2,0) !print string in boxUI_SEPARATOR 4,40,300,40

FOR k=45 TO 210 STEP spa UI_OUTFIELD 'Infield size',4,k+5,124,spa UI_OUTFIELD leding,215,k+5,90,spa UI_INFIELD 'dm',130,k,80,spa NEXT k UI_BUTTON UI_NEXT, 'Explanation',180,238,126,24 UI_BUTTON UI_PREV, 'Font leading',3,238,126,24

4Note that by using the SPLIT command, one can avoid several lines of

IF statements to parse Value list of font sizes.When you change the font size, the box isreformatted to demonstrate the importanceof Leading.

Long texts have to be written till they hitthe extreme right hand end of the scriptwindow – maximum 550 letters!

Visual GDL and coloured script

Visual GDL was abandoned as a product at the end of the life of AC5.Pity… It was over priced and difficult to get hold of, but it did allow

solid modelling which converted into scripts. Many of us (GDL users)wish that Graphisoft would bring back a good feature of VGDL, whichwas coloured script. Commands one colour, comments another, vari-ables and numerals another – it is common to other languages likeC++, and helps the programmer in both writing and debugging.

Byzanti
Highlight
Byzanti
Highlight
Page 178: Cookbook3_1

2.75

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

5Getting started with the User Interfaceis a bit painful, but in some ways, it’s

just another form of 2D scripting, and getseasier as you do more of it. You also findthat your vocabulary of things-you-can-do-with-UI gets more sophisticated as you domore of them.

Mental Health Warning!

ALTHOUGH I have used IF-statements (and so do Graphisoftin the manual), DO NOT USE IF-statements in the UI script

unless strictly to do with UI matters. IF-statements regardingparameters can result in a crash in which half or more of the param-eters delete themselves, and the ones which are left change to valuesof zero or near-infinity. Parameter changes and error checks can bemade in the PARAMETERS script.

Although the guidelines here are meant to make it easier, you stillneed a paper and pen and a lot of trial and error to get the UI just right.Build ALL the parameters you are going to want first before you designor build the UI; adding latecomers to the UI is a painful nuisance. Andafter you have saved graphics for use in the UI, don’t forget to reloadlibraries.

When you Preview the UI, do not use it to alter parameters!This causes a crash. If you wish to change a parameter, go back to theparameter box. If you wish to test a UI dialog, do it by saving and alterthe settings in the normal ArchiCAD environment.

UI_PAGE 5 !-------------------------------------------- UI_STYLE 2,0UI_OUTFIELD 'Explanation of the UI_exercise', 12,20,290,24UI_STYLE 0,0UI_OUTFIELD 'The first page was a typical page that youmight use to replace the normal parameters box.',12,36,290,28UI_OUTFIELD 'The second page was a demonstration of aPictorial Values List, e.g. for a Door library.',12,68,290,28UI_OUTFIELD 'The third page was a demonstration of ways ofdefining fonts and styles. Try changing the font. It alsodemonstrates IF statements in the User interface',12,100,290,42UI_OUTFIELD 'The fourth page demonstrated the differentleadings of INFIELD boxes for different fonts. Leading isthe space between successive lines of type.', 12,146,290,42UI_OUTFIELD 'The fifth page demonstrated how you can use apage of the User Interface to provide a detailed usersmanual.', 12,192,290,28 UI_STYLE 0,1UI_OUTFIELD 'Good luck with your attempts to build the UserInterface!',160,220,140,42 UI_BUTTON UI_PREV,"INFIELD leading",3,238,126,24

!Fire Extinguisher 3D!Discovery and Voyager

!Bottle BodyMATERIAL 'fxmat'PEN pcolRESOL 16 ROTy -90REVOLVE 4,360,63, 0 ,d/2,1, zzyzx-0.06,d/2,1, zzyzx ,d/6,1001, zzyzx ,0.00,1DEL 1

!HandleMATERIAL 'hanmat'RESOL 8 ADDz zzyzxCYLIND 0.03,0.03 ADD -0.03,0,0.06 ROTy -110MATERIAL 'nozmat' CYLIND 0.05,0.01 DEL 2 ADDz 0.03 ROTx 90 ADDz -0.02

MATERIAL 'hanmat'PRISM_ 9,0.04, -0.03,0,15, -0.04,0.05,15, 0.11,0.10,15-2, 0.12,0.09,1015, 0.03,0.05,15, 0.12,0.01,15, 0.12,0.00,15, 0.03,0.03,15, 0.03,0.00,15DEL 4

Fire Extinguisherrevisited: Materials andInterface (next page)

3D ScriptThere are few changes to the 3D script,except to insert the new material com-mands for hanmat and nozmat.

Laurent’s Advice on UIby Laurent Godel1. Smart page turning: forget UI_PREV and UI_NEXT, try to use the onedialog with a variety of ways of building it using check boxes, pull downmenu, or (best of all) PVL. (See appendix in Cookbook 3)2. Avoid jumpiness: fully specify UI_PICT statements, and put PVL cod-ing at the end of a page building routine.3. Reduce the use of OUTFIELDs if this can be done with Graphics (al-though these need lots of little graphics to be in the loaded libraries) –reduces difficulties of translation/localisation.4. Follow the structured programming philosophy of the Cookbook!

GDL and PDF combine?Adobe's Acrobat and its WONDERFUL pdf format are on their way tobecoming a worldwide standard for electronic publishing. Is it indeedsilly to dream there could be a GDL plugin for Acrobat Reader? Acrobatnow supports anything bi-dimensional- text, pictures, movies, sound(2D sound?), but no 3D. The plugin could behave much like the one forweb browsers, showing objects in 3D directly inside the reader win-dow.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 179: Cookbook3_1

2.76

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Fire Extinguisher revisited: UI

THIS Fire Extinguisher may be a humble object indeed, but it is an excellent vehicle for GDL teach-

ing. In a more sophisticated model, you want a Userinterface and more control over materials.

This object contains:• A good way to define a new material from a

pen colour• Easy User Interface script

VALUES 'fxtype' 'Water','Halon', 'Powder','Foam', 'CO2','Free colour'

!Fire Extinguisher!PROJECT2 3,270,2

ARC2 0,0,d/2,15,345CIRCLE2 0,0,0.03RECT2 -0.04,0.02, 0.12,-0.02

IF fxtype<>'Free colour' THENIF fsize>0 THEN DEFINE STYLE "ftext" Arial,fsize,2,0 SET STYLE "ftext" TEXT2 0,0,fxtypeENDIFENDIF

!Master ScriptIF fxtype="Water" THEN pred=0.6:pgrn=0.0:pblu=0.0ENDIF

IF fxtype="Halon" THEN pred=0.0:pgrn=0.6:pblu=0.0ENDIF

IF fxtype="Powder" THEN pred=0.0:pgrn=0.0:pblu=0.6ENDIF

IF fxtype="Foam" THEN pred=1.0:pgrn=1.0:pblu=1.0ENDIF

IF fxtype="CO2" THEN pred=0.0:pgrn=0.0:pblu=0.0ENDIF

IF fxtype='Free colour' THENPEN bcol

x=REQUEST("Rgb_of_pen",bcol,pred,pgrn,pblu)ENDIF

DEFINE MATERIAL 'fxmat' 4, pred,pgrn,pbluDEFINE MATERIAL 'nozmat' 4, 0.8,0.8,0.8DEFINE MATERIAL 'hanmat' 4, 0.1,0.1,0.1

UI_DIALOG 'Fire Extinguisher types'

UI_INFIELD 'fxtype',20,16,272,245,1,'firex_ui.tif',6,2,82,230,70,210,1,'Water',2,'Halon',3,'Powder',4,'Foam',5,'CO2',6,'Free colour'

Make the tiledimagesBefore making anyvisual user interface,you have to dump aseries of images intoa photoshop fileand organise theminto tiles. thisgraphic is 278x458pixels – enough forthree images toshow at once.

Update the Parameters box. Make the main type selec-tor Bold because that is the most important selectioncriterion. Add a new pen parameter and update theValue list to include the free choice of colour.

Remove hcol for the handle – we will define a newmaterial. Previously, we used Pen colour to define thematerial for the handle, by making material value tozero. The REQUEST technique used here in the Masterscript is far more effective.

Update the 2D script tohide the label if the user

makes a free choice (theycan label it themself).

You may have to do some tweaking ofthe numbers in the Infield commandbefore it finally works. Before you get

a result, remember to ‘ReloadLibraries’ after you have saved the

tiled image.

Define two newmaterials for the

Nozzle and theHandle to makesure they are the

right colour.

This routine isincredibly useful.The user specifies aPEN colour and the

REQUEST commandbreaks the pen into

Red, Green andBlue and makes anew Material from

it. The ‘plastic’material type 4 is the

most useful formaterial making(‘metallic’ is too

dark).

See previous page for the 3D Script

BUG! Do not test the Value List in the Preview window ofthe UI or you may delete parameters and your object.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 180: Cookbook3_1

2.77

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Let’s make a Door!

A cascadedparameter boxturns into this

tidy little result

Door leafSeveral varieties ofdoor stored asmacro objects

Door handleSeveral varieties ofhandle stored asmacro objects

DoorThe Wallhole, Doorframe, Parameterorganisation and User interface – callsthe leaf and door-handle macros

ImageBit map im-age of doorsarranged intiles

Exercise andcase study

This door is the most comprehensive exercise inthe GDL Cookbook. It looks at:• WALLHOLE command• TUBE command• PUT & GET used extensively• PRISM with holes drilled• Macro calling – doors and handles• 2D scripting, including scale-sensitivity• The secrets of flipping/rotating door in wall• User Interface and Pictorial Value List

DOORS are plentifully available in the ArchiCADLibrary and on object sales on the Internet, but

you still need to know the secrets behind doors in caseyou have to make one. You may be surprised to findthat they are much more difficult than windows. Thisis mainly because they can rotate and flip and presentdifferent opening options than windows. They aremore likely to be calling macros because of the manypossible styles in one frame and the ironmongery.

The door in the OMWAC should be studied first asthis is very simple. A more sophisticated door will in-clude issues of a user interface, macros, capability ofbeing flipped and rotated, a variety of door styles, dif-ferent rotating angles and scale sensitive representa-tion. All of these are tackled in this example.

Rules of doorsRemember, the primary rule about doors and windowsis that they should be built flat on the floor, and thatthe floor surface – the XY plane – represents the exter-nal face of the wall that the window/door will fit into.‘A’ represents the width of the door and ‘B’ will be theheight of the door – when it is upright in a Wall.

The hole in the wall can be cut automatically as arectangle of width A and height B, but it is better toissue a WALLHOLE command and be in control of jambmaterials and to retain the option to make arched orcomplex openings.

From ArchiCAD, select from the File menu>New Li-brary Part> Door. (You can build the door as an Objectfirst and transform into a Door later.)

ParametersThe parameters here follow Graphisoft’s list of recom-mended parameter names. These are recently pub-lished in their professional guidelines (downloadablefrom the Graphisoft website).

The parameters are added in as you need them. Theframe is part of the door script, but the doors and thehandles are best built as Macro objects, so that theycould be used in other types of door assembly, e.g.double doors, doors with porchframes, doors withcurved fanlights above, etc. Any quality object withmore than 5 parameters should be grouped with cas-cading organisation, as shown here.

OrganisationThe door could be made as an integrated whole, but itwould be very complicated, and would require a lot ofcopying and pasting and reorganisation if you decidedto do the same for a double door set or one with curvedfanlights. Using Macro objects for the common objectsmeans that the primary door object is concerned solelywith the Frame, Opening shape and User interface. Thisrequires more typing now, but less work in the longrun. The macro objects can be stored tidily in their ownfolders.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 181: Cookbook3_1

2.78

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Example Door, using Tube!and Prism: Voyager!3D Script

PEN pcol

!WallholeMATERIAL jmatPUT A/2,-B,15, A/2, 0,15, A/2, B,15, -A/2, B,15, -A/2, 0,15, -A/2, -B,-1WALLHOLE NSP/3,2,GET(NSP)

IF dort=0 THEN END:!No door

!FrameMATERIAL frmatPUT 0,0,0, 0,frt,0, frw+0.01,frt,0, frw+0.01,lt,0, frw,lt,0, frw,0,0, 0,0,0 profpts=NSP/3

PUT A/2,-B,0,0, A/2, 0,0,0, A/2, B,0,0, -A/2, B,0,0, -A/2, 0,0,0, -A/2, -B,0,0 pathpts=(NSP-profpts*3)/4

BODY -1TUBE profpts,pathpts,63,GET(NSP)BODY -1

Note that at this level itmakes sense to use PUTand GET for all forms –

this avoids annoyingerror messages when

you get the profilesslightly wrong.

There are threenumbers for each

point on theprofile.

There are fournumbers for each

point on thepathway.

VALUES 'ls' 'Empty','Flush', '1-panel','2-panel', '3-panel_a','3-panel_b', '4-panel','Circular'

The Values list in the Parameter script

3D ScriptThe primary purpose of the door object is the opening and frameso these get done first. The Wallhole is not really necessary butit’s here for two reasons – it allows you to control the colour ofthe jamb (reveal) where the wall is cut, and it demonstrates theeasy syntax of WALLHOLE.

This use of TUBE for the door frame is important if you wantto have features like a rebate in 3d and to adapt it for circular orgothic door heads. This method of building a TUBE is a classic.Copy the idea and use it for all tubes. First, it outlins the frameprofile with a long PUT statement, then stores the number ofpoints in a variable profpts. Then the next PUT statement liststhe XYZT locations (not forgetting the phantom points) andrecords the number of points in another variable pathpts. TheTUBE command itself is now incredible simple, it’s one line thatcannot cause an error because your variables have counted thepoints correctly. Just use BODY -1 either side of the TUBE toprevent a rendering error by ArchiCAD.

If you were a manufacturer you might make the openingsizes ‘snap’ to the known dimensions of your door range, oryou could allow the opening to be stretchy but adapt the widthof the frame. This is a design and manufacturing decision; what-ever you decide to do is easy enough in GDL.

Now make the door – make a macro!Work out how many door types you will want in this frame.Include an empty frame (as a courtesy to your user). Since youwill want to make a pictorial value list, try to make enoughdoors to make a grid of little images, perhaps 4 across and 2down (8 doors) or 3 across and 4 down (12 doors) – dependson the size of the doors. It’s useful to think ahead.

This is an image of the final set of doors, with a variety ofglazing/panelling options. When the door is finished, youshould make a picture file like this.

Now for the actual doors. We make them elsewhere as MacroObjects. GS advise that macro objects are better than writingjust a macro script, because you have the pleasure of writing acomplete working object, with its own little set of parameters,a preview window and even a temporary 2D script so that youcan build up an ArchiCAD file to view and organise your macroobjects.

Each filetype has its own naming conventions and icons, andmust be in loaded libraries. For this Door to work, you needthe main object, the photoshop file of all the doors, the doorleafand doorhandle macros all to be in loaded libraries – which iswhy I generally prefer to make objects fully integrated exceptin the case of manufactured products.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 182: Cookbook3_1

2.79

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Main Leaf – Macro ObjectMATERIAL lmat1lfr=lw/6PUT 0,0,15, 0,lh,15, -lw,lh,15, -lw,0,15, 0,0,-1

PUT -lfr,lh/3,15, -lfr,lh-lfr,15, -lw+lfr,lh-lfr,15, -lw+lfr,lh/3,15, -lfr,lh/3,-1

PRISM_ NSP/3,lt,GET(NSP)

!Panel or Glass ADDz lt/4MATERIAL lmat2PUT -lfr,lh/3,15, -lfr,lh-lfr,15, -lw+lfr,lh-lfr,15, -lw+lfr,lh/3,15, -lfr,lh/3,-1PRISM_ NSP/3,lt/4,GET(NSP)DEL 1

Macro Object 3D ScriptMacro Object Parameter box, and the door leaf

The hole andthe glass have

the same XY list

!Example Door, using Tube!and Prism: Voyager!Master Script

!Door parameterslw=A-2*frw !Leaf widthlh=B-frw !Leaf height

!Error CheckingIF opa3>90 THEN opa3=90IF opa3<0 THEN opa3=0

!Value List parsingIF ls='Empty' THEN dort=0IF ls='Flush' THEN dort=1IF ls='1-panel' THEN dort=2IF ls='2-panel' THEN dort=3IF ls='3-panel_a' THEN dort=4IF ls='3-panel_b' THEN dort=5IF ls='4-panel' THEN dort=6IF ls='Circular' THEN dort=7

!3D Script continued!from previous panel

!Door ADDx lw/2 ROTy -opa3GOSUB 200+dort DEL 2

DEL TOPEND:!___________________

200:!Empty Space!Nothing to doRETURN

201:!Flush DoorMATERIAL lmat1PUT 0,0,15, 0,lh,15, -lw,lh,15, -lw,0,15, 0,0,-1PRISM_ NSP/3,lt,GET(NSP)RETURN

202:!1-panelCALL dor01_macro65 PARAMETERS lmat1=lmat1, lmat2=lmat2,lw=lw,lh=lh,lt=ltRETURN

203:!2-panelCALL dor02_macro65 PARAMETERS lmat1=lmat1, lmat2=lmat2,lw=lw,lh=lh,lt=ltRETURN

204:!3-panelCALL dor03_macro65 PARAMETERS lmat1=lmat1, lmat2=lmat2,lw=lw,lh=lh,lt=ltRETURN

205:!3-panel_aCALL dor03b_macro65 PARAMETERS lmat1=lmat1, lmat2=lmat2,lw=lw,lh=lh,lt=ltRETURN

206:!'4-panelCALL dor04_macro65 PARAMETERS lmat1=lmat1, lmat2=lmat2,lw=lw,lh=lh,lt=ltRETURN

207:!'CircularCALL dorc_macro65 PARAMETERS lmat1=lmat1, lmat2=lmat2,lw=lw,lh=lh,lt=ltRETURN

Making the Door-leaf Macro ObjectFor an easy life, use the same parameter names as you used inthe main door file. Make the door flat on the floor. On the CDwith the Cookbook, there are 6 such files; here is the one with asingle panel (glazed or solid). Once you have made one door,you can duplicate the macro objects, rename them, and thenadapt each one’s 3D script to reflect the correct number of panes.This way, the work of writing in all the parameter titles is a onceonly. The hole in the prism has exactly the same XY list as theglass that fits it, so by using PUT, you can economise – write itonce for the door, then copy and paste for the glass.

Master ScriptNow you write in the error checking routine and the Value listparsing routines. The size of the door is worked out from theframe (this door is stretchy – remember that if your client hasfixed door sizes then you might have to make the opening sized‘snap’ to preset sizes). The opening angles need to be limitedto a normal sweep. You could write a similar argument for the2D opening angle. The value list result is converted into a FLAG,called dort.

3D script againThe flags enable one to use a series of subroutines whose num-bers are based on the flags. the single command GOSUB200+dort will produce all of those doors! Very economical!

The door needs to hinge off one frame. It is a houserule inGDL that doors hinge offthe right hand frame un-less they are mirrored. Forthe door to hinge correctly,you must move the 3D cur-sor to the right hand frameand build the door fromthat point. Rotate the doorby the opening angleopa3, and gosub that door.

The first value is emptydoor opening, so 200 doesnothing. 201 is a flushdoor, so it is built withinthe main door object, notcalled from a macro. Thisis the prototype for all themacros which are similar,but all have glazing panels.

The remaining subrou-tines are all identical apartfrom different labels and

The parameters here have all the same names in the Macro objects – the doors. In this case,you could write ‘CALL dorc_macro65 PARAMETERS’. But there will be cases where the namesdiffer, so you are being shown the ‘pukka’ method

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 183: Cookbook3_1

2.80

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

ROT2 180PROJECT2 4,90,1DEL 1

Preliminary 2D symbol scriptThis has been explained in earlier window exercises

!DefinitionsDEFINE FILL 'nofill' 0,0,0,0,0,0,0,0, 0,0,0

Add this to the Master script

!Example Door: Voyager!2D Script

PEN pen2d

IF E~ THEN !Flipping MUL2 1,-1 ADD2 0,-frtENDIF

!ROT2 180!PROJECT2 4,90,1!DEL 1

SET FILL 'nofill'

!Frame ADD2 A/2,0 PUT 0,0, 0,-frt,-frw-0.01,-frt,-frw-0.01,-lt,-frw,-lt,-frw,0, 0,0POLY2 NSP/2,7,GET(NSP) DEL 1

MUL2 -1,1 ADD2 A/2,0PUT 0,0, 0,-frt,-frw-0.01,-frt,-frw-0.01,-lt,-frw,-lt,-frw,0, 0,0POLY2 NSP/2,7,GET(NSP) DEL 2

!Door ADD2 A/2-frw,0 ROT2 -op2IF A_<51 THENPOLY2 5,7, 0,0, 0,-lt, -lw,-lt, -lw,0, 0,0ELSE LINE2 0,0,-lw,0ENDIFDEL 2

!Handle (scale sensitive)IF dh THEN ADD2 lw/2,0 ROT2 -op2IF A_<51 THENLINE2 -lw+lw/12,0.05,-lw+lw/12,-lt-0.05ENDIF DEL 2ENDIF

!SwingPEN spenARC2 lw/2,0,lw,180-op2,180

Pen colour for 2D

This is the answer tothe ‘difficult bit’:

E~ tells GDL if the door hasbeen flipped

Keep the Project2 routinefor quick reference

Set the fill pattern for thedoor frames

Draw out the frame, in thenegative quadrant

(tracing over a Project 2image). Using PUT, it iseasy to draw it first as a

rectangle and fit therebate later

You can write the otherone, but it’s easier to do aMUL2 and copy-paste the

one you just did

You could writeGLOB_SCALE instead of

A_ if you are quick attyping.

The door leaf is also aPoly2 if the scale is largerthan 1/50 or 1/2”-1’, anda simple Line2 if the scale

is 1/100 or 1/4”-1’ orsmaller. A_ is the globalvariable that decides.

The Handle is also a line2that goes through the door

leaf at the right location,and whose length is

governed by the scale ofthe drawing. It also

reminds the user if a doohandle is present or not.

The swing of the door isdetermined by a separateparameter op2, and has

its own pen colour

The 2D Script in full

the different file names of the macros. By using thesame variable names, it is extremely easy to write theCALL. We do not use A and B in the macros, so thesecan be left out of the CALL statement.

The Door needs a 2D symbolBefore you can place it in the ArchiCAD environment,you need to give the door a 2D symbol. Firstly, it iseasiest to use the Project2 command to generate thesymbol. The syntax of Project2 is PROJECT2 view_type,camera_angle, drawing_method. This works fine untilyou flip or rotate the door.

However, this is lazy and as you will see below, canresult in completely erroneous symbols. You wouldbe better off with a smart 2D script that is scale sensi-tive and shows the door swing correctly with aselectable pen colour. It is also good to draw the doorframes with a white fill pattern instead of the wirelineeffect you get with Project2. Add a white fill definitionto the Master script, and draw the frame out usingPOLY2.

The door leaf and the door handle are both scalesensitive, using A_.

The difficult bitDoors can be rotated (Cmd-E or Ctrl-E) or they can beflipped in the settings box. The interactions betweenthese is a nightmare to solve, and when these also causethe 2D symbol to go awry, you finish up with doorsthat are in the right place in plan, but in a quite differ-ent place in 3D, perhaps with the frame outside thewall altogether. This interaction took me many hoursto work out even with the help of GS’s GDL Technicalstandards, and you are lucky to be reading this andsaving yourself all those hours.

Using the PROJECT2, I have not been able to find away of making all these flipping and rotating interac-tions work; the only solution seems to be a properlyscripted 2D symbol, with the flipping routine included.

The 3D and the 2D need to work together. Add thissmall group of lines to the 3D script after the ‘IF dort=0’statement.

!Add this to 3D script

IF dort=0 THEN END:!No door

IF E~ THEN !Flipping routineMULz -1ADDz -frt+C_ENDIF

!.... script continues!as on earlier page

Make sure the door worksIf you haven’t already saved, you should have donelong ago. The door will be saved as a .DOR file. If per-chance you built the door as a .GSM object file, go toFilemenu>OpenLibrary Part>Open Object as Door, andthen save; it will now be saved as a door.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Line
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 184: Cookbook3_1

2.81

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Door Handle macro :Voyager Course

IF dh=0 THEN ENDIF dh>3 THEN dh=0

MATERIAL hmat

MULz -1GOSUB 100+dh:!Knob or Lever DEL 1

ADDz ltGOSUB 100+dh:!Knob or Lever DEL 1

END:!_____________________

101:!KnobRESOL 7PUT 0,0.035,1, 0.01,0.035,0, 0.015,0.020,0, 0.030,0.020,0, 0.045,0.030,1, 0.070,0.030,1, 0.080,0.010,1ROTY -90REVOLVE NSP/3,360,63,GET(NSP)DEL 1RETURN

102:!LeverRESOL 7PUT 0,0.035,1, 0.01,0.035,0, 0.015,0.012,0, 0.050,0.012,0ROTy -90REVOLVE NSP/3,360,63,GET(NSP)DEL 1

ADDz 0.05 PUT 0.1,-0.01,13, 0.0,-0.02,13, 0.0, 0.02,1013, 0.1, 0.01,13, 0.1,-0.01,1013, 0.0,-0.02,-1PRISM_ NSP/3,0.01,GET(NSP)DEL 1RETURN

103:!Tube LeverRESOL 7PUT 0,0.035,1, 0.01,0.035,0, 0.015,0.012,0ROTy -90REVOLVE NSP/3,360,63,GET(NSP)DEL 1

RADIUS 0.012,0.03 ADDz 0.015CYLIND 0.03,0.012 ADDz 0.03ELBOW 0.03,90,0.012 ADD 0.03,0,0.03 ROTy 90CYLIND 0.05,0.012 DEL 4RETURN

The door handle script in 3D

Parameter box in the door handle

The three door handles used in this example!Door Handle – add to 3D scriptIF dh THEN ADDx lw/2 ROTy -opa3 ADD -lw+lw/12,0.9,0CALL dorhandl_macro65 PARAMETERS lt=lt, dh=dh,hmat=hmat DEL 3ENDIF

Add this to the 3D script just before the END

All along, you should be making regular checks onthe 3D in the GDL, then the 2D. It’s time to test it forreal. Return to the ArchiCAD project floorplan, draw awall. Click on the Doortool and place your new door.The one you have just saved will be the first door thatgets placed. Check that it works in 3D view. Try alter-ing its settings. Try entering negative or huge openingangles. Flip it, flip and rotate it. In each case, comparethe 3D result with the 2D symbol. Move the frame inand out of the opening.

Have a look at how the hole in the wall is drilled.GDL normally cuts a rectangular hole in the wall, ‘A’ inwidth and ‘B’ in height, but leaving the default wallmaterial in the reveal. The WALLHOLE commandshould enable you to change that material.

Add the HandleAs with the door, you need to depart and make thehandles as a macro object. The handles could be a lotof separate macros, but in this case, they have beenintegrated into one macro object with its own valuelist. This enables you to use them separately shouldyou wish to, and stops your library being cluttered withan excess of tiny files.

You need to make a handle and then flip it to ap-pear on the other side of the door. There is some trick-ery in working out which way lever handles shouldgo, but they are completely solved in this example, solearn from this. These are the right way round so thatwhen they come into the main door object, they willbe the right way round and up, and will attach to theface of the door correctly.

You do not need to give the handle a 2D script, butif you wanted to use it separately, give it a PROJECT2script, save it as a library part Object, not as a Macroobject – it can then be placed independently in afloorplan. The variables used in the handle are the sameas those in the parent Door object.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 185: Cookbook3_1

2.82

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Example Door, using Tube!and Prism: Voyager!3D Script

PEN pcol

!WallholeGOSUB 50

IF dort=0 THEN END:!No door

IF E~ THEN !Flipping routineMULz -1ADDz -frt+C_ENDIF

!FrameIF frw>0 THEN GOSUB 100

!Door ADDx lw/2 ROTy -opa3GOSUB 200+dort DEL 2

!Door handleIF dh THEN GOSUB 300:

DEL TOPEND:!______________________

Final executive portionof the 3D script

The tiled image of the doors

UI_DIALOG "Leaf styles"

UI_INFIELD 'ls',6,20,298,170, 1,'doorexamp.jpg',8,2, 68,160,58,138, 1,'Empty', 2,'Flush', 3,'1-panel', 4,'2-panel', 5,'3-panel_a', 6,'3-panel_b', 7,'4-panel', 8,'Circular'

UI_STYLE 2,0

UI_OUTFIELD 'Door Selector for GDL Cookbook',6,196,298,25

UI_STYLE 1,0

UI_OUTFIELD 'Copyright David Nicholson-Cole',6,212,300,25

UI_OUTFIELD 'Use this as a guide for door building. Returnto the parameter box for general settings.',6,226,298,25

The user’s settings box with pictorial value list.Make a Preview image for a nice icon.

Finishing off – and the User InterfaceBefore we go onto that, just look at the 3D script here, and at theexample on the CD. As a final tidying up operation, you can see thatthe Wallhole, Doorframe, Doorleaf and Doorhandle routines are alltidied away into subroutines, leaving the executive portion of thescript delightfully minimal, and easy to understand.

A User Interface could be built for the entire door, including allthe options for handles and materials. This example is following theGraphisoft route which is to leave the majority of parameters in thenormal place but to build a special visual interface – what I call thePictorial Value List – to help the user decide which door to use. Itcould be further developed to choose the style of handle. Perhapsyou can try that yourself.

First, you have to render each door, seeing it face on, all at thesame scale, then move the images into photoshop and organise theminto tiles. The tiling must be rigorously evenly distributed in spacing.Make the final image no more than 270-280 pixels wide, either bygood planning, or by re-pixellating the final image. Apply a ‘sharpen’filter if you re-pixellate. Make a note of the height of the image. This

one is 272 by 316 pixels. This is very important for getting theUI_INFIELD statement to work. The file can be a JPG, TIF or BMPand must be in a loaded library. If you are in AC already, reload li-braries for the new file to be found.

Open the GDL Cookbook at the pages on the User Interface; thisexplains what each field of the INFIELD statement is doing. Keepclicking on the preview button to see how it is going. In this case, theCell width must be smaller than or equal to a quarter of the width ofthe main image, but the Cell height must be more than half the heightof the main image. Try varying the numbers in the INFIELD state-ment and you will see how wrong it can get with just a small error.

WarningIn some releases of AC, excessive playing about with User interface(and the errors resulting) can cause AC to erase great chunks of the3D script and delete your parameters. No Kidding!! This is a bug nota feature. Do this final bit of work on a COPY of your door object file.

End NotePlease note that this door is very simple. Real doors take even more work – a wider variety of door and glazing styles; letterbox and knocker; parametric transoms and stiles; more ironmongery options including kickplates and pushplates; porchframes and fanlights. The door here is a generic example which shows the essential technique with minimal detail, includingthe relationships of macro objects to the parent door-object, the notorious flipping and rotating problem and the design ofthe User Interface. Good luck with your own attempts.

UI_INFIELD starts with value listparameter name, top corner, total

field size (in pixels).

The 1 is mandatory, then the Filenameof the tiled image. The total number of

images and the number of rows.

Then the Cell X and Y dimensionsfollowed by the amount of the cell

occupied by the tiled image (must besmaller than the cell).

Follow this with a list of the door stylesand their indexes, exactly as in the

Value list.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 186: Cookbook3_1

2.83

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Anglepoise LampThis is an exercise in the use of :• LIGHT• REVOLVE• PRISM_ with Poly lines.• Mirroring objects using the MUL command

FOR the model to have any credibility in an interior view,it has to be able to hinge like a real lamp, and to be able

to switch on its light. This one does both of these things. Iuse it in interiors.

You can start it as an object (and convert to a lamp later)or in 6.5 onwards, you can start as a lamp from the begin-ning. My technique is to hammer in some rough script, to getthe model started (as on the left). Once I get to the pointwhere it needs to be structured (certain elements need to gointo Subroutines) I convert the text, as shown below, by wrap-ping Line numbers and ‘Returns’ around the blocks of text,putting an END statement in near the top, and then insertingGOSUB to each of the newly created subroutines. For exam-ple, here, I got one main arm working well, and then I wantto mirror the main arm on the other side of the pivot.

Left: is a first working scriptRight: is the same script, ‘massaged’ intoshape by converting it into two subroutinesnumberd 100 and 200, not forgetting thebutton at 110:.

Now that the script has been structuredinto subroutines, the arm routine (in 210)can be MULled around the Y-axis, whichmeans that you get a mirror image – this isdone in subroutine 200.

As the Main arm prism will be usedagain for the Second arm, the PRISM com-mand is, itself, a small subroutine (220)

The bright stainless button for theswitch is also used as an axle for the arms,so it is a subroutine, called by the othersubroutines.

This is the final shape we are aiming at – it helps to draw it freehand in your book, or at least to think out thejunction details simplify then appropriately. Avoid over complex levels of detail. For example, there is no pointin making the steel springs for the anglepoise unless the lamp is the central point of the model. If it is furniturein an interior design, the level of detail shown here is adequate.

!Anglepoise Lamp!3D Script

PEN 1!Lamp BaseELLIPS 0.05,0.1!basepivot ADD -0.025,0.01,0 ROTx 90PRISM_ 5,0.02, 0,0,15, 0.05,0.00,15, 0.05,0.06,15-2, 0.00,0.06,1015, 0,0,-1 DEL 2!buttonADD 0.07,0,0.025CONE 0.02,0.013, 0.011,90,90CYLIND 0.03,0.007 DEL 1

!Anglepoise Lamp!3D Script

MATERIAL 0PEN lcolRADIUS 0.02,0.03

GOSUB 100 !Lamp base GOSUB 110 !switch GOSUB 200 !Lamp armEND!_________________

100: !Lamp BaseELLIPS 0.05,0.1 !base

ADD -0.025,0.01,0 ROTx 90PRISM_ 5,0.02,!basepivot 0,0,15, 0.05,0.00,15, 0.05,0.06,15-2, 0.00,0.06,1015, 0,0,-1 DEL 2RETURN

Byzanti
Highlight
Byzanti
Highlight
Page 187: Cookbook3_1

2.84

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Make a LampIf the Anglepoise started life as an object, you can convert itfrom an OBJECT to a LAMP. Save the GDL object, and closeit. ‘Open Library Part’ again, and you can say what you wantit opened as. This time, make it come back as a LAMP, andyou can now save it as a LAMP. It will add more parameters,all concerned with Lighting, and all starting with single let-ters, which cannot be edited – but which can be used.

Below is the final script – in the form of a LAMP, not anOBJECT. All this means is that a few parameters are used inthe subroutine containing the light bulb. When you havesaved the lamp, you may be a bit perturbed that you can nolonger find it, but this is because it has been saved as a LAMPand can only be brought back with the lamp icon in the toolspalette.

!Angle Poise!Master ScriptIF lampang> 70 THEN lampang= 70IF lampang<-90 THEN lampang=-90IF armang1> 80 THEN armang1= 80IF armang1<-80 THEN armang1=-80IF armang2>120 THEN armang2=120IF armang2< 0 THEN armang2= 0

Master Script: You can use this to preventthe user defying gravity and materiality by bend-ing the lamp until it goes into its own arms.

410: !Lampshade Body ADDz 0.01 !liftCYLIND 0.02,0.015 !swivel ADDz 0.05 !total is 0.06GOSUB 420 !outercolorshell ADDx 0.001 MULy 0.98MATERIAL "whitewash"IF C THEN MATERIAL "lamp" GOSUB 420 !innerwhiteshell GOSUB 430 !bulb DEL 4RETURN

420: !lampshade latheREVOLVE 5,360,1, -0.05,0.01,0, -0.03,0.01,0, -0.03,0.03,0, 0.03,0.04,0, 0.15,0.10,0RETURN

430: !Lightbulb ROTy 90CONE 0.08,0.015,0.025,90,90 ADDz 0.09SPHERE 0.03 DEL 2 !Light points along XIF C=1 THEN LIGHT G/100*D,!set intensity G/100*E, G/100*F,!RGB 1, !shadow on 0.2, !start radius 30,50, !Alpha beta 0.1, !anglefalloff 0,2, !distances 0.1 !distfalloff ENDIFRETURN

300: !upperarm ADDz 0.065 !lift ADDy 0.005 !centralise ROTy armang1 ADDz armlen ROTy armang2 ROTx 90GOSUB 220 !arm prism ADDy armlen ADDz -0.01 GOSUB 230 !axle ADDz 0.005 CYLIND 0.02,0.015!shadeswivel DEL 9RETURN

400: !Lamp itself ADDz 0.065 !lift ROTy armang1 ADDz armlen ROTy armang2 ADDz armlen ROTy lampang ROTz lamtwisGOSUB 410 !LampshadeDEL 7RETURN

110: !Switch ADD 0.07,0,0.025CONE 0.02,0.013,0.011, 90,90!base GOSUB 230 !Steel button DEL 1RETURN

200: !Lamp ArmGOSUB 210 !arm part MULy -1GOSUB 210 DEL 1 RETURN210: !Arm part ADDz 0.065 ROTx 90 GOSUB 230 !axle ADDz 0.01 ROTz -armang1GOSUB 220 !arm prism ADD 0,armlen,-0.01 GOSUB 230 !axle DEL 5 RETURN220: !arm prismPRISM_ 5,0.01, !arm-0.01,0.00,15,-0.01,armlen,15, 0.01,armlen,1015, 0.01,0.00,15,-0.01,0.00,1000RETURN

230: !axle / switchMATERIAL "stainless Steel" CYLIND 0.03,0.007 !axleMATERIAL 0RETURN

Using anothermonitor

PCI cards are very cheap now; ifyou have a redundant monitor

lying around the office, why not geta second video card, and have a sec-ond monitor attached to the com-puter? It is very helpful to have asecond screen where the 3D viewgets generated, or where you canstore your palettes.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 188: Cookbook3_1

2.85

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Recursive Tree

TREES are one of the biggest problems in 3D modelling because it is difficult to make them look naturaland random, and they take a very long time to render due to the high number of polygons.

This example of a winter deciduous is a remarkable piece of programming written by a GDL friend, PhilCannon. It has a very natural look, and if used in a partially 2D form, it has few polygons. I have adapted it (withpermission from Phil) for the Cookbook, because the recursive CALL statement is so wickedly daring that Icannot imagine how he dared to even try it out in the first place. He says it was one of those ‘2 in the morning’decisions!

How does this tree work?The tree consists of a ‘parent’ and a ‘child’ – the parentis the Trunk and the CALL commands for the first fewbranches; the child is the Branch which then calls it-self many times.

I have adapted it so that the trunk is always solidand rather knarled looking (by using SWEEP). The restof the tree can be done as a set of branch structures,using either a series of 2D PLANEs, or solid CONEs .

Needless to say (even with a resol of 5) the CONEstake vastly longer to render than the PLANEs, having 7polygons each, compared with 2. They also look fartoo heavy; and it’s in the nature of the algorithm that ifyou made the cones small enough to reduce to thesize of real twigs, the iterations would produce so manythat it would take all your computer’s time to draw justone or a few trees. In silhouette, the Plane-based treelooks more realistic than the Cone-based one.

The buildings in your model can be glimpsed moreeasily through a winter tree than a fully foliated one.

Parameter box for the TREE

Script CommentaryAs an articulated model gets longer, you get an increas-ingly long chain of cursor commands that has to befollowed each time you do the next element of theobject – you can see what I mean in the script for theUpper Arm.

The Lamp element itself can also twist/rotate, as wellas vary its light level and colour. Notice that the coneof the lampshade is drawn twice, the outer shell is col-oured, and the inner shell is Lamp coloured.

As one wants the lamp to have bright colours, theLamp body MATERIAL is set to *zero* and you use PENto decide on its colour. A better method to use is theone in ‘Fire Extinguisher revisited’ where you use RE-QUEST and DEFINE MATERIAL to create material withmetallic or plastic qualities.

You may have to use Trial and Error to get the Dis-tance Falloff and other factors just as you want them –by doing some photorenders, with Lamps active.

Don’t forget to update the Executive script regularlyas you add in subroutines for the lamp and arms.

2D Script: Because the lamp can hinge and move,it has to be scripted as a PROJECT2, but it’s is a goodidea to have a Hotspot at the Origin, so that youcan pick it up easily.

!Anglepoise Lamp!2D ScriptHOTSPOT2 0,0PROJECT2 3,270,2

!Anglepoise Lamp!light object!Final Executive 3DScript

MATERIAL 0PEN lcolRADIUS 0.02,0.03

GOSUB 100 !Lamp base GOSUB 110 !Switch GOSUB 200 !Lamp arm GOSUB 300 !upperarm GOSUB 400 !Lamp itself

END!___________________

The parameters are kept very simple in naming, to oneletter, so that the first 6 letters, c, d, e, f, g, h are all thesame meaning in the Tree as in the Branch. In that way,the CALL command is reduced to the most simple form,CALL "recursive_Branch" a, b, c, d, e, f, g, h. (not need-ing the word PARAMETERs, or a long line of c=c, d=d,e=e, f=f etc etc.)

This exercise demonstrates:• Recursive programming• Using a Macro• Attention paid to polygon count

The RADIUS command isthe final touch, to makesure you are not adding

too many polygons.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 189: Cookbook3_1

2.86

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

The Tree as aseries of Cones

Parameter box for the BRANCH

!Recursive Branch!3D Script!Phil Cannon!Adapted by DNC

RESOL 15/gMATERIAL eROTx (10+rnd(25))

IF h THEN !3D CONE c,d,d*0.8,90,90ELSE ROTx 90 POLY 4,!2D -d,0, d,0, d*0.8,c, -d*0.8,cDEL 1ENDIF

BODY 1ADDz cIF d<0.14 AND d>f THEN GOSUB 1100 ENDIF c=c*0.8 d=d*0.8IF d<f THEN 1099

FOR t= 1 TO g STEP 1 ROTz 360/g CALL "recursive_Branch" a,b, c,d,e,f,g,h NEXT t

1099: DEL TOPEND:!-----------

1100:LET g=5ROTx 5RETURN

The 3D option – aCONE

The 2D option – aPLANE

!Recursive Tree!3D Script!!1996 Phil Cannon!Modified, with!PC's permission!by David NC, Dec 1999

!TrunkMATERIAL eGOSUB 100:!trunk

!Branching SystemMUL A/9,B/9,1ADDz thit-thit/3ROTx 9+rnd(2)CALL "recursive_Branch" a,b, c,d,e,f,g,hDEL 2ADDz thit!Centre branchROTx -10-RND(25)CALL "recursive_Branch" a,b, c,d,e,f,g,hDEL 2ADDz thitROTz 180ROTx 9+rnd(2)CALL "recursive_Branch" a,b, c,d,e,f,g,hDEL 1ROTz 90ROTx 9+rnd(2)CALL "recursive_Branch" a,b, c,d,e,f,g,hDEL 1ROTz 180ROTx 9+rnd(2)CALL "recursive_Branch" a,b, c,d,e,f,g,hDEL TOP

END:!-------------

100:!more realistic trunk MUL twid/0.6,twid/0.6,1 ROTz RND(180)SWEEP 10,2,RND(60),0.6,63, 0.1,0.2,0, 0.1,0.1,0, 0.3,0,0, 0.1,-0.25,0, 0,-0.2,0,-0.05,-0.25,0,-0.3,-0.05,0,-0.25,0,0,-0.2,0.15,0, 0.1,0.2,0,0,0,0,0,0,thitDEL 2RETURN

The tree as aseries of Planes

Phil’s original trunkwas a Cone, but theSWEEP gives a moreirregular section, andthe twist makes it lookknarled

Normally, if a library objectcalls itself, the effect is simi-lar to a Subroutine GOSUB-bing itself – but worse.GOSUB can be cancelledwith Ctrl-Stop, but the CALLcauses the computer to freezeuntil rebooted. In this case,the diameter and length of thecones or planes are being re-duced by 0.8 each time, sowhen they reach a minimumdiameter, they stop prolifer-ating.

The main tree object calls5 branches, but the branchesthen call themselves to formthe smaller branches andtwigs.

Page 190: Cookbook3_1

2.87

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Houses by Letts Wheeler, model by DNC, 2D Tree by Mick Kingsbury

Tree questionsHow do others generate large quantitiesof trees in their site model renders?

Third, you can have 2D trees, which turn to face the cam-era. These can be Picture objects (in which case you have tohave some alpha chanelled photos of tree types – these canbe purchased from library suppliers (look on the Graphisoftweb site, someone advertises them). There is a simple one inthe GDL Cookbook Library.

ArchiTerra has excellent picture trees with a collectionof alpha channelled tree images. The benefit of these is thatthey are upright Prisms, not rectangular picture objects, sothey look reasonably good in 3D views, and cast shadows.Fourth, you can have 2D tree using 3D elements displayedin a 2D arrangement, which turn to face the camera.

The GDL Cookbook could do with a longer feature ontrees of all four types, that’s an idea for a future edition.

I have been doing a University Campus model, doing thegeneral building shapes (a 3D figure ground plan really) andfound that the Lollipop trees are the best solution, withrandomised heights and diameters, and a texture that hasalpha channels (to make them look filigree)

ANOTHER way (type 3 below) to make a tree more realistic isto use a scanned or generated image of a tree, create an AlphaChannel for the sky to show through; and impose that on aPicture library object with the ability to turn towards the cam-era. You can satisfy a wider variety of trees. PhotoTrees causea high memory overhead despite fewer polygons, becauseArchiCAD tries to remember every tree it has already done.

!Recursive Tree –!2D Script

!!PROJECT2 3,270,2PEN 1HOTSPOT2 0,0HOTSPOT2 0, B/2HOTSPOT2 0,-B/2HOTSPOT2 A/2,0HOTSPOT2 -A/2,0

!Stretchy leafballPEN L_MUL2 A/9,B/9FRAGMENT2 1,1DEL 1

All the Trees are aware of the camera position,and look most solid from the camera’s view. Aversion of this is in the Cookbook Library.

2D ScriptThe 2D would be too slow if you have a PROJECT2; soyou first save the object with Project2. Then explode acopy of the object into 2D, copy and paste it into the2D Symbol window of the tree. Centre it carefully. makesure it is the right way round. If you add your own 2Dhotspots to the symbol, the object will not be stretchy,so you write the stretchiness into the 2D Script – usingFRAGMENT2 to call up and display the 2D Symbol.PEN L_ means that the user selected pen will be used,even if the hotspots are black.

THERE are several ways of doing trees. Trees on theirown are a potential disaster, due to the potential for

thousands of polygons in each tree. If the trees are dis-tant, there is no point in a model that faithfully and geo-metrically tries to build every leaf. But if you are doing aclose up, and a tree is important for authenticity, then ageometrically modelled tree is what you want.So,First you can have a 3D geometrically modelled tree – ifit’s any good, it will have randomised branches, and vari-able height and leafdensity and colour, and leafball shape.I’ve got one, but the best I know of is one done by MickKingsbury in Nottingham, but it’s not for sale.Second, you can have a 3D 'lollipop' style tree, basicallya ball on a stick which sounds dreadful, but you can havesubtle variations such as using a texture with alpha chan-nels to make it look leafy, shape variations to make ittall+thin, or squat shape, and can reduce the resolutionof curvature to make it more polygonal than ball shaped.The result, grouped together with a randomiser to varythe height of each, the trunk height and diameter, theleafball shape and height, can look very effective and haveonly a fraction of the polygons.

Byzanti
Highlight
Page 191: Cookbook3_1

2.88

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

This chair exercise is an example of:

• bPRISM_ – Bent Prism• Polylines in Prisms• Using CONE• Passing parameters to a macro• Using Symmetry• Using Fragment2 in the 2D

F IRST OF ALL, note that we only need to build half the chair – which can then be mirrored. For

this exercise, we are not bothering to make the chairparametric.

First hammer in the outline of the seat of the chair.Do it as a chamfered shape first, and you will be ableto curve the chamfers later. We use PRISM_, not PRISM,because we want to add in curves at the corners usingPolylines.

By the way, initially there is only one Parameter inthe parameter box, ‘cmat’ for the Material. Later, wecan add a value list for the arms.

Make it into a structured form,with subroutinesNow convert that seat prism to a Subroutine. Look atthese two scripts (right) and follow likewise. In addi-tion, convert the chamfers to curves, by adding 1000 tothe original masking value of 15. Then subtract 2 from15 to remove the vertical lines in the curve. Add theADD command to lift the seat to the correct height.

If you have done this in the ArchiCAD environment,it will come in with 6 decimal figure numbers. Here, Ihave rounded them down to simpler looking numbers.

Make a subroutine for the legformsNext, you need to develop a conical form to use forthe legs, leg braces and many other parts of the chair.This will be an example of ‘passing parameters’, be-cause the conical legs areof different lengths and di-ameters. Having got itworking, store it as a sub-routine, and make sure itworks by first using it forthe legs of the chair. Bypassing to it different pa-rameters for length andradius, you will be able touse it for the arms.

Kitchen Chair

This next little routinewill be the basis of allfuture leg and braces forthe chair. Copy theroutine above and makeit into two routines,number 200: and 210:.Thus you get one legworking.

!Kitchen Chair!Voyager CoursePEN 1MATERIAL cmat100: !SeatPRISM_ 7,0.05, 0.00, 0.00, 15, 0.00, 0.45, 15, 0.20, 0.45, 15, 0.26, 0.40, 15, 0.23, 0.05, 15, 0.18, 0.00, 15, 0.00, 0.00, -1

!Kitchen Chair!Voyager CoursePEN 1MATERIAL cmat

GOSUB 100:!Seat

END:!--------------

100: !Seat ADDz 0.44 ROTy -2PRISM_ 7,0.05, 0.00, 0.00, 15, 0.00, 0.45, 15, 0.20, 0.45, 15-2, 0.26, 0.40,1015-2, 0.23, 0.05, 15-2, 0.18, 0.00,1015-2, 0.00, 0.00, 15DEL 2RETURN

!Kitchen Chair!Voyager CoursePEN 1MATERIAL cmatGOSUB 100:!Seat

d1=0.20: d2=0.25 r1=0.02: r2=0.03CONE d1,r1,r2,90,90 ADDz d1CONE d2,r2,r1,90,90 DEL 1

!Kitchen Chair!Voyager CoursePEN 1MATERIAL cmatGOSUB 100:!SeatGOSUB 200:!Legs

END:!---------------

100:!Seat(see text box above)RETURN200:!Chair Legs etc d1=0.20: d2=0.25 r1=0.02: r2=0.03GOSUB 210: !RearlegRETURN

210:!ConeLegCONE d1,r1,r2,90,90 ADDz d1CONE d2,r2,r1,90,90 DEL 1RETURN

The next step is to writea conical leg routine

Do it as achamferedshape first

Page 192: Cookbook3_1

2.89

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

The ArmsNext, place a coneleg in the loca-tion for the Arm upright support– slightly angled forward.

Then add in the Prism for theArm itself. This has a curvy end –could be done by a simpler prismand a Cylinder at the end. Buthere it is done with a maskingvalue that gives you a Polylinerounded profile.

VALUES: You can use a ValuesList to decide if arms are to be in-cluded or not.

Making the whole chairYour main ‘executive’ scriptshould now look like this on theleft, and once you start to add inthe back, will look like this draw-ing on the left. Half the chair, isdrawn.

You can now take advantageof symmetry. Modify the scriptusing a MULx -1 so that the wholething is repeated with it mirror-ing in the X direction.

Your Executive script grows assubroutines are added.

300:!Arms ADD 0.22,0.38,0.50 ROTy 9 ROTx -6 d1=0.10: d2=0.10 r1=0.01: r2=0.02GOSUB 210 !ArmSupport DEL 3RETURN

300:!ArmsIF arms='Include arms' THEN ADD 0.22,0.38,0.50 ROTy 9 ROTx -6 d1=0.10: d2=0.10 r1=0.01: r2=0.02GOSUB 210 !ArmSupport DEL 3 ADD 0.18,0.02,0.69 ROTz -3PRISM_ 8,0.04, !Arm 0.00,0.00, 15, 0.02,0.10, 15, 0.02,0.39, 15-2, 0.10,0.39,1015-2, 0.08,0.36, 15, 0.07,0.12, 15, 0.05,0.00, 15, 0.00,0.00, -1 DEL 2ENDIFRETURN

!Kitchen Chair!Voyager Course

PEN 1MATERIAL cmatGOSUB 100:!SeatGOSUB 200:!LegsGOSUB 300:!Arms

MULx -1GOSUB 100:!SeatGOSUB 200:!LegsGOSUB 300:!Arms DEL 1

END:!---------------

VALUES 'arms' 'Include arms', 'Hide arms'

Nudge the arminto the right place

200:!Chair Legs etc d1=0.20: d2=0.25 r1=0.02: r2=0.03 ADD 0.20,0.40,0.45GOSUB 210 !Frontleg DEL 1 ADD 0.17,0.05,0.45GOSUB 210: !Rearleg DEL 1RETURN

210:!ConeLegCONE d1,r1,r2,90,90 ADDz d1CONE d2,r2,r1,90,90 DEL 1RETURN

200:!Chair Legs etc d1=0.20: d2=0.25 r1=0.02: r2=0.03 ADD 0.20,0.40,0.45 ROTx 180 ROTx 5 ROTy 5GOSUB 210 !Frontleg DEL 4 ADD 0.17,0.05,0.45 ROTx 180 ROTx -5 ROTy 5GOSUB 210: !Rearleg DEL 4RETURN

By a bit of pushing and pulling and twistingwith ROT commands, you can get the legsto splay correctly.

Make the LegsNow extend the use of subroutine210 to include the other leg. Ini-tially, the legs are vertical.

Page 193: Cookbook3_1

2.90

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Back slatsFinally, you add in the back slats.These need individual nudginginto position, and rotating to thecorrect angle – using the wirelineview in plan and side elevation.

This subroutine for the Slats iscalled from within subroutinenumber 400 – it’s part of the backassembly. It could also be calledfrom the executive script as it is atidily self contained object. That’sstructured programming in action– objects!

420:!Slats ADD 0.02,0.01,0.50 ROTx 7BLOCK 0.05,0.01,0.56 DEL 1 ROTz 5 ADDx 0.08 ROTz 5 ROTx 7BLOCK 0.05,0.01,0.56 DEL 5RETURN

250:!Leg Braces ADD 0.19,0.03,0.25 ROTz -4 ROTx -90 d1=0.19: d2=0.19 r1=0.01: r2=0.02GOSUB 210:!Legbrace DEL 3 ADD 0.21,0.22,0.25 ROTy -90CONE0.21,r1,r2,90,90 DEL 2RETURN

Leg bracesThe legbraces are importantenough to deserve their own sub-routine. You can use the coneleg(210) for the fore-and-aft brace,but the cross brace simply needsa Cone. Nudge them into posi-tion with the ADD commands,using a planview in wireline. Usethe number 250: to keep it nearthe other leg routines.

The BackPut in the double cone for theback pillars – leaning over, ofcourse.

Making the BackNow, it’s time to build the CurvedBack shape – using bPRISM !

The trick with Polylines is tocreate the Prism object first withsimple chamfered corners. Onceyou get the Prism working cor-rectly, add in the 1000 polylinesto make the corners curve. Thenlift it into position and rotate asrequired to make it fit.

When you start making a com-ponent, do not worry about firstmaking it on the floor, and leav-ing out the curved bits.

This uses the same macro routine(210:) that was used for the legs; justpass it larger parameters.

400: !Back ADD 0.18,0.05,0.50 ROTx 8 ROTy 6 d1=0.23: d2=0.33 r1=0.02: r2=0.03GOSUB 210!BackSupport DEL 3RETURN

400: !Back ADD 0.18,0.05,0.50 ROTx 8 ROTy 6 d1=0.23: d2=0.33 r1=0.02: r2=0.03GOSUB 210 !BackSupport DEL 3GOSUB 410:!CurveBackGOSUB 420:!SlatsRETURN

410:!CurvedBack ADD 0,-0.04,1.05 ROTx 96BPRISM_cmat,cmat,cmat, 7,0.045,0.8, 0.00,0.00, 15, 0.00,0.15, 15, 0.27,0.15, 15-2, 0.31,0.10,1015-2, 0.30,0.04, 15-2, 0.25,0.00,1015-2, 0.00,0.00, -1DEL 2RETURN

Autosizing text in 2DWhen you ‘Define Style’ for text, the font height is usually a fixed height that will appear on the printed or plotted sheetat that size, regardlessof scale. More often, you may want the font to appear constant relative to the object that it is partof: so you want it resize whenever the drawing scale is shanved. Font size has to be in millimetres. Object is in metres. Somultiply the object dimension by 1000. Then divide the resulting size by the Scale of the drawing. This finished size willstick faithfully to the size of the object it relates to, whatever the drawing scale. In this case the font size is twice the tubediameter.

fntz=2*t1diam*1000/A_

Page 194: Cookbook3_1

2.91

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Finishing offYour final ‘executive’ script shouldlook like this – neatly tabulatedand documented.

Your final chair should looklike this. The curved edges havehad their vertical lines tidied awayby using 1013 instead of 1015 inthe PRISMs.

!Kitchen Chair!Voyager Course

PEN 1MATERIAL cmatGOSUB 100:!SeatGOSUB 200:!LegsGOSUB 250:!Leg BracesGOSUB 300:!ArmsGOSUB 400:!Back

MULx -1GOSUB 100:!SeatGOSUB 200:!LegsGOSUB 250:!Leg BracesGOSUB 300:!ArmsGOSUB 400:!Back DEL 1

END:!---------------

2D Script or Symbol?Use FRAGMENT2!As this chair is not parametric, youwould find it best for use in thefloor plan to use a Symbol.

First use PROJECT2, then save.Place it in your floor plan. Selectthe chair with arms and apply theExplode! command to it. Thismakes it to a 2D symbol. Copy andpaste that into the 2D Symbol win-dow of the chair object. Select allthe lines in that symbol, open theline settings box and put them allinto Fragment 2.

Do that all again with the chairwith no arms, explode, copy andpaste into the 2D symbol. Thistime leave them all as Fragment 1.

Northpoint2D Script: This script was emailed to me by

Brian Frank because it didn’t quite work. I ti-died it up and sent it back, and it’s a useful demon-stration of 2D.

By using A and B as the determinants of size it iscompletely stretchy. It also has the bounding boxremoved.

The northpoint used a filled POLY2, and LINE2to form the cross shape. Hotspots are also positionedat key positions. The Fill pattern and Pen colour aresettable by the user.

The script shows how to set a text style in a 2Dscript, and how to control font and fontsize. Fontheight is based on millimetres (1/25th ”) in the plot-ted or printed output, regardless of the scale of thedrawing. The US version uses ‘points’ (1/72th inch).

!North Arrow!by Brian M. Frank!Melville Thomas Mobley Archs!Sept 98 Modified by DNC Oct 98

PEN C!Ideal size A=3 B=6LINE2 0,-B/2, 0,B/2LINE2 -A/2,0, A/2,0LINE2 A/4,0, 0,-B/2.5

SET FILL D

POLY2_ 4,3, 0,0,1, 0,B/2.5,1, -A/4,0,1, 0,0,1

PEN cDEFINE STYLE "north" ft, E,5,0 !E is Font size,FT is Font SET STYLE "north" string = "N" TEXT2 0,B/1.75,string

!HotspotsHOTSPOT2 0,0HOTSPOT2 A/2,0HOTSPOT2 -A/2,0HOTSPOT2 0,B/2HOTSPOT2 0,-B/2!turn off bounding boxes

!Kitchen Chair!Modified in 2D Mar 2000

PEN pcol!!PROJECT2 3,270,2

IF arms='Include arms' THEN FRAGMENT2 2,1 ELSE FRAGMENT2 1,1 ENDIF

Then remove the Project2 command from the 2D Script. Add some hotspotsto make it easier to pickup.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 195: Cookbook3_1

2.92

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Strings and things

WHAT is a String? It is a sequence of alpha charac-ters which have no numerical value. In GDL, a

let of alpha characters on their own are either a pa-rameter or a command, and have to be doing some-thing. A set of alpha characters behind an exclamationmark are a Comment. A set of alpha characters inquote marks are a String. ‘123.456’ is a string becauseit is in quotes. Materials (and other attributes) can benamed by a string or an index number – you can sayMaterial ‘Whitewash’, or Material 18.

STR( ): is very useful in 2D labelling and PropertiesScripting – when you often need to combine manynumbers together to make a long string of letters.

You can use it most in 2D Scripting, when you wishto annotate a symbol. For example, if you have astretchy staircase, you can get it to display a string like:“Pitch= 38.462 degrees”. This would indicate that youneed to stretch it a bit more to reduce the pitch, orsqueeze it if the stair is in a house.

The most common use of STR is in the first formabove, whereby you say how many digits will beneeded to represent an entire number, and how manyof those digits will occur after the decimal point.

For example: item=123.456STR(item,6,3) gives you ‘123.456’STR(item,6,1) gives you ‘123.5’STR(item,4,3) gives you ‘123.456’STR(item,7,2) gives you ‘123.46’

You might then say:lstr=“Length=” + STR(item,6,2)and get a string variable called lstr.

x=STRLEN(‘hello’): returns a value of 5, thenumber of letters.

x=STW(‘hello’): gives you a dimension in metresequal to the length of the word, in its present text style.Allowing you to build a 2D box round it, or to get agood results if labelling an object where you want thelabel to fit neatly to the object, whatever the drawingscale.

SPLIT( ): This is an interesting command that con-vert strings back into numbers – complicated to use,but worth exploring for the Voyager. See the ‘Bendibar’for an example. It half-does what VAL( ) does in BA-SIC. To me, its most useful purpose has been rapidparsing of Value List answers – reducing the need formany IF statements.

!Value List definition for a StairVALUES 'handtyp' '1-Parallel rails', '2-Rail + spindles'

!Parse the type of Handrailx=SPLIT(handtyp, '%n',htyp)!htyp is the flag for the rail

As a result of this, htyp is equal to either 1 or 2.

Some more GDL SyntaxREQUEST and REQREQ and REQUEST get information from ArchiCADabout the current model and system. Global Variablesget you numerical information. REQ and REQUEST canget you additional information, numerical or alphawhich you can use. The most common uses for RE-QUEST are getting the RGB colours of the current penor material, and the Time and Date.

This is a case where you need to look at the manualas there are 4 whole pages of things you can request.Unfortunately there is a small mistake in the example.REQUEST can be used on its own, but it will alwaysreport an error with ‘Check Script’. You should write itas this, with a dummy variable x before the statement:

x=REQUEST(‘RGB_of_Pen”, pcol,red,green,blue)

will return three variables for the Red, Green and Bluecomponents of red, green and blue from a Pen colourcalled pcol. If you then wanted to make a material ofthat colour, you could write it as:

DEFINE MATERIAL ‘dnc_matl’ 4,red,green,blue

Defining PEN with REQ

You cannot define PENs directly, but the following statementwill find a pen closest to your RGB definition.

pcolr= REQ(“Pen_of_RGB 0.26 0.74 0.66) willreturn the pen index pcolr nearest to turquoise. No Com-mas. You cannot use Variables here, only numbers will beaccepted.

IND( )IND( ) provides an index number for a Material, TextStyle, Texture, Line_type or Fill. Mostly these can bespecified by name, but there are times when they haveto be specified by number. IND( ) does this for you.

In a CALL statement, you need to specify a materialby its index number, not name. In a Material definitionyou need to specify a Fill or Material by its number.

It is most useful where you think that users havetweaked their materials library and changed some ofthe default numbers. For example, IND(MATERIAL,“Whitewash”) will guarantee getting ‘Whitewash’,whereas MATERIAL 18 might get a quite different re-sult. You can use it to do the same if users have tweakedtheir Linetype and Fill numbers.

When you make your own material in GDL usingthe DEFINE command the new material gets allocateda number by ArchiCAD – but you don’t know it. To besure, type in:

MATERIAL IND(MATERIAL,‘dnc_brick’)

A new Material definition using a Texture called‘wooly_carpetTX’ might be written:

DEFINE MATERIAL ‘wooly_carpet’ 22,red, green, blue, 0,61,IND(TEXTURE,‘wooly_carpetTX’)

For examples of the STW, STR and REQUEST commands, theFilestamp and Analog Clock are good examples.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 196: Cookbook3_1

2.93

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Curved Handrail,external!For Racecourse scheme!3D Script

GOSUB 100 : !Work out parametersGOSUB 200 : !Main Tube using TUBEGOSUB 300 : !Round ends

IF nupr>1 THEN GOSUB 400:!Uprights

END:!_____________________________

3D ScriptThe executive script is simply 4 lines, because there areonly 4 operations to carry out. I have put round endsonto the tube, but these could have been a Booleanchoice.

In case the user wants zero uprights, there is an IFstatement to avoid ‘divide by zero’ errors which wouldoccur if you tried to calculate the positions of zero up-rights. The user is able to set a resolution for the maincurve, which could be as high as 360 (1 degree incre-ments). The calculation works out the angular incrementanginc.

100 : !Work out Parameters !(could be in Master Script)lenc=Abulg=B!car = Angl of centreline & radius!bulg= the 'bulge' for the rail car = (90-ATN((lenc/2)/bulg))*2 trad1 = diam1/2 !Rad of Main tube trad2 = diam2/2 !Rad of Uprights radtube = (lenc/2)/sin(car)!radtube is Rad of whole rail radtdif = radtube-bulg !Chordline to centreIF bulg>radtube*2 THEN bulg=lenc/2RETURN

Long Handrail – Swing the Cat!

This handrail is an example of:• How to do long curvy objects without using

ELBOW• Making curved objects stretchy• Some Circle Geometry and Trigonometry• Rigorous control of Polygon count

THIS is a situation where you must use TUBE to makethe object (no matter how long you have tried to

avoid using TUBE!) It is also a way to organise the an-gular distribution of elements, in this case, the uprightsof the handrail.

ELBOW is a problem, especially in large curves, as itrequires a very high RESOL to look good, but whenyou do that, you have a massive number of surfaces torender, because RESOL also applies that number to thetube surface. You cannot use RADIUS either, becauseits highest value is 36; in such a long sweeping curve,36 would still seem too polygonal.

There are several ways of defining a curve. The ob-vious one is based on 1. the Location of the Centre,2. the Radius, and 3. the Sweep angle. In a very largecurve like this, the user does not know any of thesefactors. They are only likely to know the distance be-tween the ends of the chord created by the curve, andconsequently, the bulge of the curve. From this, youcan work out the centre-location, radius and sweep – inthis case, I have devoted Subroutine 100 to workingthose out. These start as A and B, which makes it stretchy,but I prefer to change their names to lenc and bulg.

Page 197: Cookbook3_1

2.94

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

200: !Main Truss Tubing for 3D!Tube algorithm to avoid!having to use a high resolRESOL rst !Set surface resolutionMATERIAL matt: PEN tcol: angd=360/rs !angular diff nrs=INT((car*2)/angd)+1!Make angd fit curv anginc=car*2/nrs !angular increment

!Swing the cat!FOR k=-car-anginc TO car+anginc+0.1 STEPanginc PUT radtube*SIN(k),radtube*COS(k),0,0 NEXT k

ADD 0,-radtdif,thit

TUBE 2,NSP/4,63, 0,0,901, !Formula for trad1,360,4001, ! round section GET(nsp)

DEL 1RETURN

Building TUBE in 3D: Swing the Cat!Next, the PUT statement is used to store all the X,Y loca-tions. (The Z locations are all zero, and the twist angles inthe tube are also zero). This use of PUT and GET is theONLY practical way to set up a large TUBE statement. It isdone in a FOR... NEXT Loop. I call this procedure ‘Swingthe Cat’. This describes a loop that rotates through a cir-cular path using angles as the counter, and using SIN andCOS of the the angles and the radius to work out the XYlocations.

Notice that (to create the phantom start and end points)you need to make the loop start one stepping angle ear-lier; and you need to go one step later than is needed forthe real sweep angle.

You then move to the centre of the circle, and deliverthe Tube statement. The 901 and 4001 numbers are re-quired to draw the tube as a clean cylinder. (Try using900 and 4000 to see the difference it makes.)

‘Swing the Cat!’ explainedYou can swing through a circle at regular angular inter-vals calculating the X & Y locations as you travel. Whenyou want to know X and Y, but already know Radius andAngle (we are talking Cartesian to Polar conversion), it isusually X=R*SIN(ang) and Y=R*COS(ang) if your refer-ence axis is the vertical. In this exercise, we have used avertical reference line. You store the points using PUT,

400: Finally, you calculate the angulardifference between the uprights.

Then retreat to the centre of the cir-cle, and ‘spray’ out the uprights, retreat-ing back to the centre before doing thenext one.

300: It is an easy job to put a sphere atthe end of the tube. The RESOL is thesame as for the tube – I recommend 12or less.

2D Scriptis simply a PROJECT2 command, with aroutine to draw Hotspots to make sure youcan stretch the handrail to the right size.Turn off the bounding box. make sure thatthe Hotspot commands occur first.

Notice that the sweep angle is deliberately exceeded by1/10 of a degree to avoid a decimal> binary> machinecode conversion error

400 : !UprightsRESOL rstangup= (car*2)/(nupr-1)!angle diff between uprights

FOR k=1 TO nupr ADDy -radtdif ROTz car-(k-1)*angup ADDy radtubeCYLIND thit,trad2 DEL 3 NEXT kRETURN

300: !rounded ends

ADD lenc/2,0,thisSPHERE diam1/2 ADDx -lencSPHERE diam1/2 DEL 2RETURN

!2D script for!long handrail

HOTSPOT2 0,BHOTSPOT2 A/2,0HOTSPOT2 -A/2,0PROJECT2 3,270,2

and the resulting points can be used for the edge of aPrism, a pathway for a Tube, and all manner of use-ful things. You can get the effect of the resol com-mand: 10˚ separations is equivalent to RESOL 36, 15˚to RESOL 24 and so on.

If your line is rising from the horizontal, then youuse X=R*COS(a) and Y=R*SIN(a).This diagram shows how this is cal-culated. Imagine a right angle trian-gle. If you haven’t got the Cookbookhandy, you can work it out from thefamiliar SOH CAH TOA saying.

This routine can be used in all man-ner of objects whenever there is cir-cular geometry. For any curved tub-ing, this is always easier and saferthan using ELBOW.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 198: Cookbook3_1

2.95

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Shapemaking with Cone and Cutplane!GDL Cookbook – 3D ScriptMATERIAL 'whitewash'PEN 1

!Make an ellipseIF shape="Ellipse" THENADDx A/2ROTy ATN(B/(A/2))*twk/100CUTPLANEDEL 2ENDIF

!Make a ParabolaIF shape="Parabola" THENADDx -A/2+A*twk/100ROTy ATN(B/(A/2))CUTPLANEDEL 2ENDIF

!Make a HyperbolaIF shape="Hyperbola" THENADDx A/2-(A/2)*twk/100ROTy 90CUTPLANEDEL 2ENDIF

!Draw itCONE B,A/2,0,90,90CUTENDEND

CONE-shapesor... Fun with Cutplane

THERE are various ways of defining the threeimportant mathematical shapes of Ellipse, Pa-

rabola and Hyperbola. This can be done with aformula using X and Y and Radius, with string andnails stuck in a wooden board, hanging chains, orwith bullets fired into the air. The easiest way is tocut a cone at different angles and observe the re-sult.

This exercise is to explore the use of VALUE LISTs,and to get the hang of manoevring CUTPLANEaround the model. It also shows stretchiness andthe benefit of a ‘helpful’ 2D symbol.

VALUES "shape" "Ellipse", "Parabola", "Hyperbola"VALUES "hlp2d" "True View","Show stretchy 2D"VALUES "twk" 10,20,30,40,50,60,70,80,90

Values List: You set up the contents of the Pop-downmenus. Values which are Text have to be in quotes.

Parameters: In this case, all the user options in thesetting box are defined by Pop-down menu. A Value Listparameter can be an ‘ABC’ text type or a number, andyou have to click the little button next to the word‘descriptors’ to activate the pop-down effect.

!Shapemaking!with Cone&Cutplane!2D Script HOTSPOT2 0,0.001 HOTSPOT2 -A/2,0 HOTSPOT2 A/2,0 HOTSPOT2 0, A/2 HOTSPOT2 0,-A/2PROJECT2 3,270,2

IF hlp2d="Show stretchy 2D" THEN HOTSPOT2 0,B POLY2 3,1, -A/2,0, 0,B, A/2,0 ENDIF

Helpful 2D ScriptingThis little routine draws an eleva-tion of the Cone on the 2D sym-bol, with a stretchy Hotspot buttonat 0,B.

If you put enough of your ownHotspots in, you are best to removethe Bounding Box, which will justconfuse the 2D symbol.

The Ellipse– formed by cuttingthrough the curved

faces of the Cone atany angle

The Parabola– formed by

cutting throughthe Cone at an

angle parallel tothe side of the

Cone. Changingthe distance

makes theparabola sharper

or rounder.

The Hyperbola– formed by cuttingthrough the curved

faces of the Conein a vertical cut,

any distance fromthe centre.

Changing thedistance makes thehyperbola sharper

or rounder.

You must declare Materialsand Pen BEFORE you start

cutting planes.

The ‘TWEAK’ here changes theform of the shape: for the

Ellipse by changing the angleof the Cutplane, for the

Parabola and Hyperbola bychanging its distance from the

centre.

Cutplane cuts awayeverything ABOVE it, so youonly have to rotate it to the

right angle, so that what youwant is UNDER the

CUTPLANE.

The Value list of shapes decidewhich of the IF... ENDIF

routines will be carried out.Whichever you choose willresult in ONE Cutplane, so

you only need one CUTENDafter you have drawn the

cone.

If the Values list result inchanging both 2D and 3D

shapes, you may have to writesome short script to parse the

list in the Master Script.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 199: Cookbook3_1

2.96

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

RhombiCubOctahedronor... More fun with CUTPLANE

CUTPLANE enables you to produce objects (by subtraction) thatcannot be sculpted positively.

For example, one can make a CUBE by cutting a SPHERE with 6 differentfaces. In this case, one can take a cube, and cut the corners off to create aTruncated Hexahedron, and ultimately a RhombiCubOctahedron. By vary-ing the dimensions of the cube, and the distance of the cutting plane, onegets interesting shapes.

First – make a CUBEThere is, sadly, no command in GDL thatgenerates a cube or cuboid from a centrallocation. So one uses a PRISM to make itwith. The parameters of width and lengthare made using A and B – this will makethe cuboid ‘stretchy’. The height of thecuboid is an average of A + B.

Having got the CUBE working, convertit to a subroutine by putting in the ENDstatement, and boxing the routine with anumber and a RETURN statement: asshown here.

The CUTPLANE command leavesbehind everything BELOW theblade. You can swivel the blade bya stated angle – so if you wanted theblade to leave everything ABOVE it,you would issue a CUTPLANE 180command.

Take our CUBE – you move the cuttingplane to the correct place by a rotationaround Z, point towards the corner by ro-tating around Y and then move out a statedamount (ADDz). Apply the CUT, then DEL3 to get back to the origin. You have to planall this ahead, because you havent actuallybuilt the cube yet! In the examples here, Ihave shown how the cursor goes to theplace, and the result when it goes back.

CUTPLANENext thing to do it to move a cuttingplane to the places where the cut isto be made. Think of the cuttingplane as a large revolving bacon-slic-ing blade that has to be manoeuvredto the right place, and then set inmotion. You then DEL back to theorigin and build your model – orperhaps set up other blades in mo-tion.

Next you need to devise a way to cut allfour upper corners in one go! The FOR...NEXT routine.

Avoid using the other methodsof Cutplane. The manual does notexplain them well and they causeheadaches getting them to work.

!RhombiCuboOctaHedron!Stretchy Using Cutplane

MATERIAL "Whitewash"

ADDz -(A+B)/4PRISM 4,(A+B)/2, A/2, B/2,-A/2, B/2,-A/2,-B/2, A/2,-B/2DEL 1

!RhombiCuboOctaHedron!Stretchy Using Cutplane

MATERIAL "Whitewash"

GOSUB 100 !Cube

END:!-----------------

100: !Make the Cube!ADDz -(A+B)/4PRISM 4,(A+B)/2, A/2, B/2,-A/2, B/2,-A/2,-B/2, A/2,-B/2DEL 1RETURN

Stage 1: Make Prism Stage 2: MakePrism command

into a subroutine

MATERIAL "Whitewash"

ROTz 45 ROTy 45 ADDz clen CUTPLANE DEL 3

GOSUB 100 !Cube CUTEND

END:!-----------------

!RhombiCuboOctaHedron!Stretchy Using Cutplane

MATERIAL "Whitewash"

ROTz 45FOR k=1 TO 4 ROTz 90*k ROTy 45 ADDz clen CUTPLANE DEL 3 NEXT k DEL 1

GOSUB 100 !Cube

CUTEND: CUTEND: CUTEND: CUTEND:

END:!-----------------

Stage 3: Get one CUTworking correctly

Stage 4: Apply the CUT to all fourcorners of the top of the cube

Page 200: Cookbook3_1

2.97

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Notice in the this routine that we had to do a CUTEND after building thecube. If you don’t do this, the blades continue spinning, and the rest of themodel gets cut. Each cut needs a CUTEND.

In the FOR... NEXT Loop here, you have to start by an initial turn of 45,thereafter, turn at right angles to do each cut. At the end, you do 4 CUTENDS.

Controlling CUTENDIn this development of the script, the idea is to set up a counter called "kut"which is incremented every time you issue a CUTPLANE command. Thisway, you can have FOR...NEXT loops issuing any number of Cutplane com-mands, and the correct number of Cutends will always be issued – in a match-ing FOR...NEXT Loop.

Making it into SubroutinesOnce you have that working, you now encapsulate that whole cutting rou-tine into a subroutine called 200: You need to do this, because you are goingto repeat the whole thing for the underside of the cube; whenever you haveto repeat an operation, use a FOR.. NEXT or a GOSUB to save typing. Once you have got the routine at

200: working, you can Invert it tomake it cut the bottom of the cube.Multiply the Z values by minus 1to make it invert. The MUL com-mand is a ‘cursor movement’ so itneeds a DEL command after.

After you have issued Cutplanecommands, you always have to re-treat back to the origin to do thenext Cutplane sequence, or tobuild the object which is to be cut.

This is a Stretchy Object – its di-mensions are defined by A and B.Or you can type in new values forA and B.

As you can also define the dis-tance of the CUT from the origin,you can create interesting effectsby interplaying the two.

The cube in the script sofar has used a size of 1meter for the cube, and acutting distance of 0.7mdiagonally from the cen-tre. In this one the cut dis-tance is only 0.6m.

This one has a cuttingdistance of 0.45m. Thecut faces now form amore predominant partof the appearance thanthe original cube. Now ithas truly become aRhombicubocta-hedron.

Here, the cut is also 0.45, butthe long dimension of thecube is 2 metres.

Here, the cut is 0.6, and thelong dimension of the cubeis 2 metres.

2D ScriptAs the object is ever chang-ing, give it the minimal com-mands required to make itstretchy.

!RhombiCuboOctaHedron!Stretchy Using Cutplane

MATERIAL "Whitewash"

GOSUB 200 !upper 4-CUT MULz -1GOSUB 200 !lower 4-CUT DEL 1

GOSUB 100 !Cube

FOR n=1 TO kut CUTEND NEXT n

END:!--------------------

100: !Make the Cube!.........Prism etc, etc, etc.........RETURN

200: !Make the 4-CUT etc, etc, etc, etc .....

!RhombiCuboOctaHedron!Stretchy Using Cutplane

MATERIAL "Whitewash"

ROTz 45FOR k=1 TO 4 ROTz 90*k ROTy 45 ADDz clen CUTPLANE: kut=kut+1 DEL 3 NEXT k DEL 1

GOSUB 100 !Cube

FOR n=1 TO kut CUTEND NEXT n

END:!---------

Stage 5: Neaterway to keeptrack of the

number of CUTsand to perform

CUTEND

MATERIAL "Whitewash"

GOSUB 200 !upper 4-CUTGOSUB 100 !Cube

FOR n=1 TO kut CUTEND NEXT n

END:!-----------------

100: !Make the Cube!.........Prism etc, etc, etc.........RETURN

200: !Make the 4-CUT ROTz 45FOR k=1 TO 4 ROTz 90*k ROTy 45 ADDz clen CUTPLANE: kut=kut+1 DEL 3 NEXT k DEL 1RETURN

Stage 6: Make the whole CUTroutine into a subroutine

Stage 7: The Cutting routine cannow be Mirrored in Z to cut allthe underside of the Cube.

!Rhombi!2D scriptHOTSPOT2 -A/2,0HOTSPOT2 A/2,0HOTSPOT2 0, B/2HOTSPOT2 0,-B/2

PROJECT2 3,270,2

Page 201: Cookbook3_1

2.98

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Making a Cube from a Sphere: The same technique can be borrowed tohave fun with making one common shape from another. The routine in thisexercise has been adapted to make a cuboid from a sphere. The top picture hasa cutting distance (from the origin) of 0.5 metres – it remains a sphere. Themiddle one is 0.4 metres – interesting. At 0.33, you get back to the TruncatedHexahedron that we were making before – with rounded corners. Finally, at 0.3metres, the sphere becomes a cube. Note that you MUL X, Y, and Z with a singlecommand.

In this case, the CUTPLANEs are symmetrical, and there is no difficulty in issuingall the CUTENDs at one go. However, in some more complex models, someCUTPLANEs remain in operation, other need to be ended. The order of CUTENDis similar to DEL, in that the most RECENT cut command will be ended. So if themodel has many cuts, you need to plan the order of cuts carefully.

ArchiCAD 6.X includes CUTPOLY, CUTPOLYA and CUTSHAPE commandswhich extend the power of ‘subtractive’ model making even further.

!Cube From a Sphere!Stretchy UsingCutplaneMATERIAL "Whitewash" GOSUB 200 !3-CUTs MUL -1,-1,-1 GOSUB 200 !other 3-CUTs DEL 1SPHERE A/2 !SphereFOR n=1 TO kut CUTEND NEXT nEND:!--------------------200: !the 3-CUT ADDz clen CUTPLANE: kut=kut+1 DEL 1 ROTx -90 ADDz clen CUTPLANE: kut=kut+1 DEL 2 ROTy -90 ADDz clen CUTPLANE: kut=kut+1 DEL 2RETURN

Tips and TricksGetting Strings to work correctly – initialize variables

T HERE is a new statement inAC_6.5, VARTYPE(exprn),

which returns a 1 if the expression isa number and 0 if it is a string. Themain use for this is in File I/O state-ments when reading text file fromdisk.

YOU may have problems with SPLIT and STR commands if GDL does notknow if a variable is a string or a numeral. Parameter variables and ones

already in use in the script are already known. Variables imported from an exter-nal file or table e.g. from a command like:

nr=INPUT (ch, 1,1,varnam).If GDL receives varnam as "44-22-22", is it to accept it as the value 0, or is it astring for a telephone number? You can define in advance the form of a variableby initialising it. e.g.

varnam1=" "varnam2=" "

stitem=" ": lent=0etc. Then ArchiCAD will know that thesevariables must be handled as strings andnot as integers or whatever...

Making Patches ScaleableLaurent Godel <[email protected]>:

T O make scaleable patches, open thePatchTemplate_65.ISM library part, included inside

the ArchiCAD library. Create a new parameter called'scal', real number type, default value 0. The parameterdefinition is "Output Scale (0=current scale)"

Then paste these lines at the beginning of the 2Dscript of PatchTemplate:

!**Scaling routine**!by Laurent Godel [email protected] scal=0 THEN scal=A_fact=A_/scalmul2 fact,fact

Save and create a new patch. The Output Scale param-eter is there. Type in a scale different from your currentdrawing scale and the patch will be stretched accord-ingly. Sorry PlotMaker...

Next all you need is a GDL dimension tool that al-lows you to dimension the scaled patch...I have one ifyou need it!

Why do you need to do a Helix?This close up screw and nut was made a day before the Cook-book went to press, for an armourplated glazing assemblydetail. It’s fully parametric of course, you can screw the nut(a macro) right up to the head (but not a millimetre further).You can vary the amplitude and pitch of the screwthread. Thewashers are stainless steel topped with neoprene body. Theneoprene sleeve is omitted to show you the screw thread.This uses the techniques on the following pages.

Byzanti
Highlight
Byzanti
Highlight
Page 202: Cookbook3_1

2.99

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Helix/Coil

!3D Script

RESOL 6FOR k=-15 to 360*hit/pit+15 STEP 15PUT crad*COS(k),crad*SIN(k),pit*k/360,0NEXT K

MATERIAL coilmatTUBE 2,NSP/4,63, 0,0,901, trad,360,4001, GET(NSP)

Simple Tubular Helix

These are surprisingly easy to make once you havemastered the ‘Swing the Cat’ procedure. To write

out a TUBE command that did this without PUT andGET would be excruciating – it would look like someof the examples in the GDL Manual! By using PUT andGET, you build the entire sequence of pathway points,then ‘throw them’ at the TUBE command with the GETstatement.

Elliptical Helix with controllable curva-tureThe same helix can be made stretchy by using A andB. Stretching these will make the helix elliptical. It’simportant that the tube section is maintained. If youtook the whole object and stretched it with a MUL com-mand, you would get fat tube and thin tube and everyvariation between. Using ‘Swing the Cat’, you can main-tain a constant tube radius. This is a most importantconcept that can be applied to curved window frames,arches and curved tubular structures. As you swingaround the centre, you tweak all values in the Y direc-tion by B/A.

A stepping angle of 15˚ on the first example givesthe actual coil an equivalent RESOL of 24 (the tubeitself is RESOL 6). If you want to control this curvature,make the stepping angle parametric. For example ifthe coil resolution cresl is to be 36, you can have astepping angle of 360/cresl, of 10˚.

You start with -15˚because TUBE needsthe phantom point toget started. the finalpoint is longer by15˚. The 901 and4001 polylines give acircular profile.

!2D Script

HOTSPOT2 0,0HOTSPOT2 -A/2,0HOTSPOT2 A/2,0HOTSPOT2 0, B/2HOTSPOT2 0,-B/2

PROJECT2 3,270,2

!Helix/Coil Elliptical

crad=A/2 !Widthhit=zzyzx !HeightIF cresl<3 THEN cresl=3

RESOL 6stp=360/creslFOR k=-stp to 360*hit/pit+stp STEP stpPUT crad*COS(k),crad*SIN(k)*B/A,pit*k/360,0NEXT K

MATERIAL coilmatTUBE 2,NSP/4,48, 0,0,901, trad,360,4001, GET(NSP)

!3D HotspotsHOTSPOT 0,0,hitHOTSPOT crad*COS(0),crad*SIN(0)*B/A,hitHOTSPOT crad*COS(360*hit/pit), crad*SIN(360*hit/pit)*B/A,hit

You could also turn off thebounding box hotspots to make

the object look tidy in plan

3D hotspots give you something with which to grab andstretch the coil in the 3D window. Use the start and endpoints of the coil.

A Masking value of 63 makes thetube solid, 48 leaves it hollowwith each end having an ink

line.

!Using the same parameters!as the above..... angl=ATN(pit/(PI*A)) h=hit w=hit/TAN(angl)

ROTx 90

cPRISM_ coilmat,coilmat,coilmat, 5, twid, 0,0,15, w,h,15, w,h+thit,15, 0,thit,15, 0,0,-1

Helix with bPRISM_3D ScriptThis technique is ideal for curved walls forming thehandrail of staircases. First lay out a cPRISM_ that startsat the origin and slopes upwards. The angle of the slopeis that formed by the pitch of the helix and the circum-ference of one 360˚ rotation. By changing this to abPRISM, we can, in effect, roll it up into a helix. With aROTx 90, we can make it stand up.

Helix and Spiral forms

Byzanti
Highlight
Page 203: Cookbook3_1

2.100

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Helix/Coil!with tube & bprism

crad=A/2 !Widthhit=zzyzx !HeightIF cresl<3 THEN cresl=3

IF tubpris='Tube' THEN tp=0IF tubpris='bPrism' THEN tp=1

GOSUB 100+tpEND:!________________________

100:!Tube basedstp=360/creslFOR k=-stp to 360*hit/pit+stp STEP stpPUT crad*COS(k),crad*SIN(k)*B/A,pit*k/360,0NEXT K

m=0 !Mask the section outlineMATERIAL coilmatTUBE 5,NSP/4,63+64, 0,0,m, twid,0,m, twid,thit,m, 0,thit,m, 0,0,m, GET(NSP)

HOTSPOT 0,0,hitHOTSPOT crad*COS(0),crad*SIN(0)*B/A,hitHOTSPOT crad*COS(360*hit/pit), crad*SIN(360*hit/pit)*B/A,hitRETURN

101:!bPrism based ADDx A/2 MULy B/A ROTz 90 ROTx 90

angl=ATN(pit/(PI*A))h=hitw=hit/TAN(angl)

bPRISM_ coilmat,coilmat,coilmat, 5,-twid,A/2, 0,0,15, w,h,15, w,h+thit,15, 0,thit,15, 0,0,-1DEL 4RETURN

In this object, we can explore both methods. Thefirst method can be repeated using a rectangular sec-tion. A Value list can be created to let the user decidebetween one method and another.

In the case of the round tube, we made that to becentred along the line of the helix. In the case of therectangular helix, we would want the outside wall ofthe helix to be the line of the helix if it is to be a wall.

When you make the cPRISM into a bPRISM, it willbecome a helix with the origin at the start of the coil. Itneeds a few nudges to get the coil to be centred aroundthe centre of the coil, not at its start. It will need somerotation to make oriented the same way as the Tubebased helix, and will need the MULy B/A to make itstretchy, elliptically. Finally, the wall will be on theoutside of the helix line. By giving a negative thick-ness to the bPrism, it will go to the inside of the Helixline. Experiment with this to see what I am trying toexplain. Change the values and see the model change.

VALUES 'tubpris' 'Tube','bPrism'

This is a rectangularsection based on ‘twid’and ‘thit’. Use m tomodify the sectionmask.

Parse the Value list,make a flag and useit for the subroutine

2D ScriptThe 2D script remains un-changed. It reveals how thesection is deformed in thebPRISM based helix if youstretch it into an ellipse.

!Using the same parameters!as the above..... angl=ATN(pit/(PI*A)) h=hit w=hit/TAN(angl)

ROTx 90

cPRISM_ coilmat,coilmat,coilmat, 5, twid, 0,0,15, w,h,15, w,h+thit,15, 0,thit,15, 0,0,-1

Rendering and smoothing issuesYou can see that there are some problems with ren-dering and smoothing. The bPRISM one looks better.If smoothing is turned on, the TUBE really messes up!If you tweak the Object Masking, you can make a dif-ference. 63+64 turns off smoothing on the Tube objectbut makes the 3D drawing full of lines.

It is oddly inconsistent that you can use 64 in Prismsto force smoothing ON, but in all objects that haveobject masking, 64 turns smoothing OFF.

1. Tube with section masking value of 02. Tube with section masking value of 13. Tube with object masking value of 63+64

4. bPrism –the bestrenderedappearance

1 2 3

By connectingthe tubes with askin (COONS)you can makethis DNA-spiral

Page 204: Cookbook3_1

2.101

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

The Spiral HelixThe difference between them is that a Helix climbsupwards with a constant radius, like a coiled spring,and a Spiral moves outwards, changing its radius as itgoes. In the 3D world, you can have the two combined,as in this model. The exercise builds on the previousmodels, but adds in some more techniques in particu-lar, it demonstrates the use of LOCK.

2D Script and Master ScriptThe Helix was easy as it was a circle or ellipse in planand could easily be 2D scripted if the object was forcommercial use. The Spiral is more complicated, it fliesout in plan view so the 2D script needs to know theparameters if it is to know where to plant hotspots.For this, we move all the housekeeping work of pa-rameter making and Value list parsing to the Masterscript.

!Helix Spiral!Master Script

RESOL reslhit=zzyzx !HeightIF cresl<3 THEN cresl=3 !Error checkIF resl <3 THEN resl=3

!Tube based parametersstp=360/cresl !Angular stepnumstep=cresl*hit/pit !Number of stepssteprad=(endrad-startrad)/numstep

!Different shapesIF tubshap='Round' THEN ts=0IF tubshap='Rect' THEN ts=1IF tubshap='I-sect' THEN ts=2

!Helix Spiral!3D Script

!Calculations moved to!the Master Script

!Tube based - pathway pointsn=-1FOR k=-stp to 360*hit/pit+stp STEP stp crad=startrad+steprad*n PUT crad*COS(k),crad*SIN(k)*B/A,pit*k/360,0 n=n+1 NEXT K

m=1-tublin !Mask section outline, inverseMATERIAL coilmatGOSUB 100+ts:!Do it!!

HOTSPOT 0,0,hit !3D HotspotsHOTSPOT startrad,0,hitHOTSPOT endrad*COS(360*hit/pit), endrad*SIN(360*hit/pit),hit

END:!________________

100:!RoundTUBE 2,NSP/4,63, 0,0,900+m, trad,360,4000+m, GET(NSP)RETURN

101:!RectTUBE 5,NSP/4,63, twid/2, thit/2,m, -twid/2, thit/2,m, -twid/2,-thit/2,m, twid/2,-thit/2,m, twid/2, thit/2,m, GET(NSP)RETURN

102:!I-SectTUBE 13,NSP/4,63, twid/2, thit/2,m, -twid/2, thit/2,m, -twid/2, thit/2-tweb,m, -tweb/2, thit/2-tweb,m, -tweb/2,-thit/2+tweb,m, -twid/2,-thit/2+tweb,m, -twid/2,-thit/2,m, twid/2,-thit/2,m, twid/2,-thit/2+tweb,m, tweb/2,-thit/2+tweb,m, tweb/2, thit/2-tweb,m, twid/2, thit/2-tweb,m, twid/2, thit/2,m, GET(NSP)RETURN

The spiral changes radius as it moves out, so you needto work out the stepping radius, i.e. the change in ra-dius with each turn of the loop. Multiply the cresl bythe number of coils to get that number

Make flags byparsing the Value

list

This is the same loop as before, but with stepping of theradius added into the routine. The first step number is -1because the first point is a phantom point. We use ‘n’ tokeep count of the number of steps done.

Because 0 is ‘show lines’ and 1 is ‘not show lines’, we haveto invert the value of ‘tublin’. (see Maths Tips and Tricks)

These HOTSPOT commands plant 3D hotspots in the rightplace, taking the last real point in the loop as the angle.

Round tube polylinedefinition

Rectangular tubedefinition with the

axis of the tubecentred on the section

I-Section tubedefinition with a

centre axis. This takesa little more thinking

out, so draw it onpaper first

This could all bedone with IF

statements, but ismore structured

with Subroutines,allowing you to

build in extralevels of detail if

you weredeveloping themodel further

Don’t forget thezero twist angle at

the end of theTUBE pathpoint.

There are stillissues withsmoothing.Even with 64added to theTUBE’s objectmasking, youstill get nastyeffects. Bestresult requiressmoothingturned off inRenderingSettings.

Page 205: Cookbook3_1

2.102

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Helix Spiral!Parameter Script

VALUES 'tubshap' 'Round','Rect','I-sect'

IF tubshap='Round' THEN LOCK 'twid' LOCK 'thit' LOCK 'tweb'ENDIF

IF tubshap='Rect' THEN LOCK 'trad' LOCK 'tweb'ENDIF

IF tubshap='I-sect' THEN LOCK 'trad'ENDIF

3D ScriptSee the captions on the script.

2D ScriptUsing the same little formula that was used for the 3DHotspots, you can plant a Hotspot accurately on thestart and end of each tube, and on the centre point.

If you wanted more hotspots, you could turn onBounding Boxes, or you could show hotspots at regu-lar intervals on the plan symbol by doing a loop at 45˚stepping intervals for the first 360˚ of the object’s life.The script here shows how this loop is done. You canuse the same loop as in the 3D script (so all the think-ing has been done for you) – just set a new value forstp, and recalculate what the radius stepping valuewould be. In the loop, start from zero, and go eitherto 360, or if the spiral doesn’t actually go to 360, go tothe top of the spiral. Use the MIN( ) function to en-sure this. Having used PUT, it requires a small loop tomake the hotspots, and this WHILE loop perfectly doesit, as if you were saying: “While NSP has a value otherthan zero, do a hotspot by GETting 2 points from thebuffer each time”.

Parameter ScriptThe Value list lives here. The main interest here is inthe use of LOCK. When the user selects a Round sec-tion, the parameters for the width and height and webare turned grey, and uneditable by the user. Similarlocking is done for a choice of the Rectangular and I-shaped sections.

Property ScriptIf this object was to appear in a listing, it is to write theshort DESCRIPTOR routine, describing the user’s se-lection.

Using the COMPONENTS statement, you could addin numerical data such as the radii, the actual tubelength (for the bar benders), or the weight. As anamusement, I have added in a routine to calculate theareas of the cross section and to calculate the length ofthe helical spiral. You have to add an extra parameter,that of dens for Density. I have also used ArchiCAD’sbuilt in volume calculator to compare the result. Asthe difference is substantial, I am not so amused, andconclude that ‘more research needs to be done”. Withthe I-section, the [dnc] calculation comes out heavierand with the round section, it comes out much lighter.

!Helix Spiral!Property Script

IF tubshap='Round' THEN DESCRIPTOR 'Helical spiral, Round tube' sectarea=trad*trad*PIENDIF

IF tubshap='Rect' THEN DESCRIPTOR 'Helical spiral, Rectangular' sectarea=twid*thitENDIF

IF tubshap='I-sect' THEN DESCRIPTOR 'Helical spiral, I-section'sectarea=twid*thit-(thit-tweb*2)*(twid-tweb)ENDIF

!Extra bits!Calculate Lengthn=0: totlen=0FOR k=0 to 360*hit/pit-stp+0.001 STEP stpcrad=startrad+steprad*nlenbit=2*PI*crad*stp/360totlen=totlen+lenbitn=n+1NEXT K

COMPONENT 'Length of Tube(dnc)', totlen,'metres'COMPONENT 'Weight of Tube(acd)', dens*VOLUME3D(),'Kilos'sectvolm=totlen*sectareaCOMPONENT 'Weight of Tube(dnc)', dens*sectvolm,'Kilos'

Endnote: some mathematical purists would claimthat the Spiral increases its radius by multiplying notby adding. Yes, that is another spiral form, but there’sno space left! YOU try it – have fun!

Add one extra parameter

Basic components listing

!Helix Spiral!2D Script

HOTSPOT2 0,0HOTSPOT2 startrad,0HOTSPOT2 endrad*COS(360*hit/pit), endrad*SIN(360*hit/pit)

PROJECT2 3,270,2

!2D extra quality!Pathway points stp=45 !Angular step steprad=(endrad-startrad)*(pit/hit)/8 n=0FOR k=0 to MIN(360,360*hit/pit) STEPstpcrad=startrad+steprad*nPUT crad*COS(k),crad*SIN(k)*B/An=n+1NEXT K

WHILE NSP DOHOTSPOT2 GET(2)ENDWHILE

Page 206: Cookbook3_1

2.103

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

DXF conversionConvert manufacturers’ products

GDL has a big future with ArchiCAD enthusiasts,but that is nothing compared with the status it will

achieve if manufacturers of building products recog-nise it as a suitable language for 3D form – and startoffering architects CDs of their product libraries inBOTH DXF and GDL. If ArchiCAD users and AutoCADusers can make equal use of the paramatric powers ofthe GDL products, DXF may become a distant memory,a bit like CPM and MSDOS.

DXF is just so inconvenient to use compared withGDL. A GDL smart object, such as a sanitary fitting cancontain the 2D plan, the 2D front elevation, the 2Dside elevation and the 3D form, and a 3D wireline formall within the same object; in addition it can containmanufacturer’s data on serial numbers, weight, cost,volume, maintenance info and more; database integra-tion that can transform the way we design, build andmanage buildings. In fact, if the 3D model isn’t toovoluminous (and if they come from DXF they usuallyare!), you can get a whole range of manufacturer’s prod-ucts inside one single smart GDL object.

GDL objects are so compact that they can be pub-lished on the web, downloaded in seconds, and work-ing in the 3D model or the 2D drawings in a few mouseclicks! Graphisoft have provided the technologyneeded for potential users to view and test GDL ob-jects before they download. Manufacturers can nowoffer live libraries on their websites – instead of show-ing pretty pictures, they can show working models oftheir products and provide every inducement for de-signers to specify and instal those same products.

If all goes well, there should be a lot of work foryears to come converting DXF drawings of manufac-tured products to GDL and writing products yet to comein native GDL. Let’s work out a typical procedure fordoing this economically. Remember that with dozensor perhaps hundreds of products to convert, there’sno point in over-elaborating. Just get the job done effi-ciently. The elaboration will come when we have theleisure time to review converted objects and convertthe 3D part of the GDL to native GDL.

There’s is a whole manual on the subject of DXF/DWG conversion so there is no intention to reiterateall the details – we will stick strictly to object making.

DXF/DWG files are usually stored separately. A typi-cal object, say a water closet, is represented by at least4 files: a 3D model, a 2D plan, a 2D front elevation,and a 2D side elevation.

Before we proceed. ask yourself: Do I know enoughabout the use of FRAGMENT2? If you do not, thenmug up FRAGMENT2 quickly, it is vital to the successof this conversion.

DXF files are almost three times the size of theequivalent DWG file. When brought into GDL, there issome reduction, but the example featured here stillfinishes up as a GDL object of about 380k – unless youchoose to rebuild the 3D model entirely, in which caseit will reduce to a tiny fraction of the original size.

Let’s do a typical file conversion1. Bring the file into ArchiCADDXFs brought into ArchiCAD itself always arrive as 2Dfiles. As your intention is to make library parts, youalso have a option to open them as a library part –click this option and bring them in. Then you can copyand paste the contents of 4 such files into one singlefile with a bit of smart scripting to separate them.

There are issues of scale – it is not uncommon for abrought-in file to be a thousand times too big or toosmall – depends on the scale of the original drawing.These objects (from Armitage Shanks) all come in 1000times too big unless you tell GDL to treat 1 Autocadunit as 1.0. It’s alarming to imagine a WC that is almosta kilometre long – but thats what you could get!

If you wish to bring in a 3D DXF/DWG, you couldfirst open the 3D file as a binary library part, and addthe 2D library part symbols to it. But this will be 1.5times the file size of bringing it in as editable script,and you would only be able to have that one object inthe file. If perchance you want your GDL to containseveral objects (selected by a value list) then its best to

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 207: Cookbook3_1

2.104

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

bring them all in as editable GDL and write some littlesubroutine structure to organise them.

If you want to bring in dozens or more objects (per-haps an entire library of sanitary fittings), most of themwill be on the manufacturer’s CD in a baffling jumbleof serial or type numbers. I advise to bring them •all•into the ArchiCAD floorplan so you can survey theentire range of symbols to be converted, group them,organise them, decide which one will go together andso on; having thus organised, you may actually do theprocess by bringing them in as library objects.

The default conversion may be 1000. Experiment. If yourobjects come in several kilometres wide, throw them awayand reimport with a smaller conversion.

You will be asked to find a font file – you can SKIP it

2. Organising the files – move fragmentsOK, so you may have 4 GDL files open at once! Savethem all to a library, then drop all four of them into afloor plan window. One more file, a fifth one, is theone in this exercise – open this later as a template forbuilding your objects.

The 2D objects (and the 2D symbol of the 3D ob-ject) will all be in Fragment number 1, so the task is tocopy and paste the symbols into one GDL object with-out getting the fragments mixed up. This is a most vex-ing process!! It is explained here.

a. Open the GDL object with the 2D Plan. Open the2D symbol window. We’re going to move the plan tofragment 16 as temporary parking space. On the frag-ment button bar, change 16 to Hidden. Now select thewhole plan view and move it to fragment 16, using thepopdown layer/fragment selector in the Info palette.First the Lines disappear. Do it again. Now the Arcsdisappear. Do it again. Now the Text disappears. Ifnothing else shows, the whole symbol is now in frag-ment 16.

Click and select here to push the2D elements to the correctfragment

Hit the Details button to hide theBounding Box hotspots

These buttons Hide or Displaythe Fragments, dark=visible,light=hidden

None of these text bits are ofinterest so they can be deleted.Edit out any bit that you don’twant, and use 2D tools to tidyup as appropriate

If you first hide fragment 16, youwill see Lines, then Arcs thenText ‘disappear’ until thewindow is blank. Now you havespace in fragment 1 to paste inthe next 2D image

The 2D symbol window actuallycontains 16 separate layerscalled Fragments. Use them here!

2D Planobject

2D SideElevation object

2D FrontElevationobject

3D object

Page 208: Cookbook3_1

2.105

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

b. Open the symbol window of the Side Elevationobject. Copy (or Cut) the whole symbol; return to thePlan object, open the 2D symbol window and Paste. Itwill be dumped into fragment 1. You are going to movethe drawing to fragment 2. Hide fragment 2 in the frag-ment button bar, then move the whole fragment from1 to 2 using the method described above (of repeat-edly shifting each set of 2D elements). Close the SideElevation object.

c. Open the symbol window of the Front Elevationobject. Do it all again (now you have got the hang ofit!) and put it in fragment 3 of the Plan object. Closethe Front Elevation object.

d. Open the 3D script of the 3D object, Copy the wholescript, return to the Plan object and Paste the whole 3Dscript into the 3D script window. Close the 3D object.

e. Return to the Plan object, show fragment 16, andhide fragment 1, 2 and 3. Move the 2D plan from frag-ment 16 to fragment 1. Go on moving elements until16 is quite empty. Save the file under a new name,

based on the objects description and number. Put itinto a loaded library, one that you have created for thestorage of all your newly converted files.

f. Now, leaving the other two hidden, take each frag-ment in turn, tidy up the image, filling in missing lines,removing bad bits of text, and positioning the image cor-rectly over the origin. Add Hotspots to each image, en-suring beforehand that you double click the hotspot tooland tell it precisely which fragment it is going into.Hotspots should be in significant corners or axes, withone in the middle for picking up. Click on the Detailsbutton in the objects title bar, and untick the BoundingBox hotspots. Set all line colours to a single colour, blackwill do (you can change it later from the settings box).

3. Convert to a Smart ObjectBuild a list of parameters for the new object. To makeyour life easy, use the same variable names on everyoccasion. You may need to add more if the objects youare making require additional definitions of materialor if you are including more than one object in thesame file.

Now open the Conversion Template object (whichwe are building now), copy the significant parts of theMaster script, the 2D script, the 3D script, the Param-eter script and the Property script. Paste them, one at atime into the script windows of the WC Object. For the3D bit, paste the template text ABOVE the 3D descrip-tion of the object.

The side and front elevations are provided for usein sections and elevations, into which you can place2D objects. A 2D version of the plan can be shown inthe 3D drawing if the user does not require a fully solidmodel. See the 3D script.

Because label is anoption, the fine detailsare hidden inside acascading set

DESCRIPTOR desc_str1

!DXF/DWG Conversion Template!Master script

VALUES 'show23' '3D model', '2D plan','2D side view','2D front'

VALUES 'fnam' 'Geneva','Arial','Times', 'Verdana','Helvetica','Georgia','Courier'

IF show23= '3D model' THEN dt=0IF show23= '2D plan' THEN dt=20IF show23= '2D side view' THEN dt=21IF show23= '2D front' THEN dt=22

x=REQUEST("Rgb_of_pen",matpen,pred,pgreen,pblue)DEFINE MATERIAL "Body_Shiny" 4, pred,pgreen,pbluebodymat=IND(MATERIAL,'Body_shiny')

desc_str1='Armitage Shanks WC 601'!for listingdesc_str2='WC 601' !for 2D symbol

Value lists can be in the Parameter script or the Mas-ter script. Put them first.

Parse the Value list and convert to flags

Extract a colour. If your manufactured objects havespecial ranges of colours (say three colours for a lamp,black, white and dark green) you might have to buildthose materials with Define, and make a Value list toselect them. In this example, the Pen colour can beanalysed into Red, Green and Blue, and convertedinto a colour. ‘Plastic’ usually gives the best results forhome-made materials.

Text descriptions, insert one to appear in a listing,and another as an optional label in the 2D symbol.

For the moment this is the minimum you need for theProperty script, unless your client wants to go overboardwith greater levels of detail.

In this case, the font size is NOT a plotting size, it remainsconstant to a real dimension, whatever the scale

Learn this technique!You can have fun with this technique – you can freelydownload DXF models of the Eiffel Tower or Chrysler build-ing and a host of other wonderful structures off the Internetand convert them to GDL.

Byzanti
Highlight
Page 209: Cookbook3_1

2.106

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!DXF/DWG Conversion Template!3D script

!Open Each file first as an object. Unit is 1 millimetre.!Then open the 2D objects one at a time and drag 2D into!fragments 1, 2 and 3 of the 2D Plan object. Edit the!2D images and ensure that they fit. Copy 3D!script into 3D script of 2D Plan object.!Resave 2D plan object as final new object.!Build Parameter table and value lists for new object.!Copy over Master, 2D and 3D script bits from the!Conversion Template object. Nudge 3D to fit.!Untick the box for Bounding Hotspots, plant your own!Test Object – tune object.

PEN pcol3MATERIAL bodymat

ADD -0.393/2,-0.700,0 !nudge into positionIF dt=0 THEN GOSUB 100 ELSE GOSUB 200DEL TOP

END!-------------------------------------

100:!3D solid modelPLANE_ 3,

0.299818, 0.035215, 0.452023, 0,0.320588, 0.045317, 0.452023, 0,0.160630, 0.020968, 0.452033, 0

PLANE_ 3,0.299818, 0.035215, 0.452023, 0,0.160630, 0.020968, 0.452033, 0,0.195927, 0.020968, 0.452035, 1

PLANE_ 3,0.012636, 0.351726, 0.452027, 0,0.019182, 0.167628, 0.452024, 0,0.384218, 0.443323, 0.452026, 0

PLANE_ 3,0.039468, 0.621380, 0.731770, 0,0.048015, 0.560041, 0.746757, 0,0.045833, 0.621251, 0.745732, 1

!...... and so on for thousands of lines until it! finishes describing every damned polygon!!RETURN

200:!2D view of planPEN pcol3LIN_ 0.194345, 0.700254, 0, 0.371504, 0.700254, 0MODEL WIREADDX 0.371504ADDY 0.680254ARC 0.020000, -1.832342, 90.000000DEL 2LIN_ 0.391493, 0.679614, 0, 0.386457, 0.522175, 0LIN_ 0.386457, 0.522175, 0, 0.368389, 0.511478, 0LIN_ 0.368389, 0.511478, 0, 0.365417, 0.466724, 0ADDX 0.355439ADDY 0.467387ARC 0.010000, -86.968877, -3.799346DEL 2!.... and so on until every line is includedRETURN

!DXF/DWG Conversion Template!2D Script

!Armitage Shanks!WC range

PEN L_HOTSPOT2 0,0

IF labl THENIF A_<101 THENDEFINE STYLE 'labl' fname, fsiz*1000/A_,2,0SET STYLE 'labl' TEXT2 0,0,'ArmSh' TEXT2 0,-fsiz*1.1,desc_str2 ENDIF ENDIF

IF dt=0 OR dt=20 THEN !PlanFRAGMENT2 1,0ENDIF

IF dt=21 THEN !Elevation SideviewFRAGMENT2 2,0ENDIF

IF dt=22 THEN !Elevation FrontFRAGMENT2 3,0ENDIF

!!!project2 3,270,2

2D ScriptStandard title is pasted in at the top. Insert the title of the particularobject you are making.

Pen can be set in the user’s settings box, and write the Key hotspot

If the user wants a label, you need to define style. In this case, font sizeis autosizing, even if the user changes scale. At smaller than 1/100scale, the label disappears. The label is on two lines, you may want toadapt this to your own needs.

If the object is in 2D in Plan or 3D then it will use Fragment 1. The zeroflag allows the user to set the colour from the main object settings box.Use the Project2 to nudge the 3D object to fit the 2D plan symbol.

3D ScriptAs you may not have your Cookbook to handall the time (shame!) then include a summaryof the instructions at the top of the script. Youmay need them again.

Set the Pen, set the material (that you built inthe Master script)

The ADD command is an offset to make the3D fit over the 2D. Use Project2 in the 2D.The offset here is actually half the width ofthe WC and the full length.

As the DXF for this WC kindly provided a 2Dversion of the WC that would appear in 3D ifthe solid object was not required, it has beenseparated into another subroutine 200. If ithadn’t provided one, you could place the 2Dplan symbol over the origin, explode it, draginto the 2D script, form it into a subroutineand you have made your own 2D image foruse in the 3D drawing. Since the 3D objectcould have thousands of polygons, it’s wiseto allow the designer to place 2D objects inthe 3D environment and only show them assolid when 3D renderings are required.

Page 210: Cookbook3_1

2.107

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Desktop Clock/ FilestampAdventures in 2D GDL ScriptingThis covers: REQUEST, Defining Style,Value List, Making fonts to autosize todrawing scale.

ALTHOUGH all of us enjoy the luxury of a clockdisplayed on the menu bar of our computer or

on our wrists, this clock is useful because it can bescaled to fit the building you are working on, or thescale of the document for plotting. So it will accu-rately datestamp the time and date of a Plot. It getsupdated everytime there is a Reload of the file. Thishas been adapted to show Project Name.

ParametersOffer a choice – If you are plotting, you can fix thesize to the Plot, and then the height in millimetreswill be the height of the text. If you tick the box to fitthe Plan, it will always relate to the size of the build-ing, whatever the scale of the drawing. Plotting heightis defined strictly in millimetres, you must set the Typeas a number, not dimension. Use a Value List for thePlot/Plan choice. A and B are not used. The user candisplay just a title box without a clock.

REQUESTThe REQUEST command must be amongst the mostdifficult of all the GDL commands, since the manualprovides an example that is itself in error – and theDateTime routine does not appear in the manual any-way. Read the DateTime Readme file in yourGraphisoft folder for deeper information. The ‘x=’before REQUEST creates a value for x of 1 or 0 if thecommand succeeds. It is not necessary, but reportsan error if you do not use a dummy variable. Useany letter not already in use, if not x.

STW( )is a way of determining in metres, the length of astring when printed on the page in the defined style.It is difficult to set the clock size to follow the Plot orthe Plan, and the script here is the result of muchtrial and error research – but it works! Many peopleuse this!

CommentGDL doesn’t have a VAL( ) function to convert textstrings into numbers like BASIC. The Time and Dateinfo, even when apparently returned in numbers, isactually a string. GDL’s SPLIT( ) command is theequivalent to VAL( ). With SPLIT to read numbers,you can make an analog clock with revolving hands.(Ana-Clock by Trevor Grant 1999)

VALUES 'clockshape' 'Clock Only', 'Project Title','Clock and Project'VALUES 'clockscale' 'Scale to PLOT', 'Scale to PLAN'

Put this in the Value List script

Use this tomark upyourdrawings

!Desktop clock/ Filestamp

IF clockshape='Project Title' THEN clkshp=1IF clockshape='Clock and Project' THEN clkshp=2IF clockscale='Scale to PLOT' THEN clspln=1IF clspln THEN htx=htxt ELSE htx=htxt*10/A_

PEN projpen

DEFINE STYLE 'clock' fontnam,htx,1,(1-clkshp/2) SET STYLE 'clock'

x=REQUEST('Height_of_Style','clock',height) len =STW('day 00 mon year')*A_/1000 hit= height*A_/1000

!HotspotsHOTSPOT2 0, 0HOTSPOT2 0, hitHOTSPOT2 len,hit

IF clkshp<>1 THEN x=REQUEST('DateTime','%a %d %b %Y',dstr) x=REQUEST('DateTime','%X',tstr)

!Display date and time TEXT2 0,0 ,dstr TEXT2 0,hit,tstr

!Body of Clock ARC2 0.0,0,hit,90,270 ARC2 len,0,hit,270,90 LINE2 0, hit,len, hit LINE2 0,-hit,len,-hit

HOTSPOT2 0, -hitHOTSPOT2 len, -hitHOTSPOT2 -hit, 0HOTSPOT2 len+hit, 0HOTSPOT2 len/2, 0 ENDIF

!Show Project NameIF clkshp THENIF clkshp=1 THEN ADD2 0,-hit

DEFINE STYLE 'title' fontnam,htx*1.6,2,1SET STYLE 'title'

x=REQUEST('Name_of_plan','',filename) TEXT2 len/2,hit*2.5,filename HOTSPOT2 len/2, hit*2.5 HOTSPOT2 len/2, hit*1 ENDIF

‘dstr’ is the Date String‘tstr’ is the Time String

In Europe, AC plots inmillimetres, but my readers inUSA can adapt this to points.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 211: Cookbook3_1

2.108

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Analog ClockGDL by Trevor Grant

THIS beautiful clock by Cookbook reader TrevorGrant actually keeps time. Everytime you do a re-

build, it updates – second by second. In fact, it’s somuch fun, I don’t get any work done. I sit here all daygoing Rebuild... Rebuild... Rebuild....

You can interrogate your computer’s system to findthe time and date using REQUEST, but the result comesas a string (text) not as a number. Trevor sent me anearly version in which he laboriously used string pars-ing to find out the time and date before building theclock. I pointed out to him the wonderful SPLIT( ) com-mand. Within a day or two, he had completely rewrit-ten it using SPLIT in a fraction of its previous size.

SPLIT extracts digits from a string, and if they arenumeric, it passes their real value to a variable. If theyare alpha characters, the variable is given a value ofzero. If you can predict accurately the composition ofa string (where digits will occur), this is an excellenttechnique. It’s valuable for parsing Value lists, and it’sgood for parsing REQUEST statements.

!Analog Clock2 – using 'SPLIT()!by TIGrant 1999

PEN pcol!Initialise variablestheString=""!number as stringtheNumber=0 !number as numbern=0B=A !A width X=Y height Br=A/2 !clock face radiush=r/10 !clock depthhourStr=""minsStr=""secsStr="" !times as strings

!Get the Timex=REQUEST("DateTime","%I",hourStr)x=REQUEST("DateTime","%M",minsStr)x=REQUEST("DateTime","%S",secsStr)

!Do hours/mins/secstheString=hourStrGOSUB 123 !Split!hour=theNumbertheString=minsStrGOSUB 123 !Split!mins=theNumbertheString=secsStrGOSUB 123 !Split!secs=theNumber

!3D Build the ClockROTX 90

MATERIAL ColFaceRESOL 36 !for the clockfaceCYLIND h, r !Face

MATERIAL ColHandsCYLIND h*0.99, r*1.05 !Rim

!Axle/hubRESOL 12 !for the hub ADDZ h*1.01 !i.e. just above clock faceMATERIAL ColHandsCYLIND h*2, r/15 ADDZ h*1.45MATERIAL ColSecsCYLIND h/2, r/10

DEL 1

!Number MarkersMATERIAL ColHandst=r/30tt=tth=r/5mk=r*0.75DEFINE STYLE "aStyle" fontnam,th*1000,7,0SET STYLE "aStyle" ADDX -th ADDY mkTEXT tt, 0, "12" DEL 2 ADDX mk+th/4 ADDY -th/2TEXT tt, 0, "3" DEL 2 ADDX -th/2 ADDY -mk-thTEXT tt, 0, "6" DEL 2 ADDX -mk-th ADDY -th/2TEXT tt, 0, "9" DEL 2

!Intermediate hour dot markersRESOL 6mkk=mk*1.15 !Radius from Centre!Put Angles where we want dotsPUT 30, 60, 120, 150, 210, 240, 300, 330mkk=mk*1.15REPEAT ADD mkk*SIN(USE(1)),mkk*COS(GET(1)),0 CYLIND t, t DEL 1 UNTIL NSP=0

Initialisevariables. It’s

not alwaysnecessary in

normal GDL,but is good

when you arehandling

strings. Fromthe start, you

establish that avariable willbe a string,

and it avoidsspurious error

messages

The REQUESTstatement is the

the brainbehind this

script

SPLIT( ) iscontained in

subroutine 123: the beatingheart of the

script

Now it’s the taskof building the3D clock face

and hands

DEFINE STYLE can be usedin 3D lettering

I have rewritten this hour dot markers section for Trevor.He laboriously posted 8 separate hour markers, requiring28 lines of code. This demonstrates how PUT and GET anda Loop can dramatically shorten a script.

USE allows you to use a number once. The second time, itis removed from the buffer with a GET statement.

Repeat... Until is the best form of loop to use when usingPUT&GET

VALUES 'fontnam' 'Arial', 'Times'

Put this Value list into theparameter script. Add more fontsif you like

This section could also (like theone below) be shortened with aPUT statement but let’s not get

too geekish!

Byzanti
Highlight
Page 212: Cookbook3_1

2.109

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

IF showName THEN !makers name, etc DEFINE STYLE "anoStyle" fontnam, 1000*th/4,7,0 SET STYLE "anoStyle" ADD -mk/3,-mk/1.5,0 TEXT tt, 0, "AnalogClock" ADDY -th*1.75/4 TEXT tt, 0, "©TIGrant" DEL 2ENDIF

!Hands!HourangH=(30*hour)+(0.5*mins) ADDZ t*1.1 ROTZ -angHl=mk*0.66667w=th*0.66667MATERIAL ColHandsPRISM 4, t, -w,0, 0,l, w,0, 0,-w*1.5 DEL 2

!MinsangM=(6*mins) ADDZ t*2.2 ROTZ -angMl=mk*1.1w=th*0.5MATERIAL ColhandsPRISM 4, t, -w,0, 0,l, w,0, 0,-w*2 DEL 2

! Analog Clock 2 – 2D Script! by TIGrant 1999! Offered to users of the GDL Cookbook

HOTSPOT2 0,0HOTSPOT2 -A/2,0HOTSPOT2 A/2,0HOTSPOT2 0,-A/20HOTSPOT2 0,-A/10HOTSPOT2 0,-A/6.75

PROJECT2 3,270,2

!SecsangS=(6*secs) ADDZ t*3.3 ROTZ -angSl=r*0.9w=th*0.25MATERIAL ColSecsPRISM 4, t, -w,0, 0,l, w,0, 0,-w*5 DEL 2

DEL TOPEND:!_______________________________

!Subroutine – does all the hard work!!123: !the string to number using SPLIT( ) n=SPLIT(theString,"%n",theNumber)RETURN

EndnoteA reader of the Cookbook in Australia used this clock– put it up into a church tower. It was only after he hadbeen working on the model some days that he noticedthat it was always showing the right time!

!Fountain created by Frank Chin

!Formulae!v=u+at u=initial velocity!s=d+ut+1/2*a*t^2 v=velocity at point!d=initial distance!s=distance at point!a=accerelation=gravity=-9.81!t=time

MULY b/aRESOL reslMATERIAL mtl

!Time for droplets to hit the watertt=(SQR(2*9.81*ht1)+SQR(2*9.81*ht1-2*9.81*ht2))/9.81

FOR j=1 TO nubFOR t=1 TO nuw/3 tme=RND(tt/2) dirx=a/(2*tt)*tme dirz=SQR(2*9.81*ht1)*tme-9.81/2*tme^2

!Disperse the water-drop ROTZ RND(angd)-angd/2 MULX 0.97+RND(0.06) MULY 0.97+RND(0.06) ADDX dirx ADDZ dirzSPHERE rdus DEL 5 NEXT t

!Twice as much water on way downFOR t=1 TO nuw/3*2 tme=tt/2+RND(tt/2) dirx=a/(2*tt)*tme dirz=SQR(2*9.81*ht1)*tme-9.81/2*tme^2!Disperse the water-drop ROTZ RND(angd)-angd/2 MULX 0.97+RND(0.06) MULY 0.97+RND(0.06) ADDX dirx ADDZ dirzSPHERE rdus DEL 5 NEXT t

ROTZ 360/nub NEXT j

DEL TOP

FountainTHIS is a superb piece of work by Frank Chin which

shows GDL as a calculation machine – it calcu-lates droplet pathways according to ballistic formulaeand applies random numbers to simulate the chaos ofdrop dispersal.

Endnote2D Script is just a Project2, but for the purist, a circlewith some radiating lines might be a good symbol. Also,one could follow this by building the water pool as aMASS command, and providing a ‘spattering’ algorithmto roughen the surface where the droplets were calcu-lated to fall.

These are the basicformulae for

projectiles

Note: If it’s stretchy,always put the hotspots

first!

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 213: Cookbook3_1

2.110

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

VALUES 'offst' 'Centrally aligned', 'Aligned to wall'

Curtains!

CURTAINS are always a problem when the CAD environment is made of hard polygons. How do you

make something look soft and flowing? Sometimes it’sbetter to map a texture onto a surface than to try tomodel it geometrically in all its detail. Here is a halfway solution. It builds a geometric curtain, but givesthe user good control over polygons, looks realistic,and when you ‘draw the curtains’ in the 3D window, itis uncannily realistic.

This curtain is a reduced version of a commercialcurtain object I have written. The real curtains havetop tufting, a metal rail in different styles, rings, a heavyhem.

This curtain demonstrates:• Trigonometry in action• The power of the RULED command

PlanningThe design approach is to trace out a SIN wave alongthe foot of the curtain, count the number of points re-sulting, and replicate exactly the same number of pointsat the top, but this time, doing it as a stretchy Zig-zagform. Using a RULED, you just join the two lines to-gether.

ParametersThe parameter box is built with cascading buttons. Thecurtain could hang vertically, but in case it’s against awall, there is an offset at the top. The other parametersare for controlling the number of billows, the waveamplitude, polygon smoothness and 2D appearance.

Master ScriptThere are some calculations to be done to parse theValue list and to calculate the waviness of the curtainSIN wave.

3D ScriptBecause this is part of a larger object, only subroutines200 and 400 are retained. The routine runs along theSIN wave, storing values repeatedly until it reaches ‘A’,the end. It counts these up (k=NSP/3) and then pro-

!Long hanging Curtains! 3D Script

PEN pcol

GOSUB 200:!Main Curtain elementGOSUB 400:!3D Hotspots

END:!-----------------------

200:!Main Curtain elementMATERIAL cmatlFOR d= 0 TO A+0.01 STEP wlenFOR n=180-angb TO angb STEP -angb PUT d+wrad*COS(n), PUT wrad*SIN(n)*wcurt/wrad,(1-sl) NEXT nFOR n=180+angb TO 360-angb STEP angb PUT d+wlen/2+wrad*COS(n) PUT wrad*SIN(n)*wcurt/wrad,(1-sl) NEXT n NEXT d

k=NSP/3 flen=(A+wlen/2)/(k/2) !fold length

FOR n=1 TO k/2 PUT flen*(n-1),tofset-wfold/2,tz !Zig PUT flen*(n-1)+flen/2,tofset+wfold/2,tz !ZagNEXT n

RULED NSP/6,16,GET(NSP)RETURN

400:!3D HotspotsHOTSPOT 0,0,tzHOTSPOT A,0,tzHOTSPOT wrad,0,zzyzxHOTSPOT A/2,0,zzyzxHOTSPOT A-wrad,0,zzyzxRETURN

!Master Script!Pleat OffsetIF offst='Centrally aligned' THEN ot=0IF offst='Aligned to wall' THEN ot=1

!CurvatureIF smooth<1 THEN smooth=1IF smooth>5 THEN smooth=5

!Details of foldnumfold=numfold-1IF numfold<3 THEN numfold=3 bnum=smooth+3 !Bit number/billow wlen=A/numfold !Wavelength wrad=wlen/4 !radius of wavebit angb=180/bnum !angular distribution tz=zzyzx !height of curtain

!Top offsettofset=(wcurt/2-wfold/8)*ot

RULED doesnt providea way of removing

the edgeline betweenbillows, but you can

turn the top andbottom lines on

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 214: Cookbook3_1

2.111

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Long hanging Curtains!2D Script

PEN L_HOTSPOT2 0,0HOTSPOT2 A,0HOTSPOT2 0,tofsetHOTSPOT2 A,tofsetHOTSPOT2 A/2,0

!Centre lineFOR k=1 TO numfoldADD2 wlen*(k-1),0LINE2 0,0,wrad,0DEL 1NEXT k

PEN pcolCIRCLE2 0,0,0.01CIRCLE2 A,0,0.01CIRCLE2 0,tofset,0.01CIRCLE2 A,tofset,0.01

PROJECT2 3,270,1

duces a zigzag pattern to match, at the top. The num-bers for a bottom and top of a RULED go in the samedirection so this is easy. It would also be possible butharder if using a COONS statement, but why do that ifa RULED will do it just as well?

The 3D hotspots are valuable because they make iteasier to grip the curtains when you are ‘drawing’ them.Remove the bounding box hotspots.

Endnote : forward to greater heights!The range of curtains in a building could be consider-able and would be a nuisance for the user to keep hav-ing to build materials. If there was a known range offabrics available, you could have a User Interface pre-senting the range of fabrics. The user could select afabric, the texture would be made and mapped to thecurtain – thus removing the need for the user to maketheir own Material in the Options menu. Thats’s wherewe shall go next!

Built in Textures and the UserInterface

WHENEVER providing a choice to the user whichinvolves a visually based decision, consider of-

fering them a pictorial Value list. The first time you dothis, it is very difficult, but once you have got oneworking, you can copy and paste to make the laterones easier to build. The GDL-CB contains an increas-ing number of examples which you are welcome toborrow.

• Find your textures. I have found 4 examples here.

• Save them in your project library in equally sizedrectangles which repeat at edges. These tiles are 200 x200 pixels. They are also copied onto a single bitmaptiled image, and the whole tile image is resized to 280x 280 which is ideal for a User Interface.

• Build a Value List that contains the filenames of thetextures. Build a few more parameters, allowing theuser to choose between predefined Material or a Tex-ture.

• Update the Master script to include the Texture andMaterial definitions. Read ahead to the section onCOOR and VERT for more detail.

• Modify the 3D script to set material according to theuser’s choice.

• The user interface script is easy once you have donea couple. Use some trial and error for the final adjust-ments of the tile sizes.

The circles are here tomake it easier to pick

up and stretch thecurtains

VALUES 'matex' 'Material','Texture'VALUES 'ctxtr' 'Morocco.jpg','Tartan.jpg', 'Redtile.jpg','Mensa.jpg'

Add these lines to your Value List

The texture images are200x200 and the tiledselector image is 280x280

Add these lines to the Master Script!Curtain Texture Definition

IF scatx<1 THEN scatx=1 !Set a limitIF scatx>5 THEN scatx=5 !to scaling

DEFINE TEXTURE 'curtextr' ctxtr, 0.3*scatx,0.4*scatx,1,0

DEFINE MATERIAL 'curtmatl' 24, 0.5,0.5,0.5, 0,61,IND(TEXTURE,curtextr)

Modify the 3D script starting at subroutine 200200:!Main Curtain elementIF matex='Material' THEN MATERIAL cmatlIF matex='Texture' THEN MATERIAL 'curtmatl'

UI_DIALOG "Curtains, stretchy"

UI_INFIELD 'ctxtr',12,16,286,150, 1,'curtain_textrs.jpg',4,2, 130,140,120,120,1,'Morocco.jpg',2,'Tartan.jpg',3,'Redtile.jpg',4,'Mensa.jpg'

UI_STYLE 1,1UI_OUTFIELD 'Please Choose your Fabric', 12,170,200,30

This is the User Interface: please try it out

Read ahead formore about

DEFINE TEXTURE

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 215: Cookbook3_1

2.112

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Handrail!Master Script!Parameters for handrail

IF chunk<3 THEN chunk=3 angl=(90-ATN((A/2)/B))*2 !Sweep angle crad=(A/2)/SIN(angl) !Curve Radius trad=diam/2000 !HRail Tube Radius angd=angl*2/chunk !angle difference hitd=zzyzx/chunk !height diff/chunk

!Parameters for downrights & ends & infil dnrad=ddiam/2000 !Downright Radius dnnum=ABS(dnnum) !make it positive IF dimen<trad THEN dimen=trad IF endstyl='Butt cut ends' THEN es=0 IF endstyl='Downward Elbows' THEN es=1 IF endstyl='Rounded ends' THEN es=2 IF dropin<0 THEN dropin=0 IF lenin<=dropin THEN lenin=dropin+0.001

IF dnnum>1 THEN angdw=angl*2/(dnnum-1) !angle diff hitdif=zzyzx/(dnnum-1) !height diff ENDIF !avoid divide by zero error

!Parameters for ends!sloping angle at endanglen=ATN(hitd/(2*PI*crad*angd/360))

These algorithms for calculatingthe Radius and sweep angle arein the Maths Primer.

This first bit is all you need at first to get the handrailworking. Do the downrights later.

!Handrail Sloping!Round with infil!3D Script

PEN pcol

!Tube locations h=-hitd !height counterFOR k=-angl-angd TO angl+angd+0.2 STEP angd PUT crad*SIN(k),crad*COS(k),h,0 h=h+hitdNEXT k

!Draw the handrailRADIUS trad*0.7,trad*1.4ADDy -(crad-B)MATERIAL matlBODY -1TUBE 2,NSP/4,63, 0,0,901, trad,360,4001, GET(NSP)BODY -1DEL 1

VALUESVALUESVALUESVALUESVALUES 'endstyl' 'Butt cut ends', 'Downward Elbows','Rounded ends'

VALUESVALUESVALUESVALUESVALUES 'infil' 'Infil Panel', 'NO Infil Panel'

As always, use Value Lists to ensurethat your objects are user friendly

This is all it takes to make a lovelystretchy 3D handrail for a spiral

staircase (although it depends onthe master script for the angles and

the 2D script for the hotspots

The infil panel can be glass, or you can applyan alpha channeled wiremesh texture

!Downrights!3D script

IF dnnum THEN ADDy -(crad-B)FOR k=1 TO dnnum ROTz angl-angdw*(k-1) ADD 0,crad, hitdif*(k-1) ROTx 180 CYLIND dnlen,dnrad DEL 3 NEXT kDEL 1ENDIF

Handrail 3DA FOR...NEXT Loop runs through,calculating all the points along thehandrail. Do not forget that for aTUBE, you have a phantom Start andEnd point. Using PUT & GET, it is al-most impossible to get an error. But Istill advise the use of the BODY-1 command, to be sure.

Downrights 3DThe first FOR... NEXT loop was basedon angle, this one is based on number.

Radius is used here instead ofResol because later we are dealingwith elbows and ellips to treat the

handrail ends

THIS handrail is similar to the ‘Long Handrail’ earlier in theCookbook, but this one goes further in that it follows a spiral

staircase and has more sophisticated treatment of the ends andthe infil panel.

Again, you must use TUBE to make the object because ELBOW is toofeeble. As for the previous handrail exercise, you can ‘Swing the Cat!’ Youneed the FOR...NEXT loop and SIN and COS to organise the angular distri-bution of elements, in this case, the points on the handrail, the downrightsof the handrail and the points on the Infil Panel.

Yes, for GDL nutcases, there is the chance to try a COONS object, theinfil panel. By the way, this is a mega useful object, and worth buying theCookbook for on its own! With the long handrail, you had a constant height– in this case, if you know the start and end height, your routine can workout the inbetween heights.

Parameters & Master ScriptFirst establish the basic geometry of the circle. This is to be stretchy, basedon a CHORD of a circle, the width being A and the bulge being B.

Spiral Handrail (Swing the Cat again!)

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 216: Cookbook3_1

2.113

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Handrail!2D ScriptPEN pcolHOTSPOT2 0,0HOTSPOT2 -A/2,0HOTSPOT2 A/2,0HOTSPOT2 0,B!display stretchspot locationCIRCLE2 0,B,diam/6000PROJECT2 3,270,2!DRAW IT!!!DownrightsIF dnnum THEN !downrights ADD2 0,-(crad-B)FOR k=1 TO dnnum ROT2 angl-angdw*(k-1) ADD2 0,crad HOTSPOT2 0,0 CIRCLE2 0,0,dnrad DEL 2 NEXT k DEL 1 ELSE !stretchspots CIRCLE2 A/2,0,diam/6000 CIRCLE2 -A/2,0,diam/6000 ENDIF

!Glass locations for COONS infilIF infil='Infil Panel' THEN!Points 1 to 2 h=-dropin !height counterPUT crad*SIN(-angl),crad*COS(-angl),-dropinFOR k=-angl+angd TO angl-angd+0.002 STEP angd h=h+hitd PUT crad*SIN(k),crad*COS(k),h NEXT kPUT crad*SIN(angl),crad*COS(angl),zzyzx-dropin!Points 4 to 3 h=-lenin !height counterPUT crad*SIN(-angl),crad*COS(-angl),-leninFOR k=-angl+angd TO angl-angd+0.002 STEP angd h=h+hitd PUT crad*SIN(k),crad*COS(k),h NEXT kPUT crad*SIN(angl),crad*COS(angl),zzyzx-lenin!Points 1 to 4PUT crad*SIN(-angl),crad*COS(-angl),-dropinPUT crad*SIN(-angl),crad*COS(-angl),-lenin!Points 2 to 3PUT crad*SIN(angl),crad*COS(angl),zzyzx-dropinPUT crad*SIN(angl),crad*COS(angl),zzyzx-leninADDy -(crad-B)MATERIAL matinBODY -1COONS 17,2,63, GET(NSP)BODY -1ENDIF

!Handrail Ends 3D ADDy -(crad-B) s=(-1) !'s' is the flag GOSUB 100:!Handrail end ADDz zzyzx s=(+1) GOSUB 100:!Handrail end DEL 2

END:!-------------------------100:!One Handrail end ROTz -s*angl ADDy crad ROTy s*(90-s*anglen) ROTz -180*(s-1)/2GOSUB 110+es DEL 4RETURN

!End Treatments110:CYLIND dimen,trad!Butt-end RETURN

111:CYLIND trad,trad !Elbows ADDz trad ELBOW dimen,90+anglen*s,trad DEL 1 RETURN

112:CYLIND dimen,trad!Rounded ADDz dimen ELLIPS trad,trad DEL 1 RETURN

Handrail Ends 3DThis is an example of using Value Lists and usingflags (in this case ‘s’) to toggle values and angles. Isuggest three methods, as a simple end of the hand-rail results in a very ugly detail where it meets thedownrights.

It’s difficult to write code like this straight off.You get each handrail end working as two rou-tines. So you discover that the difference betweenthe routines is some pluses and minuses here andthere. By using the flag (‘s’) you can toggle the an-gles and rotations and do the both with the sameroutine. These toggling routines are contained inthe Tips & Tricks in the Voyager Maths Primer.

To do one of the three choices for an End-solu-tion, the flag ‘es’ is used to decide which subrou-tine to run.

2D Script As the object is stretchy, place the hotspots FIRSTin the script. Use PROJECT2 (although a 2D scriptwith ARC2 could be written if you have time). Thedownrights need hotspots, and if there are nodownrights, you need little circles to help the userfind the stretching points.

Additional Parameters for Downrights and Infil Panel

Follow the routine I advocate in the tutorial on COONS(1–>2,4–>3,1–>4,2–>3). Use a similar FOR...NEXTroutine to the one used for the TUBE.

Infil Panel 3D: COONS can makeit! It has the Power! Another method(slightly easier) would be bPRiSM_,but you need care in calculating andlocating it.

FOR k=1 TO dnnumADD2 crad*SIN(angl-angdw*(k-1)), crad*COS(angl-angdw*(k-1)) HOTSPOT2 0,0 CIRCLE2 0,0,dnrad DEL 1 NEXT k

Due to a bug in ArchiCAD6.5 and 7.0’s DWG exporttranslation it’s best toavoid ROT2 in 2D scripts.The use of Trig (as here)replaces the need forROT2. The right handroutine is the correctedversion, the left is easier tothink out and write.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 217: Cookbook3_1

2.114

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Curved Windows– the hidden secretsCURVED windows are difficult enough to make in

real life, but they are also difficult in ArchiCAD!The GDL reference manuals contains an examplewhich defies explanation. Let’s look at the hidden se-crets of curved windows and work out simple formu-lae for solving them.

The fundamental rules for curved windows (anddoors) are here, and once you know that, you can workout many of the essential parameters for building awindow. There is still some trigonometry and geom-etry to do.

The best tool for window making is bPRISM_ be-cause you can lay out a window just as you might layout a straight wall window, and the radius is known toyou. You need to do some acrobatics to get round thefact that the origin is not on the face of the window,but at the midpoint of the chord.

Rules for Curved Windows/Doors• The dimension A is not in the curve of the wall, it’s in thelength of chord that joins the edges of the reveal in the‘hotline’ of the wall.• The Origin of the window is at the centre of the window,but not where you would expect – at the centre on theperimeter. It’s at the midpoint of the chord between thereveal edges on the ‘hotline’ of the wall.• The Global Variable called WIDO_ORIG_DIST (also knownas R_) is not the radius of the wall, as you would expect,but the distance from the centre of the Wall to the Origin ofthe Window.• Thankfully, B is unchanged – it is the height of the wall.• The actual radius of the wall can be found with a Py-thagoras calculation using the half chord width and the glo-bal variable R_.• The Sweep angle of the window can be found becausethere is a right angle triangle in the diagram – it is ArcTanof the half chord divided by the R_ global variable.• The edges of the curved window, not the centre of thewindow, are required to be level with the origin.

!Curved window experiment!Curved window experiment!Curved window experiment!Curved window experiment!Curved window experiment!3D Script!3D Script!3D Script!3D Script!3D Script

r1=ABS(R_) !make it positiveIF r1<fdep THEN r1=1 !make it work when not in planang=ATN((A/2)/r1) !half angle subtendedwrad=SQR((A/2)^2+r1^2) !Actual Wall radiusA2=2*PI*wrad*ang/360 !Actual width of windowbulg=wrad-r1 !bulge of window beyond chord!print ang,R_,A2,A !Test

ParametersEnter these first, so that you will not get an error whenyou test your script. Then in the 3D script or the Mas-ter Script, you must do some calculations for param-eters which are not in the box.

• Depending which way round the wall is, the globalR_ is often a negative quantity. Make it positive withthe ABS function.

• Give R_ a temporary value while you built the ob-ject. If R_ is smaller than the frame depth, let it equal 1metre. In the GDL environment, R_ is zero and it im-possible to run your script as you will get ‘divide byzero’ errors.

• ‘ang’ is the sweep angle of half the window. This iseasily derived using ArcTan of the two sides withknown values.

• Wall radius ‘wrad’ is easily calculated using Pythago-ras.

• The half width of the window ‘A2’ measured alongthe perimeter can be calculated from the radius andsweep angle.

• When you build the window, you need to sink itbelow the ground plane so that the outer edges arelevel with the origin – so you need to know the ‘bulg’of the window – the distance from the centre to thechord connecting the edges.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 218: Cookbook3_1

2.115

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

3D Script – the 4 tricksFirst task is to make a frame, but if you use bPRISM_you get a shape like the top view. The prism curvesdownwards and the origin is at the centre of the win-dow. You need four tricks to make the windowwork out correctly.

• First, you have to lower it by the value of ‘bulg’ – sothat the edgesof the curved frame are level with theXY ground plane.

• Second, you have to use MULz -1 to mirror thecurved frame – so that it curves upwards. This is howit should be to sit in the wall correctly.

• Left like this, the window will project BEYOND theface of the wall. So the third trick is to give the bPRISMa negative thickness value. Amazingly, this works. It isallowed to have negative thickness because if it didn’t,it wouldn’t be possible to make certain objects such asspiral staircases – or curved windows.

• The default curvature of anything in ArchiCAD is36, but this means one polygon for every ten degreesof sweep. This is in fact desperately coarse, and looksvery bad on a bPRISM_. To get any quality of appear-ance, you need to reduce this to at most 5 degrees. ARESOL command of 72 will achieve this.

!continued from previous pageRESOL 72 !Same as wallPEN pcol3 ADDz -bulg MULz -1bPRISM_ fmat,fmat,fmat,5+5,-fdep,wrad,-A2,0,15,-A2,B,15, A2,B,15, A2,0,15,-A2,0,-1,-A2+fwid,fwid,15,-A2+fwid,B-fwid,15, A2-fwid,B-fwid,15, A2-fwid,fwid,15,-A2+fwid,fwid,-1

!SillbPRISM_ fmat,fmat,fmat,5, sdep,wrad,-A2,0,15,-A2,sthk,15, A2,sthk,15, A2,0,15,-A2,0,-1

!GlassADDz -fdep/2bPRISM_ gmat,gmat,gmat,5,-0.01,wrad-fdep/2,-A2+fwid,fwid,15,-A2+fwid,B-fwid,15, A2-fwid,B-fwid,15, A2-fwid,fwid,15,-A2+fwid,fwid,-1

DEL 3

Your first effort – curvingthe wrong way and withthe origin at the centre.

The first effort correctedwith four tricks.

!2D ScriptROT2 180PROJECT2 4,90,1DEL 1

4 tricks – elevate, mirror,negative thickness and

resolution

– A2 is the half width of thewindow measured along its

perimeter. The outline is easyto write. End with a -1.

– The masking values for thebPRISM_ are all 15 because

you want lines at all thecorners.

– The Inline is the same as theOutline, just adding or

subtracting ‘fdep’.– Sill Outline is a copy and

paste of the frame Outline, justchange ‘B’ to ‘sthk’.

– Give the frame a negativethickness and give the sill a

positive thickness.– The XY pointlist for the Glass

is a copy and paste of theframe Inline.

- Although we wish to raise theglass, we are currently in amirrored state thanks to theMULz -1. Therefore we must

lower the glass in order toelevate it.

– Return the cursor to theorigin.

The sill script is easily done. This has a common sur-face with the outside edge of the window frame, so bymaking the thickness positive, and the window framenegative, the window frame grows upwards, and thesill grows downwards.

The Glass is more difficult. You can see from the 2Dscript and from the 2D image (previous page) that theglass doesnt quite meet the frame correctly. In 3D, it issunk into the frame. Some extra trig and analysis wouldbe required to get this to fit exactly. For simplicity, theglass is raised to be half the depth of the window frame.

2D ScriptThis follows the guidelines in previous windows in theGDL Cookbook. The pen colour can be set from theuser settings box. The symbol is best left as a wireframeso that the frame can be seen. This would be most dif-ficult to write in native 2D GDL, but if you are familiarwith Polylines that would help. The example in theGDL manual is written as if the window is viewed fromabove, so it would have to look as difficult as that ex-ample.

Observations – some IFsIf you change the radius of the wall, the windows in ittake some while to realise that the radius has changed.They remain at the previous radius. You may even haveto close the file and re-open it. Even a rebuild fails totell the window of the change.

If you change the window so that it is set within thereveal instead of flush with the wall, it seems to coperemarkably well.

If you wish for details such as opening casementswhich show accurately in plan and in 3D, you will needsome formidable trigonometry to resolve it perfectly.

– We must view the framefrom the direction it would

seen if it was in the plan.That is side view at 90˚,

with the camera rotated.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Text Box
hole
Byzanti
Highlight
Byzanti
Highlight
Page 219: Cookbook3_1

2.116

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

More mysteries to uncoverIf you wish to have straight reveals – as opposed toones that are perpendicular to the tangent of the wall– you have a real problem.

You can insert the WALLHOLE command at the startof the 3D Script, as above. You will get reveals that arein the plane of the centre line of the window. Theseonly work in the 3D window. The plan above is theview in the floor plan, the plan below is the plan in the3D view. Although we use a Project2 in the 2D Script,this does not inform the floorplan manager of thechange of profile in the reveal. The manual confirmsthat you cannot get this to change the floorplan view.You can only do this by cutting a larger hole and thenback filling the window jambs with wedge shaped sidepieces which use global variables to work out the prop-erties of the wall. This would need another article.

Spraying MullionsIf you wish to distribute mullions or small glazing barsin a curved window, you must get them to follow thecurve of the frame, so they cannot simply be placedwith ADD commands. One way is to ‘spray’ them fromthe centre of curvature. Let’s try an example.

First you need to calculate some additional internalparameters. If you are doing a complex object, proto-type these in the 3D script and then move them to apermanent place in the Master script along with theones we wrote earlier. Add one new parameter fornumber of panes, which I have called ‘npan’.

• You need the width of the opening, as measuredalong the perimeter of the window frame.

• From this, you derive the angular width – it’s doneby reciprocating the old formula – perimeter=2piR. Thewindow width is a proportion of the perimeter, so theangle must be the same proportion of 360˚.

• Finally, you need to know the angular separation ofthe glazing bars centres – divide by the no. of panes.

The spray loop: In the routine, use a FOR... NEXTloop based on angle. For each iteration, you start fromthe origin, bounce up to the centre of the circle, rotatearound Y – not to the edge of the frame but to thelocation of the first glazing bar. You then descend tothe window, draw the bar and retreat back to the ori-gin, using DEL. It continues to spray glazing bars untilit reaches the end, but you do not want one at the endframe. So reduce the final angle by one degree to makesure it stops before the frame.

(For this, we made an arbitrary assumption that glaz-ing bars are 1/3 of the width of the main frame.)

Better 2D Symbol for GlassIf you move those calculations to the Master Script,you can get more accurate glass in the 2D. The routinehas to know the value of ‘angpan’ by this time. If youuse 2piR again, you can work out the actual width ofthe glass at the midpoint of the frame, and replace theprevious BPRISM for the glass with this routine.

!Insert into 3D ScriptWALLHOLE 5,0, -A/2,0,15, -A/2,B,15, A/2,B,15, A/2,0,15, -A/2,0,-1

You want parallel reveals?An incorrect Reveal shape is shown infloorplan, even though the WALLHOLE isactive.

Correct Parallel Reveal shape as shown in 3DWireline: but you would need to rethink the jambsand the window frame section itself.

!Add vertical Glazing barsglaswd=(A2-fwid)*2 !Width of Glass along perimeterangpan=glaswd*360/(2*PI*wrad) !Angular width of Glasspanang=angpan/npan !Angular width of each pane

MATERIAL fmatFOR an=-angpan/2+panang TO angpan/2-1 STEP panang ADDz r1 !Use r1, not R_ ROTy an !the loop counter is an angle ADDz -wrad+fdep/3PRISM 5,fdep/3, !One glazing bar -fwid/6,fwid, -fwid/6,B-fwid, fwid/6,B-fwid, fwid/6,fwid, -fwid/6,fwid DEL 3 NEXT an

!Actual Glass widthglass_wid=2*PI*(wrad-fdep/2)*angpan/360!GlassbPRISM_ gmat,gmat,gmat,5,-0.01,wrad-fdep/2,-glass_wid/2,fwid,15,-glass_wid/2,B-fwid,15, glass_wid/2,B-fwid,15, glass_wid/2,fwid,15,-glass_wid/2,fwid,-1

This only works if the routinealready knows ‘angpan’. Somove the glazing barparameter calculations to theMaster script, along with theother calculations.

This will NOT work correctly inGDL, as R_ has a value of zero, so

you should use the value ‘r1’ whichwas derived earlier and has a tokenvalue of 1 metre when in GDL. Thewindow only works correctly when

the window is placed in a wall.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 220: Cookbook3_1

2.117

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Stretchy Edging Tool

!External coving!2D Script

HOTSPOT2 0,0HOTSPOT2 A,0HOTSPOT2 0,-bproHOTSPOT2 A,-bproHOTSPOT2 A/2,0HOTSPOT2 A/2,-bpro

HOTSPOT2 -bpro*TAN(mitr1),-bproHOTSPOT2 A+bpro*TAN(mitr2),-bpro

IF mitr1<>0 OR mitr2<>0 THENPROJECT2 3,270,2 ELSERECT2 0,0,A,-bpro ENDIF

LINE2 -bpro*TAN(mitr1),-bpro, A+bpro*TAN(mitr2),-bpro

THIS OBJECT is almost like a macro – in the sensethat the routine is standardised, and can be used

over an over again. All you have to do is put a differentprofile into the PRISM statement, and whatever you de-fine will become a stretchy cornice/ skirting/ eavespiece/ metal flashing/ cladding panel, or whatever it isintended to be. The mitring routine allows it to followsa wall or roof edge, however angular (except curved).

In terms of GDL, it is interesting in that it uses:• Polylines in the Prism shape• CUTPLANE and CUTEND• PUT and GET as a way of making a PRISM• Trigonometry in 2D scripting

3D ScriptThe mitring could be for an internal or an external cor-ner. To make sure that there is always substance to thePrism, you must make the PRISM its full length, plus atleast twice its depth at each end. Use CUTPLANE tomake it the correct length – even when there is no mi-tre. This will allow pretty extreme angles to be chosenby the user.

2D ScriptIn most things, 2D scripting is useful, but for stretchyobjects, good 2D scripting is vital. Some trig is requiredto make the hotspots land on the corners, however ex-treme the mitring angle. Unless there are many of theseitems, it is acceptable to use PROJECT2 in the 2D script,which saves one some hard work with trigonometry.However, if you need trig to work out the hotspots,you could just as well script the entire 2D object.

!External coving!3D Script

MATERIAL ematPEN pcolRESOL 16

50:!Organise cutplanesROTy -90ROTx -mitr1CUTPLANEDEL 2

ADDx AROTy 90ROTx -mitr2CUTPLANEDEL 3

100:!Make the PrismROTy -90ADDz -A-bpro*2

!Put values for!main Cornice panelPUT 0,0,15, -0.030,-bpro, 15, -0.070,-bpro, 15, -0.070,-0.160,15, -0.075,-0.160,13, -0.120,-0.110,1013, -0.125,-0.100,13, -0.165,-0.066,1015, -0.170,-0.065,15, -0.170,-0.050,15, -0.230,-0.050,15, -0.230,-0.030,15, -sdep, -0.030,15, -sdep, -0.000,15, 0, 0, -1

!Now Do it!PRISM_ NSP/3,A+bpro*4,GET(NSP)DEL 2

!FinishCUTENDCUTEND

END:!-----------------

People who find this doesn’t work haveusually forgotten to DEL after issuing the

Cutplane commands.

Material command must alwayscome BEFORE Cutplane!

This is how to draw the PRISMoutline – in the NEGATIVEquadrant of the X-Y plane.

It may bedifficult forthe user toknow which isthe start andthe end, andwhether mitresshould bepositive ornegativeangles – butthey soon findout by trialand error.

The SectionDepth andProjection giveyou anopportunity tobuild into thePRISMdefinition asmuchparametriccontrol as youwant.

This could be adaptedinto a ‘universal coving

tool’ if you have a folderfull of PRISM-based

coving profiles storedas macros, and just put

a CALL statement inhere instead of the

PRISM statement

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 221: Cookbook3_1

2.118

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Boundary Survey ToolTHIS is a ‘survey assistant’ – you can set up a the-

odolite on a tripod on a site in one place, measuredistances to all corners and some points on the site,note their angle (azimuth) from the instrument. Writethese with a text editor and you can produce atopographically accurate site model.

It is an interesting example of:• File input – reading in from a data text file• Using Arrays• Define Style and Autosizing forms• Using the PUT and GET functions• Loops where only REPEAT... UNTIL will do

Survey Textfile

The user types in the name of the project, followedby a list of the points (in order) of the boundary

using Angle, Distance, Altitude and a flag of 0 forboundary. This is followed by internal points, whichare written the same, with a flag of 1. The file is savedinto ‘ArchiCAD Data folder’.

Master ScriptDoes the whole reading operation and puts the coor-dinates and levels into an array. The flags f[…] tell it ifit’s part of the boundary or internal. This example islimited to 20 points.

OPEN and INPUT are some of the most difficult ofcommands to understand – by writing a statement thatsomehow determines the value of a useless number(‘n’), you discover the value of variables and strings.Read the appendix to the manual on this function, andtry this (‘n’ is the number of items found). ‘n’ is -1 whenthe file end is reached.

To make practical use of ARRAYS you must be pre-pared to use the PUT and GET statements to build anduse the arrays.

Derivation of the x[…] and y[…] values is a piece ofCircle geometry – the X and Y of every point definedby radius and azimuth is found with a SIN and COSstatement.

With AC 6.X, we can use this routine to make a MASScommand. This forms the site with correct levels.

3D ScriptThe MASS command is a delight to use, but you needto learn it. The first points are the boundary points,with a masking code of 15, ending in a -1 (like Prisms).The internal points are all separately listed, endingin -1.

!Boundary Survey Tool!Master Script

DIM angl[20], dist[20], alti[20], x[20], y[20], z[20], f[20]

!titlestr will be titlech1=OPEN("TEXT",fnam,"SEPARATOR=',',MODE=RO")n=INPUT(ch1,1,1,titlestr) !title

!REPEAT Loop – necessary because!FOR NEXT loop cannot be used with INPUT

REPEAT !Fill the array p=p+1 n=INPUT(ch1,1+p,1,ang,dis,alt,flg) angl[p]=ang: dist[p]=dis alti[p]=alt: f[p]=flg UNTIL n<=0CLOSE ch1

pall=p-1 !Number of all PointsFOR k=1 TO pall x[k]=SIN(angl[k])*dist[k] y[k]=COS(angl[k])*dist[k] NEXT k

p=0 !Find how many external & intenal

REPEAT p=p+1 UNTIL f[p]<>0 OR p>=20

pext=p-1 !No of External pointspint=pall-pext !No of Internal points

Arrays have to be ‘declared’ first – here the array isdeclared with the DIM command, and must notexceed 20 numbers. You could increase this number.

When you open a file, you have to define the channel(‘ch1’), and the characteristics (mode, separator etc)that GDL will expect to find.

!Survey Tool – 3D ScriptPEN L_ !uses variablesMATERIAL M_ !in settings box

!Draw the SiteFOR k=1 TO pext-1 !External PUT x[k],y[k],alti[k],15 NEXT k

PUT x[1],y[1],alti[1],-1

FOR k=pext+1 TO pall !Internal PUT x[k],y[k],alti[k],-1 NEXT k

BODY -1MASS M_,M_,M_, pext,pint,16+64*slin,0, GET(NSP)BODY -1

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 222: Cookbook3_1

2.119

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Survey TextfileYou type in the surveydetails in any text editor,save it as an ascii (text)file and put it into the ‘Ar-chiCAD Data Folder’. Puta title on the first line.Write in the order: Azi-muth, Distance, Altitude,Flag. Use commas toseparate numbers.Boundary points comefirst with a ‘0’ flag, theninterior points follow us-ing the ‘1’ flag

Site survey 10, 12.65, 2.7,0, 30, 10.55, 2.0,0, 80, 21.55, 2.3,0, 128, 10.55, 2.2,0, 196, 14.55, 1.9,0, 210, 9.50, 1.7,0, 245, 10.55, 2.5,0, 285, 8.55, 2.0,0, 325, 6.55, 2.6,0, 360, 6.75, 2.1,0, 0, 0, 3.6, 1, 270, 2.35, 3.6,1,

!Simple Table!3D ScriptRESOL 12MATERIAL 'Whitewash'PEN 1FOR k=1 TO 4 ROTz k*90 ADDx A/2-thk CYLIND hit-thk,thk/2 DEL 2 NEXT kRESOL 24 ADDz hit-thk CYLIND thk,A/2 DEL 1

Storey SensitivityGlobal variables, 2D Scripting, DEFINE• Global Variables, Define Line

O FTEN an object needs to appear on otherstoreys1, such as main beam lines, ventilation

ducts, drainage lines, lighting fittings etc. Here is anexample of Storey Sensitivity, using a simple stretchyround table.

On its own storey, the Global variable S~ (alsoknown as GLOB_CH_STORY_DIST) is zero. On otherstoreys it’s a number e.g. 1 for the storey above, -1 forthe storey below. So it can be displayed on the homestorey in all its glorious detail, and on other storeys itwill show more simply using a linetype of the user’schoosing.

One thing you can introduce here is a ‘CalculatedLine type’. This could be based on a fraction of thecircumference of the table, in this case 1/36 of it – givesyou a consistent line quality regardless of the drawingscale (means the dotted line pattern will be the sameat 1/50 or 1/200 scale). DEFINE LINE_TYPE is a night-mare, but the example here works. AC never draws adotted arc or circle correctly, your line ‘bounces’ backon itself just before it closes the circle.

!Survey Tool – 2D Script

PEN L_DEFINE STYLE "boundy" ft, fh,1,1SET STYLE "boundy"

!Draw the Site PROJECT2 3,270,1

FOR k=1 TO pallHOTSPOT2 x[k],y[k]CIRCLE2 x[k],y[k],A_*fh/2000 IF shol THEN altstr=STR(alti[k],4,2) TEXT2 x[k],y[k],altstr ENDIFNEXT k

2D scriptText always has tobe defined. The siteis drawn withPROJECT2, but thehotspots and detailsare added using thearray. The circlesare autosized to bethe same height asFont, taking note ofthe drawing scaleA_.

1 In UK spelling, ‘stories’ (pl. from story) are what you tell yourchildren at bedtime, and ‘storeys’ are what you call levels in build-ings.

!Simple Object to demonstrate!Storey sensitivity

HOTSPOT2 0,0HOTSPOT2 -A/2,0HOTSPOT2 A/2,0HOTSPOT2 0,-A/2HOTSPOT2 0, A/2

DEFINE LINE_TYPE 'solid' 1,1,1SET LINE_TYPE 'solid'

IF S~=0 THEN !LegsFOR k=1 TO 4 ROT2 k*90 CIRCLE2 A/2-thk,0,thk/2 DEL 1 NEXT kENDIF

IF S~<>0 THENIF calclin THEN circum=PI*A !Circumference DEFINE LINE_TYPE 'tabl_lin' 1/A_, 2, circum/36,circum/36 SET LINE_TYPE ‘tabl_lin’ELSE SET LINE_TYPE lintENDIFENDIF

CIRCLE2 0,0,A/2 !Tabletop

LINE_TYPEsizes are like

Font height indefining style.

The dimensionsin the DEFINEstatement are

the actualsegment length

as drawn byyour plotter,

nothing to dowith the

dimensions ofthe objects they

are drawing.This routine

will guaranteethat the

segments areresized to fityour object.

This dotted circle has 36 segments and gaps, butat the end point, you always get a double segment

Special line types do not work unless ‘Use Object’sown Line Types’ is ticked

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 223: Cookbook3_1

2.120

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Introduction

THE TEXT and DATA GDL add-ons provide developers and users of GDL library parts the ability to

store and retrieve data (parameters, values, text strings)inside or from text files. These text files are independ-ent from ArchiCAD Project files, and can be importedinto or exported from any software with text process-ing capabilities (word processors, spreadsheets,databases....).

This text tries to unveil the little secrets behind theseadd-ons, how they work, when they do not, and toprovide the readers with some basic skills to start us-ing the outstanding possibilities they offer.

This is no replacement for the official documenta-tion issued from Graphisoft, it is rather meant to be acomplement. Before starting the following exercisesmake sure you have access to the ReadMe files in htmlformat, to be found inside the Add-ons folder insideyour main ArchiCAD folder. The basic syntax of thedifferent commands is there and will not be explainedhere. Also check the GDL Reference Guide’s appen-dix on the TEXT add-on.

Possible usesOkay, but what is it for? On one side, these GDL add-ons can be used to exchange data or parameters fromother software into ArchiCAD, via library parts. Forexample, you can build a list of commonly used anno-tations to your drawings, and have a Label object re-trieve the annotations just by typing their reference

TEXT and DATA GDL Add-onsHow to create, read, or write onto a .TXT file from inside GDL.by Laurent Godel (‘gdlguru’)

Startup: Creating a blankText file from inside GDLThe OPEN & CLOSE commandsThe TEXT and DATA GDL add-ons work with chan-nels, that is, each text file to be worked with is a differ-ent channel. Channels are defined by the file name,the opening mode (read-only, write-only, amend), andthe definition of a separator between fields.

Both add-ons operate on the same type of docu-ment, the simplest text files, that can actually be openedby almost any existing software. The difference be-tween the two add-ons relies in how they read/writeinside the files.

The simplest task these add-ons can achieve is thecreation of text files. Upon running through the fol-lowing lines of code, ArchiCAD's GDL compiler willcreate the corresponding text files, identified by the_filename parameters. Using the following commandswill create empty text files. Read ahead on how to fill

Laurent Godel is part of the GDLA and the ArchiCADUniversity team. This ‘mega’ contribution is part of theprocess of widening the GDL Cookbook to be the pri-mary compendium of GDL education.

code, instead of having to type the same note repeat-edly.

Another application of these is the ability to createlists automatically; an object that is repeated many timesacross a project (a piece of furniture, for example) canautomatically store its measures, and this automaticallygenerated list can be opened, processed or printed atany time, without the need for a list calculation, to con-trol the number of this particular furniture piece insidethe project.

the files with the desired contents. In the meantime,try pasting this at the beginning of the 2D script of anew library part.

!********* FILE CREATION- "TEXT"Tfilename="TEXTfile.txt"ch1=OPEN("TEXT",Tfilename,"MODE=WA")CLOSE ch1!********* FILE CREATION- "DATA"Dfilename="DATAfile.txt"ch2=OPEN("DATA",Dfilename,"MODE=WA")CLOSE ch2!********* SYMBOLLINE2 0,0,a,0

Notes:a) Using "MODE=WO" (write only) instead of WA (write af-

ter) will in this case have the same effect, the creation ofthe two text files identified by their names. If the file al-ready exists and WO is used, the file will be cleared of itscontents. Using WA the contents of the file will not beaffected, it will only be created if it does not exist.

b) The CLOSE command is important; always remember toCLOSE any channel after opening/using it.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 224: Cookbook3_1

2.121

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Default Locations – TEXT & DATAAfter pasting the above lines of GDL code, take a lookat the 2D Full view of the object. A line should be drawnhorizontally.

Having done this, minimize ArchiCAD (Choose HideArchiCAD from the application menu in Macintosh),and open your current ArchiCAD folder. The two cor-responding text files can be found, one directly insidethe ArchiCAD folder (default destination for the DATAadd-on), and the other inside a subfolder called Archi-CAD Data Folder (default for the TEXT add-on).

These are the default location of txt files processedby the add-ons. In the difference between both loca-tions lies one of the key differences between the TEXTand DATA add-ons.

In the same way these add-ons default the creationof txt files to these locations, when trying to read filesthey will look into these directories. If they do not findthe desired files and are not instructed to look else-where, an error message will be displayed and all GDLinterpretations will be aborted. The DIALOG optionallows you to interactively point these add-ons to afile on a location other than default. Read ahead.

FULLPATH Option for FixedCustom LocationAdding the FULLPATH keyword instead of DIALOGinside the OPEN command, the add-on will interpretthe file name as a path to an existing directory, makingit possible to use files with a fixed position inside aserver for example. The path syntax is different de-pending on your system.

On Macintosh:!********* FILE CREATION- "TEXT, FULLPATH, MAC"Tfilename="server:projects folder:TEXTfile.txt"ch1=OPEN("TEXT",Tfilename,"MODE=WA, FULLPATH")CLOSE ch1!********* FILE CREATION- "DATA, FULLPATH, MAC"Dfilename="server:projects folder:DATAfile.txt"ch2=OPEN("DATA",Dfilename,"MODE=WA, FULLPATH")CLOSE ch2

On Windows:!********* FILE CREATION- "TEXT,

FULLPATH, WINDOWS"Tfilename="E:\projects folder\Tfile.txt"ch1=OPEN("TEXT",Tfilename,"MODE=WA, FULLPATH")CLOSE ch1!********* FILE CREATION- "DATA, FULLPATH,

WINDOWS"Dfilename="E:\projects folder\DATAfile.txt"ch2=OPEN("DATA",Dfilename,"MODE=WA, FULLPATH")CLOSE ch2

If any connected drive is designed by "E:" or has thename or "server", and a folder called "projects folder"can be found at root level, the files will be created.Otherwise ArchiCAD will give you an error message.It is important, then, that the path to the file be estab-lished very precisely.

DIALOG Option for User DefinedLocationAdding DIALOG to the opening mode inside the OPENcommand will enable you to define a location otherthan the default one. At this time, though, the CREA-TION of text files through the DIALOG option is onlyavailable using the DATA extension:

!********* FILE CREATION- "DATA"Dfilename="DATAfile.txt"ch2=OPEN("DATA",Dfilename,"MODE=WA, DIALOG")CLOSE ch2!********* SYMBOLLINE2 0,0,a,0

Upon reconstructing the 2D full view of the library partArchiCAD will display a dialog with buttons allowingthe user to SEARCH for the file or CREATE it inside thedesired directory/folder.

Trying this method with the TEXT add-on, a dialogwill also appear, but with one single button, allowingyou only to select an existing file. Thus the file cannotbe created directly in a custom position using the TEXTadd-on. Try it:

!********* FILE CREATION- "TEXT"Tfilename="TEXTfile.txt"ch1=OPEN("TEXT",Tfilename,"MODE=WA, DIALOG")CLOSE ch1

When reading files, the DIALOG keyword will workfine both with TEXT and DATA add-ons. It just will notallow you to create a new file with the TEXT add-on,in a different location than the default one (ArchiCADData Folder).

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 225: Cookbook3_1

2.122

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Reading inside a FileCreating a sample text fileHow these add-ons read into .txt files is easy to under-stand and to implement inside a GDL object. Writingto a file is a somehow more complex operation andwill be examined further on.

Using WordPad or DeskEdit in Windows orSimpleText on Mac create a text file with the followingcontents, simulating a sheet list for a small project:

A01 Ground Floor 1:50A02 First Floor 1:50A03 Roofs 1:50A04 Section A 1:20A05 Section B 1:20

Use TABS to separate values on the same line. This filewill be interpreted as a database, that is, each line orrow will be considered as a RECORD, and each valuebetween TABS will be considered a FIELD.

Tabulators are the standard field separators used bythe GDL add-ons. They are also the separators othersoftware like Excel or FileMaker use when they exportspreadsheets or databases to text format. However, theGDL add-ons can be instructed to look for other char-acters (such as commas) as field separators, but herewe will stick to the standard.

Save the file as SHEETS.TXT anywhere on yourdrives. If you are using any other software than thosementioned above make sure you export or save as tab-separated text (like if you are exporting from Excel).

Importing all contents of the file(TEXT add-on)The following GDL lines, pasted inside a 2D script of alibrary part, will produce a 2D symbol displaying thetotality of the SHEETS.TXT file, using the TEXT add-on.!********* DISPLAY ALL CONTENTSch=OPEN("TEXT",”SHEETS.TXT”,"MODE=RO, DIALOG")

linecont=1nr=INPUT(ch,linecont,1,sheetnum,

sheetname, sheetscale)WHILE nr>-1 DO

text2 0,0,sheetnumtext2 1,0,sheetnametext2 2,0,sheetscaleadd2 0, -6*A_/1000linecont=linecont+1nr=INPUT(ch,linecont,1,sheetnum,

sheetname, sheetscale)ENDWHILE

CLOSE ch

Note: If your 2D symbol does not display correctly setthe drawing scale to 1:20.

Explanation: Each INPUT line reads inside the rowdefined by the linecont parameter, starting on the firstcolumn (first value), a series of three values identifiedby parameter names sheetnum, sheetname andsheetscale.

After processing the input line, the nr parameterholds the number of read parameters, usually 3, but -1in the case of the end of the file. So using the WHILE/ENDWHILE routine we instruct the part to load as manyrows as it can find inside the text file. Try adding rowsto the text file, save it overriding the original one, andreconstruct the 2D symbol of your Library part. It willautomatically display all the existing rows.

So why not try this technique on the number of col-umns? Why take the trouble to write three parameternames, when in theory we could be using a WHILE/ENDWHILE routine to read all the existing fields in-side a record (or row)?. Try this:

!********* DISPLAY ALL CONTENTSch=OPEN("TEXT",”SHEETS.TXT”,"MODE=RO, DIALOG")

linecont=1fieldcont=1nr=INPUT(ch,linecont,fieldcont,value)WHILE nr>-1 DO

WHILE nr>0 DOtext2 fieldcont,0,valuefieldcont=fieldcont+1

nr=INPUT(ch,linecont,fieldcont,value)ENDWHILEadd2 0, -6*A_/1000linecont=Linecont+1fieldcont=1nr=INPUT(ch,linecont,fieldcont,value)

ENDWHILECLOSE ch

This method works for all but the last record of thetext file. Unexpectedly, the nr parameter receives -1(end of file) two fields earlier than should be. So thismethod is uneffective; you can get an object to importall the rows of a text file no matter how large it is, how-ever you must have an idea of how many columns thereare, for automatic cumulative column input does notwork.

Our first method can be made better by first import-ing all the file’s contents inside a parameter array, thendisplaying it. This is structured programming, usefulfor debugging and handy if you need to process dataafter reading it:

!********* IMPORT ALL CONTENTS! INTO ARRAYDIM tab[50][3]!maximum 50 rows per 3 columnsch=OPEN("TEXT",”SHEETS.TXT”,"MODE=RO, DIALOG")

linecont=1

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 226: Cookbook3_1

2.123

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

nr=INPUT(ch,linecont,1,val1, val2, val3)WHILE nr>-1 AND linecont<49 DO

tab[linecont][1]=val1tab[linecont][2]=val2tab[linecont][3]=val3linecont=Linecont+1nr=INPUT(ch,linecont,1,val1, val2, val3)

ENDWHILECLOSE chlinecont=linecont-1

!********* DISPLAY ALL CONTENTSFOR cntline=1 TO linecont

text2 0,0,tab[cntline][1]text2 1,0,tab[cntline][2]text2 2,0,tab[cntline][3]add2 0,-6*A_/1000

Next cntline

The only drawback of this is that the maximum numberof rows to be inputted is limited by the dimension ofthe tab parameter array. We will then have to makesure we give this array a sufficient number of rows.

Reading Only One Record(DATA add-on)To the opposite of the TEXT GDL add-on, the DATAadd-on is aimed at browsing a file’s content searchingfor a specific field. The syntax is similar to the one usedin the previous exercise, but the results are different:

!********* RECORD SEARCH (DATA ADD-ON)ch=OPEN("DATA",”SHEETS.TXT”,"MODE=RO, DIALOG") searchfield="A03" nr=INPUT(ch,searchfield,1, sheetname, sheetscale) text2 0,0,searchfield text2 1,0,sheetname text2 2,0,sheetscaleCLOSE ch

In this case the add-on internally reads all the file’s

Writing inside Text FilesThis might be the most interesting feature of these add-ons. The OUTPUT command allows a GDL script tostore inside a specified text file any value of any kind,text or number.

Writing with the TEXT add-onAgain, the TEXT and DATA add-ons will behave dif-ferently while doing output commands. We will startwith the simplest, the TEXT add-on. Open a fresh newlibrary part (object), and inside the 2D Script of thepart paste the following lines:

!********* REQUEST CURRENT TIMEdstr = ""ch = OPEN ("DateTime", "", "%m/%d/%Y, %X")n = INPUT (ch, "", "", dstr)CLOSE (ch)text2 0,0,dstr

!********* REQUEST CURRENT PROJECT FILE NAMEname=""nomplan=REQUEST("Name_of_plan","",name)

!********* OUTPUT TO LOG FILEchOUT=OPEN("TEXT","filelog.TXT","MODE=WA")

OUTPUT chOUT,1,1,name,dstrCLOSE chOUT

contents and gives back the found values for sheetnameand sheetscale based on the searchfield parameter.

This is useful if you want your titleblock to read thesheet definition parameters automatically from apredefined sheet list. Just make the searchfield param-eter accessible from the Object Settings dialog box,allowing the user to search for any key value, and thescript will do the rest.

Make the searchfield parameter accessible from theObject Settings dialog box

Save this object as “filelog.GSM” and insert it on yourfloor plan. The 2D symbol should display the date andtime as set inside your computer’s system settings.

Please note that the time displayed inside the 2Dsymbol of the filelog object does NOT change whenyou choose the Display/Rebuild command on yourfloor plan. It does though when you press ALT andchoose this last command, that is then called Rebuild& Regenerate. In the same way, the output commandwill only be effective when you rebuild and regener-ate your floor plan, or change its scale, or switch floors,or simply when you open your project file.

By inserting the filelog library part on your floor planthe filelog.TXT file has been created by the TEXTarchicad add-on inside the ArchiCAD Data Folder. Tosee its contents you can either build a little file-readinglibrary part using the previous chapter of this docu-

ment, or open the file using a simple texteditor (Wordpad for Windows orSimpleText for Mac users).

Now you can laugh at me for working solate... Apart from this, you should see that,for each rebuild & regenerate of anArchiCAD project file with the filelog.GSMlibrary part inserted on it, a line has beenadded to this text file, actually creating a

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 227: Cookbook3_1

2.124

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

log allowing you to control the time you spent on eachproject. If you insert this part on your office templates,then you will be able to control exactly what file wasopened, and when; just look into each computer’s Ar-chiCAD Data Folder for the filelog.TXT file.

In the above script we used the Write After (WA)instruction upon opening the channel, thus. If wechange this WA to WO (Write Only), at each time werebuild & regenerate the floor plan, the contents of thetext file will be erased and a single entry will be writ-ten, containing the current project file name, date andtime.

Writing with the DATA add-onWhen writing into files the DATA add-on does basi-cally the same as when it is reading values. It is in-structed to search for a specific record; if it finds it in-side the text file it just amends it with the desired val-ues. If it does not find the specific record it will justcreate it.

Let’s build a filelog similar to the one above but us-ing the DATA extension. The pursued result is that, in-stead of blindly adding new lines to our text file, ourfilelog library part will just write one line for each Ar-chiCAD project file opened, storing the last modifica-tion date and time.

!********* REQUEST CURRENT TIME dstr = "" ch = OPEN("DateTime", "", "%m/%d/%Y, %X")

n = INPUT (ch, "", "", dstr)CLOSE (ch)TEXT2 0,0,dstr

!********* REQUEST CURRENT PROJECT FILE NAMEname=""nomplan=REQUEST("Name_of_plan","",name)

!********* OUTPUT TO LOG FILEchOUT=OPEN("DATA","filelog.TXT","MODE=WA")

searchfield=name!look for current project nameOUTPUT chOUT,name,1,dstr

CLOSE chOUT

This time open the filelog.TXT file located directly in-side your current ArchiCAD folder, using WordPad orSimpleText or even Excel or FileMaker. The file hasbeen placed here because this is the default locationfor files created using the DATA add-on.

What you get is a tidy log file, with one record ofdata for each ArchiCAD project file that you open (aslong as the library part containing the above script isinserted inside the project file). No matter how manytimes you rebuild & regenerate your floor plan, onlyone line will be displayed for each project. The dataand time get updated each time you do.

For each rebuild & regenerate of an ArchiCAD project file, aline has been added to this file, creating a log allowing youto control the time you spent on each project.

What you get is a tidy log file, with one recordof data for each ArchiCAD project file that youopen

Tips and TricksBeams are groovy!

ArchiCAD 6.5’s Beamtool is notable for itscutting ability. To make the object here in the

foreground, place some beams in your slab, save theresult as an Object, open the Object, and delete theBEAMs from the 3D script. This works on Walls too.Beams generate a CUTPOLY command in the 3Dscript.

It doesn’t work on Roofs, but it will if you openthe Object, delete the BEAMs, and move the CUTENDcommands to the end of the script.

Amend the 2D script to a PROJECT2.

This would takea lot of thoughtto build innative GDL, and60 secs to buildby this method

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 228: Cookbook3_1

2.125

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Multiple outputsThe filelog.gsm is a handy library part you can startusing immediately that will store inside the text filesome useful information about the ArchiCAD projectsthat you open during the day. For it to be effective youonly need to place one instance of the object insideeach project file, provided you set the part to be dis-played on all stories and it is placed on the ArchiCADLayer (always visible).

Another application of storing parameters inside atext file is the automatic management of simple objectschedules without having to calculate lists usingArchiCAD’s calculate menu. We will now build a sim-ple rectangular symbol that will store its position andmeasures inside a text file.

The most important issue here is how to control thateach instance of our library part stores only one recordof its position and measures. Using the TEXT add-onthis seems impossible, meanwhile the DATA add-onwill certainly do the job. But first we have to find onesingle and unique identifier for each instance of thelibrary part, so as to direct the DATA add-on to thecorrect record and avoid duplicate entries inside ourparameter text file.

The ideal identifier is called Global Internal ID,GLOB_INTID is the name of this global parameter. Thisidentifier is one single and unique number internallyassigned to every construction element inside the Ar-chiCAD project. It is actually the entry number of theelement inside ArchiCAD’s internal database. The fol-lowing 2D script accomplishes the drawing of a rec-tangle using the A and B dimensions, and the storageof each instance of this object’s parameters inside atext file called ‘rectpar.TXT’ that will be created insideyour current ArchiCAD folder.

!********* 2D SCRIPT searchfield="#"+STR(GLOB_INTID,1,0) !internal unique identifier

!********* Draw rectangle RECT2 -a/2, -b/2, a/2, b/2 HOTSPOT2 0,0 HOTSPOT2 -a/2,b/2 HOTSPOT2 a/2,b/2 HOTSPOT2 -a/2,-b/2 HOTSPOT2 a/2,-b/2 TEXT2 -a/2,b/2,GLOB_INTID !displays internal unique identifier

!********* OUTPUT TO LOG FILE IF GLOB_CONTEXT = 2 THEN

chOUT=OPEN("DATA","rectpar.TXT","MODE=WA")OUTPUT chOUT,searchfield,1,SYMB_POS_X,

SYMB_POS_Y,A,BCLOSE chOUT

ENDIF

Save this library part as SpecialRect.GSM inside youractive libraries and insert a few instances of it on yourfloor plan, using different positions and measures (thenumbers displayed may vary but should be unique):

Minimize ArchiCAD and take a look at the rectpar.TXTfile that was created inside your current ArchiCADfolder :

Back into ArchiCAD, change the measures of some ofthe rectangles, then check the text file again and seehow the values were updated.

Note: Using a combination of any text type parameter‘# in this case’ and the STR result of the GLOB_INTIDparameter is safer than just using the identifier as anumber. For some strange reason, the DATA add-onwill sometimes write a new record even if the corre-sponding record exists, when only the GLOB_INTIDis used as search field.

GSM file namingOne of the new professional standards is that GDL objectfilenames should include an indication of the GDL ver-sion – 60 for 6.0 and 65 for 6.5. It should avoid confusionwith generic objects and with older objects. So the WCfeatured in the article about DXF conversion might besaved as AS_WC_601_65.GSM, using underscore as sepa-rators. If you are still using 6.0 get into the habit of using6.5 nomenclature (even on Macs).It will improve your library organisation in the long term.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 229: Cookbook3_1

2.126

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Clearing the databaseSo what is the use of this if simple ArchiCAD calcula-tions give the same result without the need for GDLscripting? Well, in this case it is possible to create alittle library part that will inform us ‘live’ of how manyrectangles we have inserted on the floor plan. Inside anew library part, paste the following lines of text, avariant of what was established above of a reading GDLscript:

!******2D SCRIPT!****** INPUT NUMBER OF ROWS INSIDE TXT FILE

ch=OPEN("TEXT",”rectpar.TXT”,"MODE=RO, DIALOG")linecont=1nr=INPUT(ch,linecont,1,val1)WHILE nr>-1 DO

linecont=Linecont+1nr=INPUT(ch,linecont,1,val1)

ENDWHILECLOSE chlinecont=linecont-1

!****DISPLAY NUMBER OF ROWS INSIDE TEXT FILE string=STR(linecont,1,0)+” SPECIALRECT Objects Detected”

TEXT2 0,0,string

Save this object as RectControl.GSM (upon savingArchiCAD will ask you to locate the rectpar.TXT file,as we have instructed the TEXT add-on using theDIALOG keyword), and insert it on the floor plan, nextto the previously inserted rectangles. Does it displaythe right number of rectangles?

So after deleting objects that use the DATA GDL add-on, we need to clear the text file of its contents, thenremaining instances of our parts can store their dataagain and the number of records can become accurateagain.

This can be done in two ways: Hide or minimizeArchiCAD, trash the rectpar.TXT file, go back into Ar-chiCAD and choose rebuild & regenerate. The numberdisplayed by rectControl is accurate again.

Another way, more orthodox GDL speaking, is toadd a parameter to RectControl.GSM, calledCLEARFILE, of type checkbox:

Then paste inside the Parameter Script ofRectControl the following lines, which upon activationof the CLEARFILE checkbox will open the file in WriteOnly mode, thus initializing it. After that the masterscript will turn the CLEARFILE checkbox Off again sothe objects can safely store their parameters again.

!*********MASTER SCRIPT!*********DATABASE CLEANINGIF CLEARFILE THEN

chCLEAR=OPEN("DATA",”rectpar.TXT”,"MODE=WO")CLOSE chCLEARPARAMETERS CLEARFILE=0

ENDIF

The clearfile checkbox will then behave like a button.Save the RectControl part, and back on your floor plandelete a couple of more instances of SpecialRect. Thenselect RectControl, and activate the Erase File Contentscheckbox. It will turn itself OFF automatically and im-mediately. Back on the floor plan, choose Rebuild &Regenerate. The number displayed by RectControl isnow accurate.

ConclusionYou now have the basic skills to build your own GDLand text interactions. Before developing a new appli-cation of these features do a little planning on howyou need the parts to behave and interact betweenthemselves. And keep in mind the golden rules:

Now drag a copy of one of the rectangles. DoesRectControl display the right number of rectanglesnow? No, you need to rebuild & regenerate the floorplan for RectControl to update its data reading insidethe text file again. When the SpecialRect was copied,the new instance did store its parameters inside thetext file. However RectControl had no idea of what wasgoing on and did not feel necessary to reload data fromthe text file. Remember to rebuild & regenerate yourprojects often when you use these GDL add-ons.

In for another surprise? Select a couple of specialrects and delete them from your floor plan. Does theRectControl library part display the right number now,even after rebuild and regenerate? It does not: In thecurrent version of GDL (ArchiCAD 6.5 v3) there is noway to tell an object to delete its record when the ob-ject itself is cleared from the floor plan. Now that’s sad.

1) Use the DATA or TEXT add-on according to what eachof them can do

2) When needed you must be able to clear the contents ofa text file quickly, from within ArchiCAD. Instead ofbeing a checkbox parameter inside an object the filecleaning feature can activate itself upon a certain cir-cumstance inside ArchiCAD (for example, IFGLOB_SCALE=333 THEN....). Very useful and fast!

3) Over a network use the FULLPATH keyword and todefine a complete path to the desired files on a server.This will ensure everybody on the team has access tothe files. Avoid the DIALOG keyword in large groups.

4) When importing records, remember to transfer all datainside a parameter array, leaving the processing for af-ter the input task.

5) As data interchange between GDL and TXT files canbecome slow when files are extensive or a lot of ob-jects try to do it simulateously, it is good to provide theobject with a “Store Parameters” checkbox, so actualexport can be turned on/off any time.

©Laurent Godel, 2000

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 230: Cookbook3_1

2.127

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

THE TEXT and DATA GDL add-ons will in somecase make a confusion between value types when

inputting values from a text file. This makes workingwith dates a difficult task.

The following 2D script uses the TEXT add-on towrite values to a tab-separated text file, then retrievesthem using the same add-on, and displays the inputvalues:!-----------test valuesstring1="10/10/2000" !datestring2="1/50" !scalestring3=" 3*5+8" !formula

!-----------OUTPUT COMMANDch=OPEN("TEXT","test.txt","MODE=WO")

OUTPUT ch,1,1,string1,string2,string3CLOSE ch

!-----------INPUT COMMANDinval1="?"inval2="?"inval3="?"ch=OPEN("TEXT","test.txt","MODE=RO")

nr=INPUT (ch,1,1,inval1,inval2,inval3)CLOSE ch

!-----------DISPLAY READ VALUESTEXT2 0,0, inval1TEXT2 0,-6*A_/1000,inval2TEXT2 0,-12*A_/1000,inval3

The results are surprising.

Although we set up the initial output values as textstrings, the input routine interprets the three of themas formulas, thus displaying their results. The date, “10/

TEXT & DATA GDL Add-onsAppendix – Variable type issues@ Laurent Godel, ‘gdlguru’

10/2000”, returns a numerical value, 0.0005. Eventhough the “invalx” parameters were previously ini-tialized as text.

If we change the first string from “10/10/2000” to“10/10/00” something odd happens. The GDL add-onattempts to calculate the formula, which would resultin an error since it is trying to divide by zero. Sincethere is an error inside the formula, the add-on de-cides to interpret the inval1 input value as a string.

My advice is that when working with dates, scales,or generally text strings that could eventually result inmathematical formulas, it is safe to add a special char-acter before the text when performing an output.OUTPUT ch, 1,1, ”#”+string1, ”#”+string2,”#”+string3

This way a following input script will ALWAYS recog-nize the values as text, and all you need is a little trim-ming in order to retrieve the initial string:

nr=INPUT(ch,1,1,inval1,inval2,inval3)TEXT2 0,0,STRSUB(inval1,2, STRLEN(inval1)-1)

Unless the object you are trying to create is a GDL cal-culator....

Modify EPS line weights>Daniel Vareika, Montevideo: Plotmaker can save ESP (Encapsulate Postscript) files well, but if you forget to set penweights etc first, you cannot bring the EPS back to edit. However, there are many EPS editors:- e.g. Corel Draw, AdobeIllustrator, Macromedia Freehand. Open the file, don’t place or import, just open from the program. Then Select all (com-mand A). Change thickness of all lines. Then you are ready to export it as EPS again.

Faithful old objects no longer so?

EVERY GDL writer has done this... open a old object, realise it could be improved a lot, improve it. It works beau-

tifully. It is superb. Congratulate yourself. Pat on the back.Return to the project plan and do a 3D and the object nolonger draws or renders. Why?

Well, the ArchiCAD project file keeps a database of theparameters of each object in the model. If you open a Li-brary part into GDL, change or add parameter names, changethe purpose of a parameter name from, say, Length to Ma-terial, introduce a Value list or anything significant and thenresave... ArchiCAD will no longer know about these param-eters, no matter how often you open and close the file or tryto set parameter values. There is no alternative. Delete theobject from the plan, and bring it straight in afresh from theLibrary. Perfect!

GDL Toolbox

JUST as we were going to press with the Cookbook 3, thiswas announced: the logical companion/alternative to

ArchiForma. Try it for yourself.From: "Hinsenkamp, Tamas" <[email protected]>GDL Toolbox is now available on both platforms! Downloadand try GDL Toolbox: Mac and Windows Demo versions forFREE. It is available in AddOnStore at www.add-onstore.com

GDL Toolbox now offers you new dimensions in profes-sional interactive GDL modelling. You will also find there theGDL Toolbox Manual, Tutorial files, and project images forfree download. GDL Toolbox is available in English, GermanHungarian. For further product information subscribe to theadd-onstore mailing list by sending a mail [email protected] with the subject SUBSCRIBE.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 231: Cookbook3_1

2.128

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

What are we trying to achieve?

ARCHICAD library parts are outstanding becausethey are parametric: any object can be a small pro-

gram, which calculates a results according to thesedefined variables: its parameters.

However, when many parameters need to be set todefine the result of a script, the task of setting and re-defining each value can become a hard and time-con-suming activity. Let’s see how a determined set of val-ues for an object’s parameters can be saved by the user,and later retrieved without effort to re-establish thecombination required for the desired result.

We’ll build a simple object, called ‘2D RectangularTube’, where the 2D symbol will be governed by fourparameters: Width(A), Height (B), Thickness, Fill type.We’ll see how to save sets like '5x3cm, aluminium fill'or '8x4cm, steel fill' and how to access these sets froma pulldown menu for quick retrieval of the definedcombinations of width, height, thickness and fill.

How can this work?What we need is some kind of database to store thedesired values along with the names of the combina-tions of values. For this purpose we will use aspreadsheet-like text file.

We will need to provide the user with the possibil-ity to STORE parameter sets inside the database, andto RESTORE parameter sets using their assignednames. This last feature will be addressed first, and itcan be split into two sections: Data INPUT and PARAM-ETER SETTING.

Setting up a sample library partCreate a new library part and its parameters names andtypes exactly as in the following illustration.

– A, B, Thickness and Fill type will be the parameterscontrolled by our ‘Save Parameter Sets’ feature.

– The Avsets parameter will receive the pull-down listof available parameter sets.

The two last parameters will allow the user tochoose a name for a combination of settings and toactually store the combination inside the text file usedas a database. We will make the ‘Record’ checkbox actlike a button.

Saving Parameter SetsBy Laurent Godel

Our first task inside the 2D script refers to the thecreation of the desired POLY2_ shape:!--2D script--SET FILL filltADD2 -A/2,-B/2

POLY2_ 10,1+2,0,0,1,A,0,1,A,B,1,0,B,1,0,0,-1,thick,thick,1,A-thick,thick,1,A-thick,B-thick,1,thick,B-thick,1,thick,thick,-1

Check your scripting changing values for A, B, thick-ness and fill type to see if the 2D symbol responds cor-rectly. If it does, save this object as 2D RectangularTube.GSM , inside your loaded, active library.

Setting up a sample parameter fileUsing Excel or a simple text processor we can set up alist of four combination of settings – the first columnreceives the name of the set, the second the width, thethird the height value, the fourth the Thickness value,the fifth gets the Fill Type number.

Save the file using '2D Rectangular Tube_SETS.TXT'as filename, as TAB_SEPARATED TEXT, inside your cur-rent ArchiCAD Data Folder.

Data input from the parameter fileAlthough the DATA GDL I/O Archicad Add-on allowsfor quick record search inside a text database, I rec-ommend the use of the TEXT GDL I/O Add-on, for Ihave found the DATA extension to be unreliable insome cases, and find it safer to use the TEXT one.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 232: Cookbook3_1

2.129

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Array definitionsThrough the TEXT extension, the first task for the li-brary part will be to IMPORT saved settings to makethem available to the users.

We will input the whole contents of the databaseinto two parameter ARRAYs which we have to declareat the beginning of the MASTER script. The first arraywill be a single-column one, called Avn (available setnames).

The second parameter array is called Inpt, thenumber of required columns is 4 (length, width, thick-ness, fill type). The reason behind inputting set namesinside a different array than the assigned values is thatwe are going to use this array directly to define thevalues for the 'Available saved sets' pull-down list. Ineffect, GDL allows us to assign a complete array ofvalues to a parameter by just typing the name of thearray inside the VALUES command.

We will provide the user a maximum of twenty savedsets to choose from, so the beginning of the MASTERscript will bear these instructions:

!---Array definitions and! parameter types (MASTER SCRIPT)DIM Avn[20]DIM inpt[20][4]

FOR i=1 TO 20Avn[i]="....."

NEXT i

Parameter type issuesThe initial definition of the values of Avn as ‘.....’ isrequired in order to provide the user with a readablepull-down menu for available saved sets, in the casethat there are less than 20 saved sets. Through this wealso initialize the Avn array as text type.

Input scriptThe following script lines input the contents of the textfile inside our arrays. The first instruction actually cre-ates the text file if it does not exist. In our case we havepreviously created the parameter file, but if you usethis document to create new objects, it is safer to haveit this way.

!--CREATE THE PARAMETER FILE IF IT! DOES NOT EXIST(MASTER SCRIPT)FILENAME="2D Rectangular tube_SETS.TXT"ch=OPEN("TEXT",filename,"MODE=WA")CLOSE ch

!--INPUT DATA FROM TEXT FILE INTO! ARRAY (MASTER SCRIPT)

ch=OPEN("TEXT",filename,"MODE=RO")linecont=1nr=INPUT(ch,linecont,1,val1,val2,val3,val4,val5)WHILE nr>0 DO

Avn[linecont]=val1inpt[linecont][1]=val2inpt[linecont][2]=val3inpt[linecont][3]=val4inpt[linecont][4]=val5linecont=linecont+1

nr=INPUT(ch,linecont,1,val1,val2,val3,val4,val5)ENDWHILE

CLOSE CHlinecont=linecont-1

We end up with our Avn and Inpt arrays filled with asmany parameters as there are inside the text file. Thelinecont parameter hosts the number of parameter setssuccessfully read.

Defining a value list for available param-eter setsTo assign the Avn array of parameters to the Avsets listof available sets we first need to make sure that bothare the same parameter type, text in this case. So wehave to run a small routine to convert all possible nu-merical Avn values to text. Paste this into your MasterScript, just after the input routine:

!--SET Avn TO TEXT TYPEFOR rep=1 TO linecont

IF VARTYPE(Avn[rep])=1 THENAvn[rep]=STR(Avn[rep],1,0)ENDIF

NEXT rep

Now we will set the Avsets parameter we defined astext type at the beginning of this exercise to displaythe available saved sets names as they were read fromthe database file. Essentially, this means assigning theAvn array of values to the AvSets parameter, and add-ing a default value of 'NONE'. Paste this line inside thepart's Parameter script:

!--Assign Avn values to the Avsets parameterVALUES "Avsets" "NONE", Avn

Run a ‘check script’ to see if everything is OK, andcheck that the 'Restore available sets' parameter nowshows a value list as in the illustration below:

Take a break and have a coffee.

Using the value list to restore parametervaluesNow we need the saved parameters to be restoredwhen the user chooses a settings combination namefrom the pull-down list. We will instruct the parameterscript to restore input values at the moment the Avsetsparameter is changed.

!--Restore values upon set selectionIF GLOB_MODPAR_NAME="AvSets" THEN FOR rep=1 TO linecont

IF Avn[rep]=Avsets THENPARAMETERS A=inpt[rep][1], B=inpt[rep][2], thick=inpt[rep][3], fillt=inpt[rep][4] ENDIF

NEXT repENDIF

Once this is done we need to set the Avsets parameterback to its default value.

PARAMETERS Avsets="NONE"

Click on the parameters tab to the left of the Editordialog, and check now that, when you choose a namefrom the ‘Restore available sets’ pull-down list, the

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 233: Cookbook3_1

2.130

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

parameters’ values are automatically changed. Save.And have another sip of that cold coffee...What comesnext is worse than this.

Adding settings to the parameter fileChecking if a set name already exists

The saving of a determined parameter set will dependon two things: First, if the set name already exists, wewill have to warn the user that its values will beoverwritten. To determine if the name exists, this rou-tine is needed inside the Master Script:

!--DETERMINE IF NAME FOR SAVED! PARAMETERS ALREADY EXISTSFOR rep=1 TO linecont

IF Avn[rep]=SetName THENEXISTS=rep

ENDIFNEXT rep

After the interpretation of these lines, if the set namealready exists, the EXISTS parameter will be differentthan 0 and will contain the identifier of the row of ourAvn array where its settings are to be found.

With the next instructions we will determine thevalue of the currline parameter, which will be used asthe row number to which our current settings will beexported. Paste this inside the MASTER script, follow-ing what we previously typed:

!--DETERMINE ROW TO EXPORT! CURRENT PARAMETERSIF EXISTS>0 THEN

currline=EXISTSoutcont=linecont

ELSEIF linecont<20 THEN

outcont=linecont+1currline=linecont+1PEN 4

ELSEoutcont=linecontoutnum=1currline=1

ENDIFENDIF

Two new parameters appear: outcont is the numberof rows or parameter sets to export to the databasefile; outnum is needed when the number of saved setsis already 20 and we need to loose the last set of thelist in order to export our current settings to the firstline of the database file.

OUTPUT commandAll we need now is to paste the following script linesinside the 2D script of our part:

!----EXPORT DATA TO FILEIF record AND GLOB_CONTEXT=5 THEN

IF EXISTS<>0 THEN PRINT "Current set namealready exists- It will be overwritten!!!"

ch=OPEN("TEXT",filename,"MODE=WO")IF linecont=0 THEN

OUTPUT ch,1,1,SetName, A, B, thick, filltPRINT "Settings Added- please uncheck

this box"ELSE

FOR rep=1 TO outcontIF rep=currline THENOUTPUT ch,1,1,SetName, A, B, thick, filltPRINT "Settings Added/modified- please

uncheck this box"

ELSEOUTPUT ch,1,1,Avn[rep-outnum],inpt[rep-outnum][1],inpt[rep-outnum][2],inpt[rep-outnum][3],inpt[rep-outnum][4]

ENDIFNEXT rep

ENDIF CLOSE CH

ENDIF

These lines will perform output only upon activationthe Record checkbox inside the object Settings DialogBox.

Note that there are two conditions: If linecont is 0,this means that no parameter sets were previouslysaved, then the output row is 1 (the first). In the othercase, data export is performed using the previouslydefined outcont and currline parameters.

Where to put the parameter file?In this example, the 2D Rectangular tube_SETS.TXTparameters file is written and read directly from insidethe ArchiCAD Data Folder, which is the default loca-tion for the TEXT GDL Add-on. This means that if yourwork group consists of many workstations connectedto a server, each computer having its own ArchiCADfolder, every user will have access to the sets he or shesaves, individually, unless you merge the contents ofeverybody’s parameter files regularly (that’s messy...).

For every connected user to have access to one sin-gle and unique parameter file for saving and retrievingparameters sets, try defining the file name as a com-plete path. For example, on Mac:

filename=”SERVER:PARAMETER FOLDER:2D Rectangu-lar tube_SETS.TXT”

On Windows:

filename=”E:/PARAMETER FOLDER/2D Rectangulartube_SETS.TXT”

This will work if you have previously created a foldernamed PARAMETER FOLDER on the root level of yourserver, and if your server is actually named “server”(mac) or “E:” (windows), and all the stations access itthrough the same name.

GS recommends using the FULLPATH instructioninside channel opening instructions when the file nameis actually a path:

ch=OPEN("TEXT",filename,"MODE=RO, FULLPATH")

Please note that using the DIALOG keyword insteadof FULLPATH, each user will be prompted to locatethe file inside the server’s directories, therefore mak-ing it unnecessary to set up the filename parameter asa path. But this can lead to confusions, so stick to thepath routine.

Further issuesOur library part stores parameter sets inside a text file,which means ALL instances of the object have accessto one single list of up to 20 sets of values.

If you need EACH instance of an object to store andretrieve its custom parameter sets, then think aboutperforming the same routines not on a text file but ona parameter array that can be used as a database. That

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 234: Cookbook3_1

2.131

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

would mean doing all the work inside the parameterscript. The parameter array has to be physically cre-ated inside the parameters tab of the Object Editor, notdefined with a DIM command inside the Master script.It can be done! More coffee?

©Laurent Godel 2000

Complete Master Script!---Array definitions and parameter typesDIM Avn[20]DIM inpt[20][4]

FOR i=1 TO 20Avn[i]="....."

NEXT i

FILENAME="2D Rectangular tube_SETS.TXT"

!--CREATE THE PARAMETER FILE IF! IT DOES NOT EXISTch=OPEN("TEXT",filename,"MODE=WA")CLOSE ch

!--INPUT DATA FROM TEXT FILE INTO ARRAYch=OPEN("TEXT",filename,"MODE=RO")

linecont=1

nr=INPUT(ch,linecont,1,val1,val2,val3,val4,val5)WHILE nr>0 DO

Avn[linecont]=val1inpt[linecont][1]=val2inpt[linecont][2]=val3inpt[linecont][3]=val4inpt[linecont][4]=val5linecont=linecont+1

nr=INPUT(ch,linecont,1,val1,val2,val3,val4,val5)

ENDWHILECLOSE CHlinecont=linecont-1

!--SET Avn TO TEXT TYPEFOR rep=1 TO linecont

IF VARTYPE(Avn[rep])=1 THENAvn[rep]=STR(Avn[rep],1,0)ENDIF

NEXT rep

!--DETERMINE IF NAME FOR SAVED! PARAMETERS ALREADY EXISTSFOR rep=1 TO linecont

IF Avn[rep]=SetName THENEXISTS=rep

ENDIFNEXT rep

!--DETERMINE ROW TO EXPORT! CURRENT PARAMETERSIF EXISTS>0 THEN

currline=EXISTSoutcont=linecont

ELSEIF linecont<20 THEN

outcont=linecont+1currline=linecont+1PEN 4

ELSEoutcont=linecontoutnum=1currline=1

ENDIFENDIF

Complete 2D Script!--EXPORT DATA TO FILEIF record AND GLOB_CONTEXT=5 THEN

IF EXISTS<>0 THEN PRINT "Current set namealready exists- It will be overwritten!!!"

ch=OPEN("TEXT",filename,"MODE=WO")IF linecont=0 THEN

OUTPUT ch,1,1,SetName, A, B, thick,filltPRINT "Settings Added- please uncheck

this box"

ELSEFOR rep=1 TO outcontIF rep=currline THENOUTPUT ch,1,1,SetName, A, B, thick,filltPRINT "Settings Added/modified- please

uncheck this box"ELSEOUTPUT ch,1,1,Avn[rep-outnum],inpt[rep-outnum][1],inpt[rep-outnum][2],inpt[rep-outnum][3],inpt[rep-outnum][4]

ENDIFNEXT rep

ENDIF CLOSE CHENDIF

!--2D script

SET FILL filltADD2 -A/2,-B/2

POLY2_ 10,1+2,0,0,1,A,0,1,A,B,1,0,B,1,0,0,-1,thick,thick,1,A-thick,thick,1,A-thick,B-thick,1,thick,B-thick,1,thick,thick,-1

Complete Parameter ScriptVALUES "Avsets" "NONE", Avn

IF GLOB_MODPAR_NAME="AvSets" THEN FOR rep=1 TO linecont

IF Avn[rep]=Avsets THENPARAMETERS A=inpt[rep][1] , B=inpt[rep][2], thick=inpt[rep][3], fillt=inpt[rep][4]

ENDIF NEXT repENDIFPARAMETERS Avsets="NONE"

Check your scriptsHere you can find the complete Master, Parameter and 2D scripts for our library part. We have discussedthe necessary steps to provide any library part with the ‘Save Settings’ function – just change parameternames in the INPUT and OUTPUT routines to meet the needs of your library your part.

Byzanti
Highlight
Page 235: Cookbook3_1

2.132

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

This little Zone object calculates theroom’s capacity (of people) and checksthe total width of doors for compliancewith fire escape regulations.by Laurent Godel, ‘gdlguru’

LOOKING into ArchiCAD’s built-in Zone Stamp’sscripts is a somewhat confusing experience. These

objects are very complex. They read from various Glo-bal Variables [GV], sense different unit settings and cre-ate a data table within their symbol.

In concept, Zone Stamps are 2D library parts linkedto a colored polygon, which can be placed on theArchiCAD floor plan using automatic boundary recog-nition. Zones Stamps are powerful in that they haveaccess to features of constructive elements surround-ing them, or even inside their linked polygon. Zonescan also calculate room areas in very complex ways.

In ArchiCAD, under Options/Zone Categories, Cat-egory names and numbers can be defined, as well aswhich zone stamp (of the available inside the loadedlibraries) is to be applied to each zone polygon, ac-cording to its category. This means the user can actu-ally assign custom zone stamps to zone polygons, ifhe creates special stamps for specific uses.

This little exercise creates a simple new Zone Stamp,which we will call Zone Escape.RSM, that will firstcalculate the capacity of the room according to asquare-meter-per-person ratio, adaptable for each zonestamp, but based on standard values depending onZone Category.

In effect, the fire departments’ criteria for calculat-ing the capacity of a given space is usually based onmultiplying the area of this space by a square-meter-per-person ratio, related to the actual use of the space.For example, a nightclub’s capacity is counted on thebasis of 0.5m2 per person (two people fit inside onesquare meter). On the other hand, a restaurant’s ca-pacity will be calculated using a ratio of 2 square me-ters per person.

Make the Zone StampChoose File/New Library Part..., selecting Zone Stampas format. A standard Object Editor appears; note thatall the usual scripts are available, except the 3D scriptwindow. Zones cannot have a 3D script.

ParametersThe parameter list already contains many parameters:These are all the Global Variables assigned to ZoneStamps. Click on the New button to add a new param-eter, which is to be called CapacityRatio, and selectReal Number as parameter type. Assign 1,000 as de-fault value. The first lines of the 2D script will containa routine for calculating the room’s capacity accordingto this ratio and the room area:

!*******capacity calculation calcapacity=ROOM_AREA/CapacityRatio

If the ratio is zero an error will occur. And if it is lessthan zero the calculation can give back a negative ca-pacity, which is not desirable! So the following lineshave to be written inside the Parameter Script, to avoidwarning messages:

!*******Error ControlIf CapacityRatio=0 THEN

PARAMETERS CapacityRatio=1ENDIFIF CapacityRatio<0 THEN

PARAMETERS CapacityRatio=-CapacityRatioENDIF

Bug? PRINT statements do not seem to produce anyresult while working on Zone Stamps. So telling theuser his parameters are incorrect is not possible....

2D ScriptNext step is to check inside the 2D script the overalldoor width of the room, and compare it with the totalwidth needed for the occupants inside the room to es-cape in case of fire. Again, local regulations establishthe number of people that can escape through a one-meter wide door. This is the meaning of the escapefactparameter. The GV holding the overall width of doorsinside walls surrounding the Zone is calledROOM_DOORS_WID (it seems to work even if theZone has not been created using the Automatic Bound-ary Recognition method).

!*******escape calculationescapefact=1/100escapeneed=calcapacity*escapefactIF ROOM_DOORS_WID>=escapeneed THEN

escapestring="Enough door width"ELSE

escapestring="NOT ENOUGH DOOR WIDTH !!!"warnflag=1

ENDIF

Here we use the escapestring parameter so as to putone single TEXT2 instruction further down inside the2D script. warnflag is used for displaying a bold 2Dsymbol if the overall door width is not enough for theroom’s capacity:

!*******text styleDEFINE STYLE "text""Arial",ROOM_LSIZE,1,warnflagSET STYLE "text"

Custom Zone Stamp

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 236: Cookbook3_1

2.133

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

What’s left is only the necessary code to display insidethe stamp the room number, name, area, capacity anddoor width verification. So this is the complete 2D scriptof the new Zone Stamp:

!*******capacity calculationcalcapacity=ROOM_AREA/CapacityRatio

!*******escape calculationescapefact=1/100

IF ROOM_DOORS_WID>=escapeneed THENescapestring="Enough door width"

ELSEescapestring="NOT ENOUGH DOOR WIDTH !!!"warnflag=1

ENDIF

!*******text styleDEFINE STYLE "text" "Arial",

ROOM_LSIZE,1,warnflagSET STYLE "text"

!*******2D symbolstring=ROOM_NUMBERGOSUB 100

string=ROOM_NAMEGOSUB 100

string="Area: "+STR(ROOM_AREA,3,2)GOSUB 100

string="Capacity: "+STR(calcapacity,1,0)+" p."GOSUB 100

string=escapestringGOSUB 100

END:!________________________

100:!*******text typingTEXT2 0,0,StringADD2 0,-2*ROOM_LSIZE*A_/1000RETURN

Set it up for useSave the Stamp. Then, choose Options/Zone catego-ries..., and inside the categories dialog box create yourlist of categories. Assign to each category the new ZoneStamp, from the pull-down list on the left. The field tothe right allows you to assign default values for thestamp’s parameters, according to each category. As-sign to each room usage type the adequate capacityratio, according to your local regulations.

Then click OK and start drawing Zones through asample project file containing some walls and doors.The Zone Stamp informs you when there is insuffi-cient door width to evacuate the number of personsthat can fit inside each room. Please note that you willneed to choose the Update Zones command after add-ing or changing doors, for the Zone Stamp to accu-rately display its calculations results.

End noteToo bad there is no GV giving the number of doors foreach room. This could be useful for further fire escapecalculations. It also seems difficult if not impossible totell ArchiCAD in what direction people are going toevacuate, which is an essential part of fire escape regu-lations. For example, the Fire Officer wouldn’t permityou to let restaurant goers to escape through thekitchen, a hazardous environment, or the toilets, a deadend.

Maybe a door could be scripted in such way that itwould process the capacity of adjacent rooms (see theREQUEST -Zone Relations function), calculates the fluxof people from one room to another, and sums up ca-pacities feeding statistics back to other Zones... It’stime for a new API called FireCad!

©Laurent Godel 2000

The user has a Zone settingbox where they can adjust thenominal capacity of the room

Set it up in Options/Zone categories....

Move them hotspots!It is always better to design your own hotspots than to rely on a default bounding box. With AC 6.5onwards, you can now plant 3D hotspots to make it easier to pick up objects in 3D.In the 3D view, you usually get a cluster of hotspots around the zero XY plane of the object. If youwant the hotspots to appear all at the top of the object, then build the whole thing downwards withthe zero XY plane at the top. You can achieve this effect with something you have built the normalway up by using zzyzx and preceding the 3D script with a MULz -1. The zzyzx hotspot will pointdownwards.

Byzanti
Highlight
Byzanti
Highlight
Page 237: Cookbook3_1

2.134

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Lattices – Winged Truss – 1

THIS is an interesting truss form, which I call a‘winged truss’. It is here to show a way of building

lattices that can done by one subroutine call and re-quires no trigonometry.

This is a valuable learning exercise, including:

• Smart stretchy algorithm (recalculates spacing)

• Uses no trigonometry (done by XYZ locations)

• The 2D script is written in the 3D window (?)

• The members are made with TUBE command :-(

This method is incredibly easy for making lattices,because one subroutine does all the work, you onlyhave to tell it the XYZ locations of each end of a tubeand the job is done. Even better, you get a totally accu-rate 2D image, scripted from within the 3D script!! Allthe 2D script has to supply are hotspots and labels. Inthe Cookbook, I have referred to this as the ‘AngleRod’method, using a simple TUBE from point to point.

!Winged 3D truss!Master Script

tnum=INT(1+A/tlen) !Number of TrussesIF tnum<1 THEN tnum=1twid=B !Width of Trussthit=zzyzx !Height of Truss

!Resolution limitsIF resl<4 THEN resl=4IF resl>12 THEN resl=12

!Drawing in 2D or 3D?IF GLOB_SCRIPT_TYPE=2 THEN draw2d=1IF truvu=1 THEN draw2d=0

Master ScriptGLOB_SCRIPT_TYPE is the key to automatic 2D script-ing. It tells GDL when it’s busy drawing a 2D symbol;if it is then the flag draw2d is set to 1. Subroutine 100does all the work in 3D. Every tube in the 3D can havea matching LINE in 3D also which is performed by sub-routine 101. We can then do a project2 of the truss madewith either tubes or lines.

3D ScriptEstablish the subroutine 100 first, because this is whatdoes all the work. Do one test member, which can bethe lower tube.

Because this truss is, in effect, a load of cylindersthat all collide at node points, you are depending onthe ability of shaded views to ‘z-buffer’ all the cylin-ders where they meet – i.e. to tidy up the junction.Thus the lower tube is improved in appearance by be-ing extended by its own radius in each direction. Theparameters for x1,y1,z1 and x2,y2,z2 and the tube ra-dius are sent to the subroutines. If draw2d is positive,the action will be sent to subroutine 101 where a LIN_command will draw a line instead of a cylinder.

!Winged 3D truss!ReWritten for Cookbook3 Nov 2000

PEN pcol3MATERIAL tmatRESOL resl

!Lower main memberrad=t1diam/2 x1=-rad: y1=0: z1=0 x2=tlen*(tnum-1)+rad y2=0:z2=0GOSUB 100+draw2d

END:!------------------------

100:!Tube!Define Phantom Points x0=x1+(x1-x2) x3=x2-(x1-x2) y0=y1+(y1-y2) y3=y2-(y1-y2) z0=z1+(z1-z2) z3=z2-(z1-z2)

!Draw itTUBE 2,4,63, 0,0,901, rad,360,4001, x0,y0,z0,0, x1,y1,z1,0, x2,y2,z2,0, x3,y3,z3,0RETURN

101:!Tube in 2DLIN_ x1,y1,z1, x2,y2,z2RETURN

This routine works outthe position of

phantom points nomatter how wierd thestart and end points.

It ensure clean buttends to all tubes.

These two lines are thepolylines required todraw a cylinder. Theextra 1 gives you tidy

cylinders. 900 and4000 would give you

a mass of ink lines foreach polygon on the

cylinder – horrid!

Subroutine 101 onlyhappens if PROJECT2

is working

For would-be lattice builders,this is the most useful exercisein the GDL Cookbook.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 238: Cookbook3_1

2.135

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Winged 3D truss!2D Script

HOTSPOT2 0,0HOTSPOT2 A,0HOTSPOT2 tlen*(tnum-1),0HOTSPOT2 tlen*(tnum)-tlen/2,0HOTSPOT2 -tlen/2,0

!Put Hotspots on each truss elementFOR n=1 TO tnum HOTSPOT2 tlen*(n-1),0 HOTSPOT2 tlen*(n-1), twid/2 HOTSPOT2 tlen*(n-1),-twid/2NEXT n

!Crosshair on stretchy pointp=-t1diam/2 LINE2 -p,0,p,0 LINE2 0,-p,0,p LINE2 A-p,0,A+p,0 LINE2 A,-p,A,p

PROJECT2 3,270,2

IF shownam THEN !Annotationfntz=2*t1diam*1000/A_ !AutosizeDEFINE STYLE 'ttxt' 'Arial',fntz,1,0SET STYLE 'ttxt' TEXT2 0,-t1diam,idenENDIF

!Winged 3D truss!ReWritten for Cookbook3 Nov 2000

PEN pcol3MATERIAL tmatRESOL resl

!Lower main memberrad=t1diam/2 x1=-rad: y1=0: z1=0 x2=tlen*(tnum-1)+rad y2=0:z2=0GOSUB 100+draw2d

!Upper main memberrad=t1diam/2 x1=-tlen/2-rad: y1=0: z1=thit x2=tlen*(tnum-1)+tlen/2+rad y2=0: z2=thitGOSUB 100+draw2d

!Outer long membersrad=t2diam/2 x1=-rad:y1=-twid/2:z1=thit/2 x2=tlen*(tnum-1)+rad y2=-twid/2:z2=thit/2GOSUB 100+draw2d y1=-y1: y2=-y2GOSUB 100+draw2d

!Upper diagonal tubesFOR n=1 TO tnumADDx tlen*(n-1) rad=t3diam/2 x1=-tlen/2: y1=0: z1=thit x2=0: y2=-twid/2: z2=thit/2GOSUB 100+draw2d y2= twid/2GOSUB 100+draw2d x1=tlen/2GOSUB 100+draw2d y2=-twid/2GOSUB 100+draw2dDEL 1NEXT n

!Lower diagonal tubesFOR n=1 TO tnumADDx tlen*(n-1) rad=t4diam/2 x1=0:y1=0:z1=0 x2=0:y2=-twid/2:z2=thit/2GOSUB 100+draw2d y2= twid/2GOSUB 100+draw2dDEL 1NEXT n

!Longitudinal diagonal tubesFOR n=1 TO tnumADDx tlen*(n-1) rad=t5diam/2 x1=0: y1=0: z1=0 x2=-tlen/2: y2=0: z2=thitGOSUB 100+draw2d x2=tlen/2GOSUB 100+draw2dDEL 1NEXT n

END:!--------------------------

!Follow this with the!subroutines 100 and 101

The 2D symbol with a simple level of detail. Eachmember is represented by one line

The 2D symbol with a high level of detail – a truview.The full PROJECT2 is drawn. A detail study in anarchitect’s drawing might need such detail, but anengineer’s layout for a whole roof of trusses wouldprefer the simpler representation and the faster redrawtime.

3D script: continued

The tube structure continues with the upper and thelateral tubes. Then the diagonal tubes are done as aseries of FOR NEXT loops. They could all be done asone single FOR NEXT, but for the Cookbook I havedone each set of tubes separately so you see how thething builds up. All you have to do is to work out therelative x1,y1,z1, and x2,y2,z2 locations for each tubeand you have won!

2D ScriptThe Hotspots are important – this truss is stretchy inlength (and in height in the 3D window). A loop isused to put one on each truss node. There could be anoption to omit this if it is a nuisance with too manyhotspots. The Crosshair assists in finding the stretchy‘A’ hotspot.

This is where the real workhappens. Normally you are

advised to script in 2D insteadof using PROJECT2. We have

done! ...in the 3D script.

B UG! There’s one problem with this 2D<>3Dmethod! due to a bug in 6.x, you get a spinning

beachball over the hotspots, even though the object func-tions correctly. Graphisoft, please fix this for the next issue!

All you have to do issend the values of XYZ

at each end, andradius, and your TUBE

will be built!

Page 239: Cookbook3_1

2.136

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Lattices – Winged Truss – 2

THIS is the ‘winged truss’ again, but done in a quitedifferent way. This is the more traditional

craftsmanlike way to make one, showing a good levelof detail. The truss has cast metal sleeved joints to thetubes which we want to display. This requires the useof Trigonometry, to get all the angles of the tubes pre-cisely calculated.

For manufacturing purposes, this would provide ac-curate feedback – as you stretch the truss, it can calcu-late and report back on the angles of the joints and thelengths of the tubes – this could be a written report foran engineer/fabricator. For general perspective draw-ing, or animation, one would like to shorten the draw-ing time – hence the truss can also be drawn with thejoints concealed.

This is a valuable learning exercise, including:• Using Trigonometry to calculate lattice mem-

bers• Outputting data to file to inform the user of

details and risks• Reading the system clock• Extensive 2D scripting, to save redraw time• Level of Detail awareness• Defining and Autosizing text in 2D symbols

ParametersIf you have already built the previous Winged Truss,note that this has an identical parameter window, ex-cept for the addition of two parameters, simcom andoutdat. So you could open the previous truss, erasethe scripts and resave with a new name to save theeffort of rewriting all the parameters.

The truss has four different radii of tubing. Everylinear element is parametrically definable. A and Bare used to make the truss stretchy. The Master Scriptconverts the A and B into ‘tnum’ and ‘twid’, from whichthe rest of the truss can be drawn.

If you are starting from scratch, leave the optionalparameters at the bottom of the list until you need them.

Master ScriptIf the object is stretchy, make sure that you equate A,B and zzyzx to the parameters names you wish to use.the tnum routine is a way of counteracting the ten-dency of INT(…) to round down. (One could use anew function CEIL(… ) which is like INT but roundsup.)

The next set of calculations use ArcTan and Pythago-ras to work out the angles and lengths of tubing.

!Winged 3D truss!Master Script

tnum=INT(1+A/tlen) !Number of Trusses twid=B !Width of Truss thit=zzyzx !Height of TrussIF tnum<1 THEN tnum=1

!Longitudinal Diagonal Tubing dtang=ATN(thit/(tlen/2)) dlen =SQR(thit**2+(tlen/2)**2)

!Upper Wing tubing ang1=ATN(tlen/twid) ang2=ATN((thit/2)/((tlen/2)/SIN(ang1))) utlen=(thit/2)/SIN(ang2)

!Lower Wing Tubing ltang=ATN(thit/twid) ltlen=SQR(thit*thit+twid*twid)/2

IF resl<4 THEN resl=4IF resl>12 THEN resl=12

In some versions of ArchiCAD 6.5, the presence oftrigonometry functions in the Master script causes Stretchyobjects to have a spurious ‘divide by zero’ error – move theroutine to the 3D and 2D scripts.

3D ScriptThe housekeeping (like the angle and length of diago-nal tubes) are all dealt with in the Master script. The3D script can be dedicated to 3D. As this is a complexobject, set out to structure the script, so put in the END

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 240: Cookbook3_1

2.137

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

statement early.

The Lower and Upper and outer tube members (300:and 310:) are easy enough to do. Manoevre into posi-tion, rotate to point Z along the line of the truss andpush out your cylinders. If the user has opted for thecomplex truss, then run the FOR NEXT loops that aresleeves for the joints. Because the sleeves are biggerthan the tube, and have to accept diagonal tubes later,they are longer then their diameter. You need to makesmall adjustments in position to make the sit nicely.

The sleeves sit nicely along the rods. The ones inthe middle are the right length because they have toaccept a total of 8 tubes arriving into them at differentangles. The end tubes overhang too much, so aCUTPLANE routine is required to reduce the size ofthe end joints. Insert the CUTPLANE routine before you

start with the 3D elements, to trim off thesleeve ends correctly. Add CUTEND:

CUTEND just before the ENDstatement

Tips and TricksBuilding Lattices

WE CAN easily make non parametric latticeswith the slab tool, laying out the shape, and

then inserting holes, and finishing up with rectan-gular sectioned members. But if you stretch them,the sizes of all the members are distorted. Makinga serious 3D truss this way is almost out of thequestion.

Home built Parametric Lattice trusses are oneway to impress people who think that everythingshould be done with AutoCAD. Challenge them tomatch that with AutoLisp! Here are four methodsto think about.

The Prism method: A lattice can be made as aPRISM_ with holes drilled. You can use arithmeticto work out how many holes to draw, PUT to storethe outlines of the holes, and GET to draw the prism.You could also make the web of a castellated beamthis way. This is somewhat limited to 2D trusses.

The Trigonometry and Loopmethod: Using the technique ofthe Lattice truss in the Discoverycourse, you can use arithmetic towork out how many lattice mod-ules required (or to calculate themodule size); then use a For NextLoop. The cursor runs along thelength of the truss, building eachmodule.

Along the way, you will have touse trigonometry to work out theangles of the truss members, andeither Cylinder, or a Squilinder(prism) to draw the members. (I callthis ‘knitting’). This needs someserious maths if the truss is curvedor irregular in shape. (WingedTruss-2)

The ‘AngleRod’ method: isuseful if the truss departs fromregular spacings or layout, andhas members in which there areso many angles and geometriesthat the trigonometry gives youa headache. (I like trig, but youmay not). In this case, you just usea macro like AngleRod in the Voy-ager course. You just specify thestart and end points, the sectionaldiameter, and whether the rod issquare or round. You do not ac-tually need to call Anglerod, be-cause the routine using TUBE isso short, it can be copied andpasted as a subroutine into yourmain script. (Winged Truss-1).

CUTPOLY method: First build your lattice as a solid block; then applya series of CUTPOLYs to drill holes, leaving behind the structural mem-bers. This is a laborious method for a 2D lattice, but for a 3D lattice, itcould be the easiest! Use Loops and PUT and GET to place them.

!Winged 3D truss: 3D ScriptPEN pcol3MATERIAL tmatRESOL resl

GOSUB 300 !Lower TubeGOSUB 310 !Upper Tube

END:!----------------------

300: !Lower Tube sleeves ADDx -t1diam/2 ROTy 90CYLIND tlen*(tnum-1)+t1diam,t1diam/2

IF simcom THEN FOR k=1 TO tnum ADDz tlen*(k-1)-t1diam CYLIND t1diam*3, t1diam/1.5 DEL 1 NEXT k ENDIF DEL 2RETURN

310:!Upper Tube sleeves ADD -tlen/2-t1diam/2,0,thit ROTy 90CYLIND tlen*tnum+t1diam,t1diam/2

IF simcom THEN ADDz -t1diam FOR k=1 TO tnum+1 ADDz tlen*(k-1) CYLIND t1diam*3,t1diam/1.5 DEL 1 NEXT k DEL 1 ENDIF DEL 2RETURN

!Cutplane routines for ends ADDx -tlen/2-t1diam/2 ROTy -90 CUTPLANE DEL 2

ADDx tlen*(tnum-1)+tlen/2+t1diam/2 ROTy 90 CUTPLANE DEL 2

CUTPLANE routine:Insert here

CUTPLANE routine:you need this to trimthe sleeves

The basic Cylinder isthe tube and

the Loop creates thesleeves

These two lattices depend on cylinders meeting ex-actly at nodes. If you need to trim them back for a per-fect wireline view, use the Trig and Loop method, andpush circular CUTPOLYAs along the lines of the maintubes to cut the ends of the minor tubes (not illustratedin this example).

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 241: Cookbook3_1

2.138

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!3D Script, continued

GOSUB 320 !Outer Lateral member MULy -1GOSUB 320 !Outer Lateral member DEL 1

END:!------------------

300:310:320: !Outer Tube ADD -t2diam/2,-twid/2,thit/2 ROTy 90CYLIND tlen*(tnum-1)+t2diam,t2diam/2

IF simcom THEN FOR k=1 TO tnum ADDz -t2diam ADDz tlen*(k-1) CYLIND t2diam*3, t2diam/1.2 DEL 2 NEXT k ENDIFDEL 2RETURN

Lateral tubesThe lateral (or wing) tubes are done in the same way.Do one of them, and then use a mirroring technique,using MULy -1, to do the other. The routine in 320 isdone in exactly the same way as for the main tubes.

DiagonalsThe way to get the diagonals done is to start off bygetting ONE module right, and the rest will be donewith a FOR... NEXT loop.

These diagonals are more complicated. The maintubes were long single tubes, and the sleeves were cyl-inders. In the diagonals, the sleeves are conical, andhave to point in the same direction as the tubes. This isa good illustration of an object oriented approach –one cannot solve the problem in bits and pieces. Onemust get to the right place, summon the tube and itshould arrive as a whole object, complete with itscones.

Passing parametersA standard subroutine (240:) has been developed for aCylinder that has a cone at each end. (This gives theform of the sleeved joints). All you have to do is getthe cursor to the right place, point it in the right direc-tion, pass appropriate parameters to the subroutine,and it’s done. 260 calls 270 to get the cones. the pa-rameters are clen (cylinder length) and diam (diam-eter). The subroutines have built in rules to decide howbig the cones should be.

ROTz 180 - ang1 ROTx 270 + ang2GOSUB 260 !tubeDEL 2+1

ADD 0, twid/2,thit/2 !fourth upper ROTz 180 + ang1 ROTx 270 + ang2GOSUB 260 !tube DEL 2+1RETURN

220:! Do Lower Wing tubes ROTx 90-ltangclen=ltlen:diam=t4diamGOSUB 260: !Cylinder lower tube DEL 1 ROTx -(90-ltang)GOSUB 260: !Cylinder lower tube DEL 1RETURN!-----------------------------------

260: !Cylinder lower tubeIF simcom THEN GOSUB 270 !jointCYLIND clen,diam/2 IF simcom THEN ADDz clen MULz -1 GOSUB 270 !joint DEL 2 ENDIFRETURN

270: !Joint using a ConeCONE diam*2,diam,diam/1.5,90,90RETURN

!All the diagonal tubesFOR k=1 TO tnum ADDx tlen*(k-1) GOSUB 200: !Do Diagonal Tubes GOSUB 210: !Upper Wing tubes GOSUB 220: !Lower Wing tubes DEL 1NEXT k

CUTENDCUTENDEND:!--------------------------

200: !Do Diagonal TubesLET clen=dlen: diam=t2diam ROTy 90-dtangGOSUB 260 !tube DEL 1 ROTy -(90-dtang)GOSUB 260 !tube DEL 1RETURN

210:!Upper wing tubesLET clen=utlen: diam=t3diamADD 0,-twid/2,thit/2 !first upper ROTz ang1 ROTx 270 + ang2GOSUB 260 !tubeDEL 2+1

ADD 0,-twid/2,thit/2 !second upper ROTz -ang1 ROTx 270 + ang2GOSUB 260 !tubeDEL 2+1

ADD 0, twid/2,thit/2 !third upper

These are the end of the cutcommands cutting the end joints

to the correct length

Subroutine 260 does all thework, you just have to pass

parameters to it

Byzanti
Highlight
Byzanti
Text Box
Bottom main tube Lower main tube t1diam
Byzanti
Text Box
Top main tube Upper main tube t1diam
Byzanti
Text Box
Diagonal tube Diagonal Bracing tube t2diam
Page 242: Cookbook3_1

2.139

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Winged TrussThe joints in this truss look good evenat close inspection. Perhaps the conesat the end of each tube could be a bitlonger. From this, one can derive thedesign of cast steel sleeve joints.

One can get the script to write out todisk a list of the data for each tube –see later in this worksheet.

2D ScriptWhether youare to use the Truview (using Project2) ora scripted 2D symbol, you will need Hotspots to pickthe truss up with. You also need to write the stretchyhotspots before you draw the truss.

If the user prefers a scripted view (many secondsfaster especially if you use the one with complex joints),the the script is below. the sequence is similar to the3D in that you do a FOR... NEXT loop for the diago-nals in each module, and then put in the main longitu-dinal tubes. As a rule, 2D scripting is easy if you use asimilar structure as for the 3D (loops etc)

As the truss has a name, it is possible to have it dis-play its name in the 2D symbol, using TEXT2. The sizeof the Text is automatically calculated to be twice thediameter of the main tube.

File Output

You were offered the possibility of outputting todisk a file with the data about the truss. Here it is.

You can now add the final parameters.

First, it is important to know WHICH truss it is, as abuilding project may have several of different lengths.

So we offer the user the chance to name the truss(‘iden’) and at the same time, we offer them the chanceto turn off the feature (‘outdat’) – we don’t want doz-ens of trusses all simultaneously sending the same datato disk. If the user appoints a truss (the "show-truss")to do the work, the others can remain silent.

By the way, the name ‘iden’ will determine the nameof the file. This file will be placed in the ArchiCAD DataFolder. It takes the name of the truss followed by .TXT.

IF outdat THEN GOSUB 500:!File I/O

Add this line to the executive script, just above the ENDstatement.

Make sure that different trusses have different names,or later trusses will overwrite the file written by onethat was processed earlier.

Add ‘outdat’ and ‘shoname’ to the parameters box

!2D Script for Winged Truss

HOTSPOT2 -tlen/2,0 !StretchyHOTSPOT2 A-tlen/2,0 !Hotspots

!Hotspots on each truss elementFOR n=1 to tnum ADD2 tlen*(n-1),0 HOTSPOT2 0,-twid/2 HOTSPOT2 0, twid/2 HOTSPOT2 0,0 DEL 1 NEXT n

IF shownam THEN !Annotationfntz=2*t1diam*1000/A_ !AutosizeDEFINE STYLE 'ttxt' 'Arial',fntz,1,0SET STYLE 'ttxt' TEXT2 0,-t1diam,idenENDIF

IF truvu THEN PROJECT2 3,270,2

ELSE

RECT2 -tlen/2,t1diam/2, tlen*tnum-tlen/2,-t1diam/2FOR n=1 to tnumADD2 tlen*(n-1),0 POLY2 6,1, 0, twid/2, tlen/2,0, 0,-twid/2, -tlen/2,0, 0,twid/2, 0,-twid/2 DEL 1NEXT n

!Lateral tubesRECT2 0, twid/2+t2diam/2, (tnum-1)*tlen, twid/2-t2diam/2RECT2 0, -(twid/2+t2diam/2), (tnum-1)*tlen,-twid/2+t2diam/2ENDIF

This differs from the previousWinged truss in that the 2D

script is fully scripted, notdepending on Project2. As there

is still the mysterious bug withthe project2 solution, it may be

preferable to script it. There is notrigonometry because in the

plan view it’s possible to describelocations using polygon points.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 243: Cookbook3_1

2.140

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

REQUEST results in a number (X) which can be discarded,but as a result of making the request, you obtain the valueof ‘dstr’ and ‘tstr’.

Date and TimeWe want to know the date of the report, in case it wasdifferent from the one we wanted. this, along with thename of the truss will appear in the report.

Date and Time are not in the manual, but they arein a Readme file in your Add-ons folder. In thedate&time script, one uses a REQUEST which investi-gates a resource in ArchiCAD called ‘DateTime’ thatknows the system time and date. The strings using per-cent signs can extract the data.

Actually, the whole time and date can be repre-sented in a single string called ‘%c’, but to show youhow the strings work, I have joined several ones to-gether – %A gives the day of the week; %d the daynumber, &B the month; %Y the year and century(millenium bug proof! ha-ha!); %X gives the time inAM or PM.

The rest of the DateTime strings can be found byreading the ReadMe file in the Add-ons Folder. Thewhole lot are combined into a text string called ‘dstr’.

The ReportFILE INPUT and OUTPUT are covered in the appen-dix to the main GDL manual. If you are a Voyager, it’stime to read that appendix! But then you may feel likereading the Cookbook for light relief.

First, the file must be opened and named, a chan-nel defined, and you must set up the way in which theroutine will separate data.

The OUTPUT commands then follow; each time youremind it which channel you are writing to (in caseyou have more than one file open at once – you couldbe reading from one file, and writing to the other.)

• The report adopts the name put into the ‘iden’ fieldin the parameters box.

• The report has TABs (‘\t’)between fields, so youcould copy and paste this to a spreadsheet – or youcould reformat it so that it could be read in byFilemaker.

• It’s a good idea to have carriage returns to separategroups of data. A report of this kind would be used asa cutting schedule for the tubing and the design of thesteel sleeve joints in the truss.

It is not really on to have it report in detail on struc-tural matters, as you would require to ask the user toenter vastly more data, like Live and Dead loads, K-factors, steel grades, joint characteristics etc. However,a report on slenderness ratio is a good example of pro-viding a warning to the designer. This could also flashup in the 2D symbol.

This report does provide the engineer with essen-tial detail like tube lengths, from which calculationswould be done – how else could those dimensions bederived, except by the engineer having to calculatethem all again?

500:!File Output Routine!Get the Date and Timex=REQUEST("DateTime","%A %d %B %Y",dstr)x=REQUEST("DateTime","%X",tstr)

500:!File Output Routine!Get the Date and Timex=REQUEST("DateTime","%A %d %B %Y",dstr)x=REQUEST("DateTime","%X",tstr)!Write the Report Filech1=OPEN("TEXT",iden+".txt","SEPARATOR='\t',MODE=WO")OUTPUT ch1,1,0,"Winged Truss Data:>",idenOUTPUT ch1,1,0,"Output Date:",dstrOUTPUT ch1,1,0,"Output Time:",tstrOUTPUT ch1,1,0,"Cutting Schedule for Tubes in mm."OUTPUT ch1,1,0," " CLOSE ch1RETURN

OPEN: Channel 1 is opened to allow output to a file, in aWrite Only mode (WO), using tabs (\t) to separate.

OUTPUT: ‘ch1’ tells it where to send, ‘1’ tells it to start anew line (‘0’ appends to the most recent line), the ‘0’ doesnothing. After that, you send the data you would like tohave in the line, enclosing all text in quote marks.

Winged Truss Data:> MainHallOutput Date: Sunday 02 January 2000Output Time: 17:33:04Cutting Schedule for Tubes in mm.

Upper tubes Number : 4 Length : 2100 Diameter: 100

Bottom tubes Number : 3 Length : 2100 Diameter: 100

Diagonal tubes Number : 8 Length : 1594.52 Diameter : 70 Declination: 48.8141

Upper Wing tubes Number : 8 Length : 2168.52 Diameter : 70 Angle in Plan: 30.2564 Declination :16.0625

Lower Wing tubes Number : 4 Length : 1897.37 Diameter : 70 Declination: 18.4349

Upper Tube Sleeves : 5Bottom Tube Sleeves: 4Wing Sleeves LeftH : 4Wing Sleeves RightH: 4

Slenderness RatiosUpper : 1/ 21Lower : 1/ 21Diagonals: 1/ 23UpperWing: 1/ 31LowerWing: 1/ 27

This is the kind of datathat you can get a report

to produce. It is muchneater and moreorganised than a

Components listing fromthe Properties scripting,

but it is more tiresome forpeople to have to ‘dig

around’ in the ArchiCADdata folder for the result.

You should still try to giveobjects some Descriptor

and Components listingin the Property script.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 244: Cookbook3_1

2.141

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

DO not be dismayed by apparent complexity ofthis script. Like everything else, type in the first

few lines, do a 3D view and see if it works by lookingat the Data Folder to see what has landed there. Don’tforget that you must include the CLOSE statement orthe file cannot be read.

As you build up the text, you add in the extra lines.You need to be pretty precise about the format of thereport, so each line is precisely worked out, and ap-propriate labelling text is put in, always enclosed inquote marks. When you have got the above text work-ing, continue, line by line, until you have completed.You do not need to do all of course – by now, youshould have got the idea.

By the way, you notice that it is possible to includealgebraic expressions in the OUTPUT statements, suchas the ones that calculate Slenderness Ratio. It wouldbe possible to express it as a decimal, but you cansee that by playing with the layout, you can get it tolay it out in a more readable form.

In this case, OUTPUT tells it to send, ‘ch1’ tells itwhere to send, ‘1’ tells it to start a new line (‘0’ shouldappend to the most recent line according to themanual), the final ‘0’ does nothing at all. After all that,you send the data you would like to have in the line,carefully enclosing all text material in quote marks.

500:!File Output Routine!Get the Date and Timex=REQUEST("DateTime","%A %d %B %Y",dstr)x=REQUEST("DateTime","%X",tstr)!Write the Report Filech1=OPEN("TEXT",iden+".txt","SEPARATOR='\t',MODE=WO")OUTPUT ch1,1,0,"Winged Truss Data:>",idenOUTPUT ch1,1,0,"Output Date:",dstrOUTPUT ch1,1,0,"Output Time:",tstrOUTPUT ch1,1,0,"Cutting Schedule for Tubes in mm."OUTPUT ch1,1,0," "OUTPUT ch1,1,0,"Upper tubes"OUTPUT ch1,1,0," Number :",tnumOUTPUT ch1,1,0," Length :",tlen*1000OUTPUT ch1,1,0," Diameter:",t1diam*1000OUTPUT ch1,1,0," "OUTPUT ch1,1,0,"Bottom tubes"OUTPUT ch1,1,0," Number :",tnum-1OUTPUT ch1,1,0," Length :",tlen*1000OUTPUT ch1,1,0," Diameter:",t1diam*1000OUTPUT ch1,1,0," "OUTPUT ch1,1,0,"Diagonal tubes"OUTPUT ch1,1,0," Number :",tnum*2OUTPUT ch1,1,0," Length :",dlen*1000OUTPUT ch1,1,0," Diameter :",t2diam*1000OUTPUT ch1,1,0," Declination:",dtangOUTPUT ch1,1,0," "OUTPUT ch1,1,0,"Upper Wing tubes"OUTPUT ch1,1,0," Number :",tnum*2OUTPUT ch1,1,0," Length :",utlen*1000OUTPUT ch1,1,0," Diameter :",t3diam*1000OUTPUT ch1,1,0," Angle in Plan:",ang1OUTPUT ch1,1,0," Declination :",ang2OUTPUT ch1,1,0," "OUTPUT ch1,1,0,"Lower Wing tubes"OUTPUT ch1,1,0," Number :",tnumOUTPUT ch1,1,0," Length :",ltlen*1000OUTPUT ch1,1,0," Diameter :",t4diam*1000OUTPUT ch1,1,0," Declination:",ltangOUTPUT ch1,1,0," "OUTPUT ch1,1,0,"Upper Tube Sleeves :",tnum+1OUTPUT ch1,1,0,"Bottom Tube Sleeves:",tnumOUTPUT ch1,1,0,"Wing Sleeves LeftH :",tnumOUTPUT ch1,1,0,"Wing Sleeves RightH:",tnumOUTPUT ch1,1,0," "OUTPUT ch1,1,0,"Slenderness Ratios"OUTPUT ch1,1,0,"Upper : 1/",(INT(tlen/t1diam+0.5))OUTPUT ch1,1,0,"Lower : 1/",(INT(tlen/t1diam+0.5))OUTPUT ch1,1,0,"Diagonals: 1/",(INT(dlen/t2diam+0.5))OUTPUT ch1,1,0,"UpperWing: 1/",(INT(utlen/t3diam+0.5))OUTPUT ch1,1,0,"LowerWing: 1/",(INT(ltlen/t4diam+0.5)) CLOSE ch1RETURN

SOMETIMES it is just too difficult to set upthe background in ArchiCAD. Do you want to

model the entire town or perhaps use a photo-graph of it as a background and spend hours try-ing to get it to line up with the model? Yes!.... butNo, I havent got the time.

Much easier still is to use a perfectly whitebackground. When you save the render, ArchiCADsaves the background as an Alpha Channel. Theproof is on the left – Photoshop displays the chan-nel perfectly. Save as a PICT or a TIFF with no com-pression. This can be brought into Photoshop andlaid over a photographic background. Make useof the transparency of the alpha channel.

Anti aliasing is good, but for better results forimages with alpha channels/transparency, renderVERY LARGE with NO Anti-aliasing – like 4000pixels wide! Remove backgrounds with 100% pre-cision. Then rescale the image to the size you want.

Tips and TricksDoing it with Alpha Channels : thinkBIG! VERY VERY BIG!

Byzanti
Highlight
Page 245: Cookbook3_1

2.142

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Catamaran

Points are progressively added alongthe hull, along the top and waterline.The more points, the smoother theshape. All the locations are based onproportions of width and length.

COONS 2,2,63,!half float1 0,0,0, !Point 1 0,0,hit, !Point 2

len*0.9,0,0, !Point 4 len,0,hit*1.1, !Point 3

0,0,0, !Point 1 len*0.9,0,0, !Point 4

0,0,hit, !Point 2 len,0,hit*1.1 !Point 3

Stage 2:Three points

along thelength

COONS 2,3,63,!half float2 0,0,0, !Point 1 0,0,hit, !Point 2

len*0.9,0,0, !Point 4 len,0,hit*1.1, !Point 3

0,0,0, !Point 1 0,wid*0.5,0, len*0.9,0,0, !Point 4

0,0,hit, !Point 2 0,wid*0.5,hit, len,0,hit*1.1 !Point 3

COONS 2,4,63,!half float3 0,0,0, !Point 1 0,0,hit, !Point 2

len*0.9,0,0, !Point 4 len,0,hit*1.1, !Point 3

0,0,0, !Point 1 0,wid*0.5,0, len*0.5,wid*0.5,0, len*0.9,0,0, !Point 4

0,0,hit, !Point 2 0,wid*0.5,hit, len*0.50,wid*0.55,hit, len,0,hit*1.1 !Point 3

!Master Script!Master Script!Master Script!Master Script!Master Script

len=A: cwid=B

First, establish len and cwid. Do itin the Masterscript so that both 2Dand 3D scripts will be informed.

Stage 3:Four points

along thelength

Stage 4:Five points

along thelength

THIS CATAMARAN isn’t just here because I like sailing. In fact I have only been on a catamaran once.

Modelling one is a way of coming to terms with personaldeprivation!(:-) The Cat looks at:

• Using the COONS statement

• Progressively encapsulating components intosubroutines

• Using TUBE to form linear elements

• Value Lists and parsing

• Defining Materials

3

4

Planning: OK, The catamaran isnot totally realistic – it’s a simplemodel to teach some GDL tech-niques. The main object of the exer-cise is the contruction of the floatsusing COONS, and the TUBe for therigging.

For the float, you could useRULED, and it would perhaps beeasier; but the forward end of thebow curves upwards – so theCOONS statement is best for a moresculpted 3D problem.

Master Script: will grow as theboat grows, but first you establishthe roles of A & B. Add the rest inlater, when you have written thevalue lists.

Stage 1:Join up the corners

only: in yoursketch, number

each corner

Stage 1:

COONS 2,6,63,!half float5 0,0,0, !Point 1 0,0,hit, !Point 2

len*0.9,0,0, !Point 4 len,0,hit*1.1, !Point 3

0,0,0, !Point 1 0,wid*0.5,0, len*0.5,wid*0.5,0, len*0.7,wid*0.5,0, len*0.8,wid*0.32,0, len*0.9,0,0, !Point 4

0,0,hit, !Point 2 0,wid*0.5,hit, len*0.50,wid*0.55,hit, len*0.70,wid*0.60,hit, len*0.85,wid*0.4,hit*1.05, len,0,hit*1.1 !Point 3

Stage 5:Six pointsalong thelength –finished!

3D Script: The easiest way to starta COONS is to enter the FOUR cor-ners only, first. Number the corners,as in the diagram below. You get arectangle. Then, as in the script here,add in the extra points progressively.Remember to increment the numberin the first line of the COONS, as youadd the extra points.

Although this is to be a catama-ran made of of subroutines, my start-ing technique is to hammer in somebasic code that works. So the earlyscripts here do not even have linenumbers or subroutines. You onlyneed to build half of one float, as youcan mirror this to form one float, andthen duplicate the float to make thesecond float.

Side Elevation of hull,showing rising deck

Page 246: Cookbook3_1

2.143

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Left: The final COONS profile for ahalf float.Above: The same statement,cocooned into a new subroutinenumber 100:.

Convert the 3D form to a whole floatby repeating subroutine 100, and byusing the MULy command for the re-peat.

Both floats now: To get the twofloats balanced equally around thecentre line, you need to offset thefloats – the offset is equal to half thedifference of the total width andfloat width. The routine that makesthe float must itself become a sub-routine (200). So we have two‘nested’ subroutines.

110: The Deck is a COONS that usesthe same coordinates as the upperedge points of the hull shape. Copyand paste. Make sure you still fol-low the procedure of doing thepoints in the order, 1,2~4,3~1,4~2,3.

Next you need to add the cross-beams that join the floats, and thenadd in the mast, boom and sail.

Finished COONS statement with 6points along its length, & a numberallocated to it.

Once the half-float COONS code isworking, convert it to a subroutineby putting in an END statement, andputting a number and a RETURNstatement either side of the COONS.You still only have half a float!

!Catamaran Hull!for Voyager Course

100: !Half a floatMATERIAL fmatPEN pcol

COONS 2,6,63,!half float 0,0,0, !Point 1 0,0,hit, !Point 2

len*0.9,0,0, !Point 4 len,0,hit*1.1, !Point 3

0,0,0, !Point 1 0,wid*0.5,0, len*0.5,wid*0.5,0, len*0.7,wid*0.5,0, len*0.8,wid*0.32,0, len*0.9,0,0, !Point 4

0,0,hit, !Point 2 0,wid*0.5,hit, len*0.50,wid*0.55,hit, len*0.70,wid*0.60,hit, len*0.85,wid*0.4,hit*1.05, len,0,hit*1.1 !Point 3

!Catamaran Hull!for Voyager Course

PEN pcolRESOL 12GOSUB 100 !Half Float

END !------------------

100: !Half of a floatMATERIAL fmatCOONS 2,6,63, !half float 0,0,0, !Point 1 0,0,hit, !Point 2 ........ etc, etc, etc, etc, etc, ........ len,0,hit*1.1 !Point 3RETURN

200: !Entire FloatGOSUB 100 !half float MULy -1GOSUB 100 !half float DEL 1RETURN

!Catamaran Hull!for Voyager Course

!Floats ADDy (cwid-wid)/2GOSUB 200 !Entire Float DEL 1 ADDy -(cwid-wid)/2GOSUB 200 !Entire Float DEL 1END !----------------

100: !Half of a floatMATERIAL fmatCOONS 2,6,63, !half float 0,0,0, !Point 1 0,0,hit, !Point 2 ........ etc, etc, etc, etc, as above ........ len,0,hit*1.1 !Point 3RETURN

200: !Entire FloatGOSUB 100 !half float MULy -1GOSUB 100 !half float DEL 1GOSUB 110 !DeckRETURN

110: !Deck sloping

COONS 2,5,63, 0, wid*0.50,hit, !#1 0,-wid*0.50,hit, !#2

len, 0.0, hit*1.1,!#4 len,-0.001,hit*1.1,!#3

0, wid*0.5,hit, !#1 len*0.50,wid*0.55,hit, len*0.70,wid*0.60,hit, len*0.85,wid*0.4,hit*1.05, len,0.0,hit*1.1, !#4

0,-wid*0.50,hit, !#2 len*0.50,-wid*0.55,hit, len*0.70,-wid*0.60,hit, len*0.85,-wid*0.4,hit*1.05, len,-0.001,hit*1.1 !#3RETURN

200: !Entire FloatGOSUB 100 !half float MULy -1GOSUB 100 !half float DEL 1GOSUB 110 !DeckRETURN

VALUES 'catmode' 'Not Sailing', 'Starboard Tack','Port Tack'

VALUES 'masthit' 'Mast very high','Mast medium high','Mast short'

VALUES 'sailmode' 'Close hauled','Reaching/running'

This is yourValue List in theParameter Script

!Master Scriptlen=A: cwid=B

IF catmode='Starboard Tack' THEN tack=-1IF catmode='Port Tack' THEN tack=+1IF sailmode='Reaching/running' THENtack=tack*2IF masthit='Mast very high' THEN mhit=len*2.0IF masthit='Mast medium high' THENmhit=len*1.8IF masthit='Mast short' THEN mhit=len*1.6mastrad=mhit/150 !Mast Radiusboomlen=len*0.5 !Boom lengthboomrad=boomlen/150

DEFINE MATERIAL 'sailcloth' 2, 1.0,1.0,1.0DEFINE MATERIAL 'rigging' 3, 0.5,0.5,0.5

As you get ready to move onto the Mast and Sailing de-tails, add in the extra parameters, write a Value List in theParameter Script, and then extend the Master script to‘parse’ the value list – this creates flags (‘tack’) and inter-nal parameters (‘mhit’, ‘mastrad’ etc). You can defineMaterials in the Master script.

Now add more detail to theMaster script

Page 247: Cookbook3_1

2.144

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Crossbeams300: The cross beams are PRISMswhich are better than BLOCKs, sinceyou can generate them from the cen-tre line of the boat.

Make each one, and then DEL backto the origin before making the nextone.

Update the executive script to in-clude the subroutine 300.

Mast and Sails400: You advance to the base of themast, and push up a cylinder. Tomake sure the mast has the oval lookof a mast, then you MUL the cylin-der in the X direction.

450: At this point, you provide aparametric choice – the boat couldbe at anchor, or on Port or Starboardtack. It is more manageable to do theboom as a separate subroutine fromthe mast. The boom is angled at 20degrees from the axis. If you havewritten the Value Lists, then you canuse ‘tack’ and the other data from theMaster Script to vary the angles ofboom and sails. If the boat is not sail-ing, then the boom is in line with theboat’s axis. If it is sailing, it swivels20 degs for ‘Close hauled’ and 40degs for ‘Reaching or Running’.

500: In this exercise, the main sail isdone as a PLANE, and not as acurved COONS mesh (which wouldlook better), since the original focusof this exercise is on the scripting forthe floats.

A small amount of trigonometryis required to make sure that the

Time to add somemore parameters!These are Values Listones – use ‘abc’ asthe parameter typeand click on thevalue list button.

300: !cross beam pieceADDz hit-0.12PRISM 4,0.1, -0.1, (cwid-wid) /2, +0.1, (cwid-wid) /2, +0.1,-(cwid-wid) /2, -0.1,-(cwid-wid) /2DEL 1RETURN

!Catamaran Hull!for Voyager CoursePEN pcolRESOL 12!Floats ADDy (cwid-wid)/2GOSUB 200 !Entire Float DEL 1 ADDy -(cwid-wid)/2GOSUB 200 !Entire Float DEL 1!Cross beams ADDx len*0.1 GOSUB 300 !Beam DEL 1 ADDx len*0.55 GOSUB 300 !Beam DEL 1 ADDx len*0.85 GOSUB 300 !Beam DEL 1END !------------

400: !MastMATERIAL "Stainless Steel" ADD len*0.55,0,hit MULx 1.5 !make it ovalCYLIND mhit,mastrad !mast DEL 2RETURN

450: !BoomMATERIAL "Stainless Steel" ADD len*0.55,0,hit+hit ROTz tack*20 ROTy -90+5 MULx 1.5 !make it oval CYLIND boomlen,mastrad*2/3 DEL 4RETURN

500: !Main SailMATERIAL 'sailcloth' ADD len*0.55,0,hit+hit ROTz tack*20

IF tack THEN PLANE 3, !Flat Sail -mastrad,0,0, -mastrad,0,mhit-hit, -boomlen,0,len*0.5*COS(85) ENDIF DEL 2RETURN

boom is allowed to slope at 5 de-grees. PLANE is the easiest way tomake a surface, as you only have todefine the X-Y-Z points. It also helpsto do the Sail as a separate subrou-tine, to make debugging easier.

Materials: Note that in the MasterScript we defined the Material of‘sailcloth’ – as a plastic-like materialwith an RGB value of 1,1,1 It stilllooks a bit grey – you need a bit of‘emission’ to make it look whiter. Atthe same time, we can also specify ametallic grey for the rigging.

Page 248: Cookbook3_1

2.145

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Finishing offWith all these extra subroutines, theexecutive script now looks like this.

2D ScriptFinally, you need to give the Cat a2 D script for the stretchy hotspotsto work, and as it may be difficultto pick up, additional hotspotsenabling you to pick it up.

Rigging600: This further demonstratesthe use of TUBE to do lineartasks. Instead of a multitude oftrig calculations and cylindercommands, one single TUBEmoving from XYZ location tothe next can do it all in one se-quence. A polyline with 900and 4000 defines the cylindri-cal section, and RESOL3 makesthe cylinder into a triangularsection.

!Catamaran!2D ScriptPEN pcol

!Stretchy HotspotsHOTSPOT2 0,0HOTSPOT2 A*0.7,-B/2HOTSPOT2 A*0.7, B/2HOTSPOT2 0,-B/2HOTSPOT2 0, B/2

!Pick up HotspotsHOTSPOT2 0,-B/2+widHOTSPOT2 0, B/2-widHOTSPOT2 A*0.55,0HOTSPOT2 A*0.85,0

PROJECT2 3,270,2

600:!RiggingRESOL 3MATERIAL 'rigging'PUT len*0, cwid/2, -1 ,0, len*0.40, cwid/2, hit,0, len*0.55, 0.08 ,mhit,0, len*0.55,-0.08 ,mhit,0, len*0.40,-cwid/2, hit,0, len*0.00,-cwid/2, -1 ,0BODY -1

TUBE 2,NSP/4,63, 0,0,900, 0.01,360,4000, GET(NSP)BODY -1RETURN

!Catamaran Hull!for Voyager Course

PEN pcolRESOL 12

!Floats ADDy (cwid-wid)/2GOSUB 200 !Entire Float DEL 1 ADDy -(cwid-wid)/2GOSUB 200 !Entire Float DEL 1

!Cross beams ADDx len*0.1GOSUB 300 !Beam DEL 1 ADDx len*0.55GOSUB 300 !Beam DEL 1 ADDx len*0.85GOSUB 300 !Beam DEL 1

GOSUB 400: !MastGOSUB 450: !BoomGOSUB 500: !Main SailGOSUB 550: !JibGOSUB 600: !RiggingEND !------------------

Level of DetailAt this point, you make decisionson level of detail. If you want asea scene, this may be goodenough, but if you are designinga marina sales area, you maywant to add rudders, tiller, net-ting and more. Level of Detail(LOD) is a constant factor to con-sider.

The use of BODY -1 ensures thatTUBE works without unexplainederrors.

These could alsobe tidied awayinto a subroutine

Forestay and jib550: Whether you are sailing or at an-chor, you need a forestay. This couldbe done with a CYLIND but would be adifficult piece of Trig. TUBE, in whichyou only need to know the X-Y-Z loca-tions is far easier, once you get the hang.Do not forget the ‘phantom points’ withTUBE; in this case, 1000 metres up inthe air and down in the deep! Use PUTand GET and BODY -1 to ensure thatyou have less risk of syntax or unex-plained errors. RESOL can be 3, as it is aslender cable, and 3 will suffice.

The jib itself is also a PLANE, swiv-elled at the same angle as the Mainsail.

550: !Jib!ForestayMATERIAL 'rigging'RESOL 3PUT len*0.85,0, -1000, 0, len*0.85,0,hit, 0, len*0.55+0.1,0,mhit+hit,0, len*0.55+0.1,0,1000, 0

BODY -1TUBE 2,NSP/4,63, 0,0,900, 0.01,360,4000, GET(NSP)BODY -1

IF tack THEN !Foresail MATERIAL 'sailcloth' MULy -tack PLANE 3, len*0.85,0,hit, len*0.55+0.1,0, mhit+hit, len*0.50, cwid*0.3, hit*2 DEL 1ENDIFRETURN

Fonts or what?Some people wonder at the font system in the Cookbook. Generally a headline inGaramond is for a section of Theory, and a headling in Frutiger is for an objectbuilding exercise. Tips and Tricks are all done in Frutiger. The Body Text throughoutmost of the GDL Cookbook is done in Garamond 10, exactly as in the Graphisoftmanuals.

Page 249: Cookbook3_1

2.146

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Squiffle – revisitedby Bill Rattenbury, author of Project Framework

FOR the brave here is a GDL object script to makethe line ends overshoot and cross each other. It is

designed to work with the hidden line drawings cre-ated from the 3D view, and as such only supports pencolour and lines; everything else (arcs,circles,fills textetc) is ignored!

What it does is read in a GDL script created byArchiCAD of the lines and draws it as a single objectwith the line ends crossing. It randomly flips the linesto prevent the problem of parallel lines all squigglingthe same way.

How to use Squiffle21) Copy the lines of a hidden-line view from the 3Dwindow using the ‘flat’ marquee option. Start withsomething VERY simple!

2) Paste these into a empty corner of the floor plan.

3) Select all the lines with the pointer tool.

4) Open a new GDL script window (File/Open LibraryPart/GDL Script).

5) Drag the selected lines onto the open script win-dow. You may need to resize your floor plan windowso both are visible.

6) The lines get converted to text. Save the script intothe ‘ArchiCAD Data Folder’ inside the ArchiCAD folderas ‘View1.gdl’ or similar.

7) Place this Squiffle object into the project floor plan,typing the name into the appropriate parameter field(windows users may need to add the ‘.GDL’). Watch ithappen! You may need to zoom to fit in window tosee the new object.

SummarySo! I finally found a use for the mysterious SPLIT com-mand! For complex perspectives this object gets VERYslow and it would need further development so it couldwork with floor plans and draw thick line ends etc.

An API which could take a copy of your selectedfloor plan elements, explode them and squiffle themwould be much faster and easier to use, any Cprogramers keen? ;-)©Bill Rattenbury, email: [email protected]

DNC writes:Earlier in the GDL Cookbook, you may have read aboutSquiffle, a magic (but really a very easy) technique for mak-ing line drawings look rough or hand drawn. This could bedone to any line drawing brought into ArchiCAD. All youhad to do first was to make a new LINE_TYPE, by drawing it,and pasting it along with a line name (like ‘Squiffle’) into theOptions/Line Types dialog. Bill Rattenbury now comes upwith this brilliant little piece of GDL that allows you to ex-tend the lines, parametrically. You can of course roughen iteven further by selecting the original Squiffle1 line type forthe drawing. As this Squiffle2 takes a long time to draw be-cause of all the disk I/O, I advise you to Explode the result,and then apply Squiffle1 lines to it.

This catamaran looks a lot more sketchy with the Squiffle2treatment!

! Squiffle2 Sketch Object 2d script! Check that a file name has been inputtedIF STRLEN(file_name) > 0 THEN

! Set up the variablesLET pen_num = 1LET Ln_In = ""

! Scale the overshoot to page millimetresLET overshoot = overshoot*GLOB_SCALE/1000SET LINE_TYPE L_Style1

! Open a Text File Channel, called 'ch1'ch1=OPEN("TEXT",file_name,"separator='/t',mode=RO")

LET row = 1: LET n = input (ch1,row,1,Ln_In)

WHILE n <> -1 DO IF n = 1 THEN IF strstr(Ln_In,"LINE2")>0 GOSUB 100 IF strstr(Ln_In,"PEN") >0 GOSUB 50 ENDIF LET row = row + 1 LET n = INPUT(ch1,row,1,Ln_In)ENDWHILE

CLOSE ch1ENDIFEND:!----------------------------------

50:!Split command extracts Pen settingm = SPLIT(Ln_In,"PEN %n",Pen_bit,pen_num)RETURN

100:!Split command extracts Line parametersm = SPLIT(Ln_In,"LINE2 %n, %n, %n,%n",Line_bit,X0,comma1,Y0,comma2,X1,comma3,Y1)

LET scale_ratio=overshoot/MAX(SQR((X1-X0)^2+(Y1 - Y0)^2),0.0001)

IF scale_ratio>1 THEN LET scale_ratio=0

PEN pen_numLET Xoffset = (X1 - X0)*scale_ratioLET Yoffset = (Y1 - Y0)*scale_ratio

!Randomly draw the line backwardsIF RND(2)>1 THEN LINE2 X0-Xoffset,Y0-Yoffset,

X1+Xoffset,Y1+YoffsetELSE LINE2 X1+Xoffset,Y1+Yoffset, X0-Xoffset,Y0-YoffsetENDIFRETURN Scale_ratio checks that the line will be longer than the

overshoot. This prevents curved surfaces made of shortline segments from looking like little ‘fire wheels’

WHILE ENDWHILE is a good (and safe)way of reading through a textfile whenyou don’t know where it’s going to end

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 250: Cookbook3_1

2.147

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Test TUBE to make coiled cable!Simple Non parametric demo

RESOL 6rad=0.5 !RadiusPUT 0,0,-1,0,!twist 0,0,0,10, 0,0,1,20, 0,0,2,30, 0,0,3,40, 0,0,4,50, 0,0,5,60, 0,0,6,70

MATERIAL 'whitewash'PEN 1TUBE 2,NSP/4,63, 0,0,900, rad,360,4000, GET(NSP)

!‘Coilcabl’:GDL Macro!Error checking

IF n<3 THEN n=3IF n>12 THEN n=12IF t<1 THEN t=1IF t>10 THEN t=10RESOL n

FOR z=-d TO l+d STEP d tw=tw+t^2 PUT 0,0,z,tw NEXT z

BODY -1TUBE 2,NSP/4,63, 0,0,900, d/2,360,4000, GET(NSP)BODY -1

Cable Macro

This is a Parametric way ofdoing the cable so this can bea Macro, used like CYLIND, upthe Z-axis

MATERIAL 'Zinc'PEN L_CALL coilcabl PARAMETERS l=5, d=0.4,n=8,t=6

This is how it can be used as a macro

THIS exercise investigates a useful feature of TUBE command, &

shows how to make a Macro.

The last digit in the Pathway defini-tion of a TUBE command is a Twist an-gle. (The best stories always have a twistat the end.) If this angle progressively in-creases, then the section twists as itmoves through space. The first exerciseshows simply how this is done. The an-gle is always absolute, not relative. 10,10, 10, will go straight, 10, 20, 30 willtwist.

MACROS are objects that can becalled by other GDL scripts and that be-have like a command. For example, thecommand CYLIND calls up a cylindricalshape with parameters H and R. This onecould be called ‘TWISTCYL’ or‘COILCABL’ and only needs the 4 param-eters shown on the right.

The 900 and 4000 define a circular sec-tion; if these were 901 and 4001, thetwisty lines would disappear.

If you have smoothness ON inphotorendering this form gets smoothedand the macro is useless – with smooth-ness OFF, you can clearly see the twists.

Because it will be used as a Macro,it’s easier to use single letter variables. Itcan now be used like CYLIND.

Deliberate Errors

COMPUTERS work in Machine Code, we work inthe world of Applied Maths. We humble earth-

lings use feet and inches, or millimetres or metres.In between the two, there may be conversion stageslike Decimal and Hexadecimal and Binary.

Sometimes when you divide two numbers, or usethe INT command, you get tiny errors as a result ofthis conversion. For example 1/3 produces a recur-ring number in decimal. INT(9/3) could produce aresult of 2 instead of 3 due to tiny conversion errors.FOR k=0 TO 10 STEP 5/2 should produce 4 intervalsand 5 locations; but this could result in one of thembeing lost.

Nobody notices small dimensions like 1/256” or1 millimetre. So if you write FOR k=0 TO 10+0.001STEP 2.5, you will eliminate the conversion error,but you will not alter the model at all. I noticed re-cently that if you divide 6’-0” by 3’-0” you get anerror. If you divide by 6’-0” by 2’-11.9999” (yes youcan use decimals) you guarantee getting a result of2. If a piece of GDL simply doesn’t work when itshould, look for the opportunity to feed in a deliber-ate error.

Architects can create Web sites

DOES anyone out there have experience of creating and managing their own web page... >Neil

YES, most architects do their own pages themselves nowadays.With the plethora of absurdly easy visual design tools (no html

programming required) the idea of a designer paying another de-signer to put his image out there is not necessary.

Even if you had a graphic designer start it out for you (logos,menus and all) you will definitely want to maintain it yourself andupdate your samples of work, personnel, skills, and, of course link toyour project-specific-web-sites which may be the single most impor-tant reason for a project architect to get into web technology.

Over the years I have tried countless web-writer softwares, freeand paid for, both Mac and Windows. Though I still use PageMillmyself as my primary tool, I would recommend that most people justdownload the free NetscapeCommunicator4 which includes a veryvery useful PageComposer. You can leave PageComposer open whileviewing with Navigator live and drag and drop images. It will auto-matically put any graphic files together in any empty folder you pick(to keep a local version on your own hard drive) and automaticallyPublish the whole site to whichever provider you specify. It even hasbuilt in wizards that will design a preliminary page or whole site FORyou. Hard to beat free AND easy AND good. >Geoffrey Moore Langdon, AIA

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 251: Cookbook3_1

2.148

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

DEFINE TEXTURE: For GDL to make a materialwith a texture it has to have a texture defined, and thattexture has to have an index number.

If you look at the familiar material-making dialog,you can see that having selected your colour file to bethe texture, you specify the size of texture (x and y),the rotation angle and how it responds to alpha chan-nels. The GDL command does exactly the same thing,

DEFINE TEXTURE ‘chekpatn’ ‘chekpatn.jpg’, 1.0, 0.75, 1,0 txtrnum=IND(TEXTURE,’chekpatn’)

We use the IND( ) expression to find the Index numberof a texture or material.

When you make the Material, you can use a general(as in the flag) or here, we use a predefined one, theplasticky one (20+4).DEFINE MATERIAL 'chekmatl' 24, 0.9,0.9,0.9, !RGB 0,61,IND(TEXTURE, 'chekpatn')

THIS is one of the greatest mysteries of GDL. EveryArchiCAD user asks, at some stage, how can I make

a texture start from exactly where I want it to start, scaleit, rotate it, and make it go in the direction I want it togo in? For flat objects such as a building facade, thisquestion can be solved with a picture object. But manyobjects, such as the curvy flag or the cyclorama, arecurvy or complex. The GDL manual tries to help, butmakes matters worse for most readers – including me.The ‘knowledge’ gets around at training courses andby word of mouth. And here it is now, in writing.

We are going to map this texture on to this Prism –and then try different orientations and starting points.The normal way to make a material is known to mostArchiCAD users – use the Options/Materials menu se-lection and it’s easy enough. The information aboutthe material is stored in the Project file. But this doesn’twork for all users. The Flagpole here is an example ofwhere you couldn’t expect the user to make materialsthis way for every flag, and the cyclorama materialwould also be a nuisance for the user to set up – butyou could make the GDL do it for you.

DEFINE MATERIAL: You can make materials inGDL. There are many ways:

0: General definition in which you specify 16 charac-teristics (including the RGB colours, reflection, trans-parency, emission).

1: Simple definition, in which you only specify 9 (in-cluding RGB and reflection)

2-7: Predefined definition, in which the qualities of re-flectivity and transparency are already known in ma-terials such as Matte, Metal, Plastic, Glass, Glowing andConstant.

10-17: Then these are repeated with a single addedparameter for Fill.

20-27: These are all repeated again with 3 added pa-rameters, fill, colour of fill and index of Texture.

See the examples in the manual, and in the Flagpoleand the Cyclorama for further detail.

Secrets of Wrapping Textures

PRISM shape _ using Polylines Texture chekpatn.jpg

2: Matte: non reflective3: Metal: shiny but non reflective4: Plastic: not shiny, but reflective5: Glass: transparent (with colour)6: Glowing: with colour7: Constant:: horrid! no shading

Predefined Material types

The manual tells you to put a comma between thetexturename and the texture bitmap. But you mustnot!

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 252: Cookbook3_1

2.149

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Working out how textures are mapped!Nov 2000 DNC

DEFINE TEXTURE 'chekpat' 'chekpatn.jpg', 1,0.75,1,0

DEFINE MATERIAL 'chekmatl' 24, 0.9,0.9,0.9, !RGB 0,61,IND(TEXTURE, 'chekpat')

MATERIAL chekmatlBODY -1PRISM_ 9+2,2, 0.00,0.00,15, -1,3,15, 1,3,15, 1,4,15, 2,4,15, 2,1,1000+15, 1.5,1,15, 1.5,0.00,15, 0.00,0.00,-1,

2,2.5,915, 0.8,360,4015

VERT 0,0,0 !OriginVERT 1,0,0 !X directionVERT 0,1,0 !Y directionVERT 0,0,1 !Z directionCOOR 2,1,2,3,4BODY -1

Wrapping modes:These are illustrated in the GDLmanual, and here: 1=planar,2=box, 3=cylindrical,4=spherical, 5=cylindrical withrectangular to top and bottom.

Wrapping the texture: VERT+COORHere we use the same prism that we have used before,but it’s a bit larger. There are so many different ways ofmapping texture, we are going to have to print many smallrendered images showing what happens in each case.

The statements whichdefine the position of atexture are VERT andCOOR. These are all writ-ten after the object that isto be textured.

Four VERT statementsset out the location, andCOOR does the wrap-ping. The process isended with a BODY -1statement.

The first VERT statement is the starting point (origin)of the texture. Then from that point there are the threelocations which define the X, Y and Z direction. If the 3pointed star you thus create is cubic, you will get nicelyprecise wrapping, but you can deliberately distort theshape of the star to create distortions in the texture. TheCOOR statement is thus: COOR, wrapping mode,vert1, vert2, vert3, vert4

Follow that with BODY -1. There are other modifiersto wrapping mode,256,1024, 2048 and 4096.

Try it!This whole technique isdefinitely worth explor-ing once you have theidea. Its been fun writingit. 2 exercises in the Cook-book explore this tech-nique, the Cyclorama andthe Flagpole.

Wrapping modes

1 2

3 4

5

Here, the origin is at the extreme left corner of theprism and the 3-pointed star is perfectly cubic.

Wrapping modes

1 2

3 4

5

Here, the origin of the 3-pointed star has beenmoved to the centre of the hole.

Here the origin is backto 0,0,0, but the X,Y andZ locations have beenmodified so that the 3-pointed star is tilted.

BODY -1PRISM_ 9+2,2, 0.00,0.00,15, -1,3,15,..... etc, etc same as above .....2,2.5,915, 0.8,360,4015

VERT 2,2.5,0 !OriginVERT 3,2.5,0 !x-directionVERT 2,3.5,0 !y-directionVERT 2,2.5,1 !z-directionCOOR 1,1,2,3,4BODY -1

BODY -1PRISM_ 9+2,2, 0.00,0.00,15, -1,3,15,......etc, etc, same as above.....2,2.5,915, 0.8,360,4015

VERT 0,0,0 !OriginVERT 1,1,-0.5 !x-directnVERT -1,1,-0.5 !y-directnVERT 0.5,0.5,1 !z-directnCOOR 2,1,2,3,4BODY -1

The 3-pointed star

12

3

4

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 253: Cookbook3_1

2.150

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

This object provides a surface to support context pho-tos of the neighborhood of the project, but is not theabsolute background. Compared to measuring andmodeling the entire city, it reduces the complexity ofthe model and shortens rendering time. Several of theseobjects of different sizes could be nested together fora layered, theatrical effect.

The object is an empty cylinder. It can be scaled tothe diameter and height needed to approximate thedistance and height of the context to be created.

The trick is in preparing the scenery painting. In areal context, you should use a photographic panorama,stitching the overlapping pictures into a smooth 360˚cyclorama using an application like VR Authoring Stu-dio or Spin. This will give you absolute control overthe ‘size’ of the background: once the perimeter ‘length’of the cyclorama is established, the relative ‘height’results. To create accurate height, you’ll need to deter-mine the height and distance of a prominent object inyour photos from which to scale.

Using a photo editor, make the sky transparent bymasking it with an ‘Alpha Channel’. This simplifiesmaking a quality photographic cyclorama: clouds andexposure variations in the sky can be difficult to match.

In the rendering background, place a photo of cloudsand sky scaled to suit the VR panorama size chosen,tilted CCW 90˚ to match the VR rendering routine. [Ob-serve a VR render being made once and you will un-derstand: ArchiCAD makes VR panoramas tilted side-ways and later rectifies the image.]

This example uses a panoramic scenery photostitched together into an image that fills the panoramaat the ratio needed to simulate forest trees. [If they looktoo big, this is just another way to know that it is timeto visit British Columbia.] By placing the image in theArchiCAD library, it can be used as a texture map ap-plied to the surface of the cyclorama. Do not scrimpon image size: this image is well over 3000 pixels wide.The image must not be saved as a JPEG. It must beuncompressed – a TIFF, a PICT or a BMP.

Try it without GDLThe 3D object is a cylinder. First try it using Profiler tomake the cylinder. You will have to make a Material(in the options material) from the cyclorama image.You will have to map the image to the exact perimeterof the cyclorama object to avoid overlap; calculate theperimeter of the object using the formula: PI x diam-eter to establish the width of the mapping image. Con-strain the proportions of the scaling and note the heightof the image after the width fits the cyclorama perim-eter. If you are not accurate enough and a vertical seamshows in the rendering, add a unit to the horizontalsize. Keep trying. Use the height of the image as theheight of the cyclorama.

The height of the cyclorama is critical. It must notexceed the height of the image. If the cyclorama is tootall, ArchiCAD will repeat the image at the top. Youwill see this in the render if it happens. The shadowalgorithm ignores alpha channels, so you may get abig shadow across your final picture. A big mess.

Try it with GDLThe GDL object supplied here takes all the guessworkout of it. It builds a texture and a material from the

Create a CYCLORAMA for yourVR PanoramaJust like building a set for the movies!by Dwight Atkinson, GDL by David NC

A VR panorama’s realism is enhanced by an intermediate background. To create one, insert an object, known in movie parlance as a ’Cyclorama’, into the ArchiCAD environment sur-

rounding the project being modelled.

Mountain photography by Jennifer Lamb

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 254: Cookbook3_1

2.151

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

main image. It accurately maps the image to the cylin-der, starting from the ground, and stretching it to fitperfectly no matter what radius or height you specify.You can stretch the cylinder in the 3D window, andyou can make the planform ellipical. It removes theshadow. The GDL anchors the texture to start at themost eastward point of the cylinder.It prevents thegroundline from repeating itself in the sky.

For realistic shadows of the actual trees or moun-tains, magically create a PIPG from the alpha channelwith ArchiCAD’s new fantasy utility PIPGMaker, avail-able from wizards in a far-off land somewhere. TheItalians figured it out somehow. They think they are sosmart. But ask them to fix a car and see what happens.

The image map will be represented starting fromthe origin of the object, the most eastward point. Ifyou find that your image is not correctly oriented, ro-tate the object to suit. The image map will also rotate.Trial and error is required here as the rendered view isthe only place where the mapping can be seen.

For this example, a diameter of almost one hundredmetres was chosen. This is a good start, but is prob-ably too small for a building project with multiple VRscenes. To rescale, just stretch to a new size and theobject will stretch the original image image map pro-portionally. If you use Profiler or the Wall tool, youwill have to go back to the calculator.

Don’t spin too fast. You’ll get dizzy. Dwight

!Cyclorama Object!2D Script

PEN pen2d

HOTSPOT2 0,0HOTSPOT2 -A/2,0HOTSPOT2 A/2,0HOTSPOT2 0,-B/2HOTSPOT2 0, B/2

!Draw the CircleMUL2 1,B/ACIRCLE2 0,0,A/2

IF hoton THEN !extra hotspotsFOR ang=30 TO 331 STEP 30 HOTSPOT2 COS(ang)*A/2,SIN(ang)*A/2 NEXT ang ENDIF DEL 1

!Labeltd=2*A_/1000IF labl THEN DEFINE STYLE 'labltext' arial,2,1,0 SET STYLE 'labltext' TEXT2 0,-td,'Cyclorama Centre' ENDIF CIRCLE2 0,0,td/3 !Centre circle LINE2 -td/2,0,td/2,0 LINE2 0,-td/2,0,td/2

!CrosshairsIF crosh THEN DEFINE LINE_TYPE 'croshair' 5.0, 4,0.002,0.008,0.0,0.008 SET LINE_TYPE 'croshair' LINE2 0,0,-A/2-0.2,0 LINE2 0,0, A/2+0.2,0 LINE2 0,-B/2-0.2,0,0 LINE2 0, B/2+0.2,0,0 ENDIF

!Cyclorama Object!Article by Dwight T Atkinson MAIBC!GDL by David NicholsonCole!3D Script

!Define the TextureDEFINE TEXTURE 'cyclotxtr' filenam, 2*PI*A/2,zzyzx*1.05,1,0DEFINE MATERIAL 'cyclomatl' 22, 1,1,1,0,61,IND(TEXTURE,'cyclotxtr')

!Make the CylinderSHADOW OFFTOLER 0.2MATERIAL 'cyclomatl'MULy B/A

BODY -1EXTRUDE 2,0,0,zzyzx,48, 0,0,901, A/2,360,4001

!Map the texture cylindricallyVERT 0,0,0VERT A/2,0,0VERT B/2,0,0VERT 0,0,zzyzxCOOR 3,-1,-2,-3,-4BODY -1

If you use the Profiler method, get ready to spend a longtime with your calculator figuring out the optimum widthand height

Stretchy Hotspots

Stretchy Circle 2D

Extra Hotspots

Label – no matter howlazy you feel, you

must never omit toDefine Style before

writing 2D text

Define LINE TYPE.This will only work ifyou tick ‘Use object’s

Line types’ in thesettings box.

Scripts: 3D: defines a Texture and Material. Laterin the script, it maps it to the east corner of the cyclo-rama – see the section on Texture mapping for full ex-planation. TOLER is used for curvature so that the reso-lution is adjusted no matter how large the cyclorama.

2D: Define LINE_TYPE. This makes a dotted line forthe cross hairs. The spacing of the line here is 5 me-tres, and the small numbers are alternating lines andspaces. Multiply the index of the segments lengths bythe spacing to get the actual length of each segment.

This routine remove the trial anderror – ensures that the mappingis cylindrical around the centre

This routine saves you thetrouble of making amaterial in the project –stretches the image to fit thecyclorama precisely

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 255: Cookbook3_1

2.152

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

WE all know that ArchiCAD provides us with alibrary of backgrounds. These are best for sin-

gle views and have the disadvantage of being unableto change when you change the camera position, sothat a cloudy sky looks quite unconvincing during aflythrough – it is always static with the same cloud be-ing in view. You can rectify this somewhat for a VR fileby taking one of the ArchiCAD skies, and repeating itmany times, stitching it together in blocks (flip hori-zontal each time so that the clouds join) until you get afile several thousand pixels wide. Rescale it to an ex-act size which must be divisible by 96. The short di-mension must be divisible by 4. ArchiCAD works thisout for you, but if you are in Photoshop, you need thistable in the Cookbook.

When you run the VR, make sure that the large di-mension will be exactly the same as the backgroundsize. Even then you sometimes get a vertical break line.

Why does the long dimension need to be divisibleby 96? Well, a Quicktime VR is actually a movie of 24tiles which rapidly slide past your vision as you scroll.Any one tile must contain a number of pixels divisibleby 4. That makes 96 as the common divisor.

In digital VR using a camera, the proportion of widthto length is variable. I have done digital photographyVRs where the ratio is between 6.5 and 8 dependingon how steadily you hold the camera and the wideangle ability of your lens. As the image is stitched, it iscropped top and bottom if you do not use a perfectlybalanced tripod. A very bad photoshoot will result in aratio of 8, and if you can get it down to 6 you havedone very well. In a CAD package, there is no dodgytripod or rough pavement, so you get a better ratio –more like that of PI, 3.14. ArchiCAD has its own set ofratios, so here is the table of preferred sizes.

For VRs you are concerned mainly with screen dis-play, and with opportunities for putting walkaboutson the web. You do no need anything like the highpixel definition of a finished static render where youmight be looking to get 300dpi or higher in quality.The ideal window size for viewing a VR is 360 x 240,and if the background panorama image is 796 x 2496,that gives plenty of detail for the user to zoom in onto,and plenty of scope for looking up and down as wellas around.

VR Rendering with BackgroundsLet’s make a backgroundThe Sunset is a good one to start with because it hasmany horizontal lines. Sharp eyed readers will pointout that sunset is always in the west, and the view tothe other horizons would be darker. True! But lets talkabout technique. You can apply this idea to cloudyskies, perhaps ones you have photographed yourself.For this, use Photoshop or a good bitmap editor.

This sky is 1024 x 768 (fits a normal 2-page displayperfectly) Open it, and save as a new test file. Rotate itCCW so that it is upright. Make a New file and set itssize to 1400 x 5000. Select All in the sky file, copy andpaste it to the new file. Move one paste to the top,paste again and move the second to the lower middle.Return to the sky file, flip vertical, select all and thenpaste it into your new file, move it to the upper mid-dle. Paste again and move to the bottom. Avoid thepastes overlapping.

Once the images are in the new (big!) file, zoom incloser and dock them carefully, avoiding a white pixelgap between images. Because one has flipped them,they meet perfectly, but the image develops somethingof a ‘Rorschach test’ look about it.

When the part images are docked, cropoff the surroundings. Do not lose pixelsat top or bottom or the image will notwrap nicely when it meets in a 360˚ sur-round.

Finally, untick the proportionscheckbox and repixellate it to one of thesizes in the table. Save it into an activeArchiCAD library. Use this in conjunctionwith the Cyclorama and the mountainswill be visibly different from the sky, en-hancing the 3D effect. With these twotechniques, you are ready to V-Rumble!

640 x 2016672 x 2112704 x 2208732 x 2304764 x 2400796 x 2496824 x 2592856 x 2688888 x 2784916 x 28801008 x 3168

304 x 960336 x 1056368 x 1152396 x 1248428 x 1344460 x 1440488 x 1536520 x 1632552 x 1728580 x 1824612 x 1920

Here is the starter file, so rotate itCCW 90˚.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 256: Cookbook3_1

2.153

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Cast Shadows with AlphaChannels without GDLby Steve Campbell, introduced by DNC

CAN Alpha channelled picture objects or texturemaps cast shadows in ArchiCAD? No they cannot!

Or so it seems. Perhaps we can? Anybody who hasused picture objects, or mapped textures on to a sur-face is disappointed to find rectangular shadows be-ing cast. This is particularly distressing in the case ofpeople and tree figures. One solution is to do it inArtlantis – but we are talking ArchiCAD in the GDLCookbook – this is where we want the shadows to workjust as well.

Another solution was discussed in the article in theDiscovery section (‘People who face camera’) usingpeople as an example. Trace the outline of the tree orthe people figures with the slab tool and write someGDL. Map the texture onto it using COOR and VERT.

First, there is a solution available in 6.5 onwards,using the special menu and not using GDL at all. Itworks like a treat! Then we look at the COOR solution.

Let’s make an alpha-Dwight!I have chosen a photograph of one of the Cookbookeditorial team, Dwight Atkinson. Do this withPhotoshop or a good bitmap editor. First thing to do isto remove the background. This is painful to do as DNCand Dwight’s wife were in the background. Once thewhole background is completely white, use the magicwand to grab the background, CUT it (Cmd-X).

In the Channels Palette, make a new channel, andcall it ‘Alpha’. Click into that channel. If it is not al-ready black, use the paint pot to fill it with black. Dropthe black into the alpha channel, not all over Dwightin the RGB channels. Then Paste (Cmd-V) the back-ground into the Alpha channel. Click off, then selectall, and INVERT it so that the background is now blackand the area where Dwight is standing is white.

Note the size of the image. If you think Dwight is1.8 metres high, use the Image settings window inPhotoshop to tell you how wide the image will be.

Save this as a TIF or PICT or BMP into an ArchiCADlibrary, but do not use any of the compression formats(JPG, GIF). If you are already in ArchiCAD, reload yourlibraries, including the one that contains this file.

Now get it working in ArchiCADSteve Campbell writes:

In ArchiCAD, first create a new material [it’s easiest toduplicate an existing one like marble and adapt it].Make sure the expert options are showing. Hit the EditTexture button.

Now you'll want to choose your tree or person pic-ture as the applied texture. It needs to be a picturewith an alpha channelled background. You can usethe Search button to find it. It has to be a picture lo-cated inside a loaded library. Once you've picked yourpicture set the width and height of the texture to theright size. [You have a button in the dialog box allow-ing you to set the proportions according to the size ofthe image]. Write these values down somewhere. Nextunder the Alpha Channel Effects section check theTransparency option.

Check on the width to heightratio of the image and applythis to your wall

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 257: Cookbook3_1

2.154

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Build the wallNext go back to the plan window. Pick the wall tool.Set the wall thickness to 1/64” or 1 millimetre. Set thetop, bottom, and side materials to the new materialyou just made. Set the height of the wall to the heightyou gave to your tree picture. Now draw a wall andmake its overall length equal to the width of the treepicture.

Above: Ensure that the proportions match those of the image,and that you have ticked the Transparency boxBelow: The wall settings, with the height, thickness andmaterial

In Photorendering settings, choose Shadows on, andclick the Options button. Tick the ‘Use transparency inshadow calculation’.

Map the picture – use ‘Special’ menuThe last step involves setting the vector fill origin. Thismake sure that one copy of the tree or person picturefits exactly to the wall. You'll need to turn on the Spe-cial menu. To do this hold down the CTR + ALT keysor CMD + OPTION keys as you start ArchiCAD. Onceyou start you'll have a new menu called Special.

Now to set the origin go to the 3D Window. Set theUser Origin to a bottom corner of the thin wall youmade [click at the corner with Alt-Shift].

Now type Z and set the Z value to 0.000'. Select yourwall, choose Set Vector Fill Origin/ Set Position fromthe Special Menu. Click on the User Origin in the 3DWindow.

Do a photorendering and you'll only see the figureshaped shadow. The hardest part of this method isgetting the origin set correctly.

The 3D windowshows only the

upright wall. Alt-Shift-Click the

user origin at thebottom corner of

the wall. The UserOrigin appears as

a 3-pointed star.The shadow will

be of a rectangle.

When you havedone the business

with the Specialmenu, you can

tryphotorendering.If all went well,

you will get this!

Want more?Having got it working with one wall, you can dupli-cate them as much as you like. Although it first requiredthe user origin, it seems to remember the mappingthereafter, even when you move or duplicate the wall.

If the wall renders unreliably (texture doesn’t lock tothe bottom corner), then Save Special... as an Objectand it will always work. The Autoscript gives a perfectdemonstration of the use of COOR and VERT!

©David NC and Steve Campbell <[email protected]> with apologies to Dwight Atkinson

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 258: Cookbook3_1

2.155

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Cast Shadows without AlphaChannels and do it with GDLIN the Discovery course, we had a 3D outline shape

that was cut for different people shapes. The sametechnique can be applied to trees. But it couldn’t dis-play a photographic texture map. In the Voyager exer-cise on the previous page, we mapped a texture ontoa wall. It can cast shadows in a rendering but is a rec-tangle in 3D. It seems we can only butter our bread onone side.

With a bit of GDL we can have our bread both-sides-buttered! Let’s adapt Geoffroy Magnan’s object, to ex-tend the model of Dwight. Bring the figure into Archi-CAD, resize it with the Figure settings box (in AC 6.5

r3) to the exact size. Make sure the bottom left corneris precisely on the Main Origin of the Project file. Traceit with a Fill tool. Drag it into the floating 2D scriptwindow of a new object. It will be a POLY2_B. Thiscan be converted easily into a POLY_ which is a 3Dentity. Copy and Paste that into the subroutine of the3D script of our new object below, set A and B to matchwidth & height, and save as a new object.

This technique can be applied very successfully toentire building facades. This object can be adapted.Just trace the outline with a Fill, drag over to the GDLand build the resulting outline in to the subroutine.

!3D Cutout model without alpha shadows

dkx=K~-X~:IF dkx=0 THEN dkx=0.001dly=L~-Y~azi=ATN(dly/dkx)!Azimuth

DEFINE TEXTURE 'maptxt' filnam, A, B, 1, 0DEFINE MATERIAL 'mapmat' 24, 0.5,0.5,0.5, 0,61,IND(TEXTURE,'maptxt')

PEN pcolMATERIAL 'mapmat'

IF turn THEN ROTz (90+azi-W~) ROTX 90 BODY -1:GOSUB 100:BODY -1!Do it!DEL 1

BASEVERT 0,0,0 !1 originVERT 1,0,0 !2 XVERT 0,1,0 !3 YVERT 0,0,1 !4 ZCOOR 2+256,-1,-2,-3,-4BODY -1

END !-------------------------

100 : !DwightPOLY_ 47, 0.392028, 0.102625, 1, 0.295824, 0.115744, 1, 0.208365, 0.093879, 1,!all the remaining points follow......RETURN

Set the size of the figure, andposition it over the Main Originbefore tracing it. Dont’ make thetracing too elaborate, its onlythere to cast a shadow. Softwarelike Adobe Streamline orCoreldraw may be able to do thisfor you, save as a DXF and bringin to ArchiCAD, and use themagic want to form a Fill. Butyou may have thousands ofpoints, whereas with handtracing, it is quick and you endup with a managable 47 points.

Before you are finished, knockup a quick 2D script withPROJECT2 3,270,1. See theexample on the Cookbook CD.

All you have to do now is tell it the name of the file to loadas a texture.

The resulting object now works well in 3D as well as inPhotorenderings!

This routine rotatesthe cutout figure to

face the camera

This routine isguaranteed to

position the texture atthe object’s origin

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 259: Cookbook3_1

2.156

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Animated FlagOK, you are thinking this is just a flag. But,

read on! This remarkably clever little objectis supplied by reader Frank Chin of Brunei, anddemonstrates a host of powerful uses of GDL. Inparticular, it includes:

• COONS for making a surface• Using trigonometry to form a wave form• Defining Materials with full details• Defining Texture• Defining location of the texture• User Interface – the full job• Frame based animation

!Flag created by Frank Chin!November, 2000

!Flag Pole fpht=zzyzx RESOL 12 MATERIAL mtl CONE fpht,fpht*0.0075,fpht*0.0025,90,90 ADDZ fpht SPHERE fpht*0.0065 DEL 1

!Flag selectionIF flg="Arg" THEN coun=1IF flg="Austl" THEN coun=2IF flg="Austria" THEN coun=1IF flg="Belgium" THEN coun=3IF flg="Canada" THEN coun=2IF flg="Denmark" THEN coun=4IF flg="Finland" THEN coun=5IF flg="France" THEN coun=1IF flg="Germany" THEN coun=6IF flg="Hungary" THEN coun=1IF flg="Italy" THEN coun=1IF flg="Lithua" THEN coun=2IF flg="Mexico" THEN coun=1IF flg="Moldova" THEN coun=7IF flg="Neth" THEN coun=1IF flg="Norway" THEN coun=8IF flg="Nz" THEN coun=2IF flg="Peru" THEN coun=1IF flg="Russia" THEN coun=1IF flg="Sa" THEN coun=1IF flg="Switz" THEN coun=9IF flg="Uk" THEN coun=2IF flg="Usa" THEN coun=10IF flg="Venez" THEN coun=1 GOSUB coun*10 !Organise parameters fnu=coun*2 !Starting angle for SIN wave

!Wind Speed SelectionIF wspd="Slow" THEN spd=0.75IF wspd="Medium" THEN spd=1IF wspd="Fast" THEN spd=1.5

!Get ready to rumble!ratflg=szx/szyADDZ fpht-0.6*flgL/ratflgADDX 1.1*flgL/2MUL flgL/2,flgL/2*spd,flgL/ratflgflgx=ratx/szx*flgLflgy=raty/szy*flgL/ratflgROTX 90q=(N_+fnu)*40 !Animation index

DEFINE TEXTURE "FLAG-MAP" flg, flgx, flgy, 1,0DEFINE MATERIAL "Flag1" 20,1, 1, 1, ! surface RGB [0.0 .. 1.0]! ambient, diffuse, specular,! transparent coefficients [0.0 .. 1.0]1, 1, 1, 0,0, !shining [0.0 .. 100.0]0, !transparency attenuation[0.0..4.0]0, 0, 0, !specular RGB [0.0 .. 1.0]0, 0, 0, !emission RGB [0.0 .. 1.0]0, !emission attenuation [0.0 .. 65.5]! Fill index, color index, texture index! IND(FILL, "Solid Fill")0, 61, IND(TEXTURE, "FLAG-MAP")

Value list and Parameter boxBuild the Parameter box, and write the Value list, intothe Parameter script. Base the set of choices on a match-ing set of bitmap images that you have scanned orpainted. Note that the bitmap files have the same namesas the choices in the menu.

Place the zzyzxfactor at the top.This disappears,and re-appears inthe settings boxfor the heightfactor. Make themost importantparameter bold.

VALUES "FLG" "Arg", "Austl", "Austria", "Belgium", "Canada", "Denmark", "Finland", "France", "Germany","Hungary", "Italy", "Lithua", "Mexico", "Moldova", "Neth", "Norway", "Nz", "Peru", "Russia", "Sa", "Switz", "Uk", "Usa", "Venez"VALUES "WSPD" "Slow", "Medium", "Fast"

Thesecommands liftand rotate the

flag intoposition and

adjust its size

3D ScriptFirst build the Flagpole. The radii are a function of theheight. Then the country is found from the Value list,setting a small ‘flag’ called coun. Because Frank’sbitmap flag images are all slightly different in size hehas a lot of small adjusters of the aspect ratio whichare stored in little subroutines at the end. It would re-duce the programming workload if the bitmaps wereexactly the same width and height. fnu is an arbitrarystarting angle for the flag at the start of the animation.

The shape of the flag is a SIN-wave form that travelsthrough the flag; the wind speed index will modify theamplitude of the waves. The flag is lifted and rotatedinto position and its size adjusted according to the as-pect ratio.

The clever bit that controls animation is based onN_ (GLOB_FRAME_NR), the global variable that is theindex of the frame that is viewed during the anima-tion. For a still image, the flag exists in a static wave,but if you have a number of cameras and run anflythrough (with ‘Rebuild each Frame’), the flag willappear to wave convincingly.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 260: Cookbook3_1

2.157

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Defining Texture and MaterialThe material for the flag is based on a full DEFINEMATERIAL statement, including the use of a Texture.However, the texture does not yet exist – so we mustmake one. When you make a new material in the op-tions menu, you may have experimented with defin-ing the size and the rotated angle of the texture. ThisDEFINE TEXTURE command is doing the same thingin a single line of code. It deserves a dip into the GDLreference manual to confirm.

There are several way of defining Material, andmethod 20 is by far the most complex, but there is agood example in the manual that can be copied andadapted.

Build a COONS based flagThe flag is defined by its perimeter. The SIN wavestravel from the flag post outwards, and GDL calculatesa smoothing algorithm for the internal faces. The sur-face is broken into triangles as shown, and althoughthe grid looks a bit coarse, it looks perfectly smoothonce you apply a texture and apply smoothing in thephotorender. Frank has made the origin at the centreof the flag, but I would have made it from the uppercorner nearest to the top of the flagpole.

The flag is built flat on the floor. The outline of theflag has been traced in the floor plan with a slab, andthose XY coordinates have been brought into GDL asa cPRISM_. The masking codes have been stripped offand the XYs have had a Z factor added. The Z is basedon the SIN wave; the q-factor (animation index) modi-fies the height at each point. The SIN wave is also ap-plied to the vertical edges of the flag.

Check earlier in the Cookbook for the sequence ofbuilding a COONS. To remind you, you build a list ofthe XYZ locations in sequential order from the cornerpoints 1 to 2, 4 to 3, 1 to 4 and 2 to 3. If you use PUT &GET, the job is made easier.

Precede the COONS with a BODY -1 command.This is always a good idea, but if you are going to mapa texture on to it, it is essential!

BODY -1MATERIAL 'Flag1'!1>2PUT -1.049971, -0.530855, SIN(q+200)*0.1*0.3, -0.771689, -0.501782, SIN(q+160)*0.1*0.4, -0.530451, -0.477571, SIN(q+120)*0.1*0.5, -0.257369, -0.477571, SIN(q+80)*0.1*0.6, 0.002391, -0.500883, SIN(q+40)*0.1*0.8, 0.278803, -0.500883, SIN(q+0)*0.1*1, 0.558544, -0.514204, SIN(q-40)*0.1*1.2, 0.828295, -0.537516, SIN(q-80)*0.1*1.4, 1.078065, -0.570818, SIN(q-120)*0.1*1.9!4>3PUT -1.009465, 0.497912, SIN(q+360)*0.1*0, -0.758049, 0.513212, SIN(q+320)*0.1*0.2, -0.521268, 0.508426, SIN(q+280)*0.1*0.4, -0.250387, 0.487386, SIN(q+240)*0.1*0.6, -0.009750, 0.471607, SIN(q+200)*0.1*0.8, 0.250612, 0.483442, SIN(q+160)*0.1*1, 0.499139, 0.499221, SIN(q+120)*0.1*1.2, 0.755893, 0.472164, SIN(q+80)*0.1*1.4, 0.937848, 0.429705, SIN(q+40)*0.1*1.6

!1>4PUT -1.049971, -0.530855, SIN(q+200)*0.1*0.3, -0.983366, -0.274425, SIN(q+240)*0.1*0.4, -0.960054, 0.005317, SIN(q+280)*0.1*0.4, -0.980189, 0.250694, SIN(q+320)*0.1*0.2, -1.009465, 0.497912, SIN(q+360)*0.1*0!2>3PUT 1.078065, -0.570818, SIN(q-120)*0.1*1.9, 1.011460, -0.274425, SIN(q-80)*0.1*1.6, 1.001469, -0.037977, SIN(q-40)*0.1*1.6, 0.978772, 0.221673, SIN(q+0)*0.1*1.6, 0.937848, 0.429705, SIN(q+40)*0.1*1.6

COONS 9,5,63,GET(NSP) BASE VERT -1.50, -0.75, 0 !origin for texture VERT 1.50, -0.75, 0 !x-direction VERT -1.50, 0.75, 0 !y-direction VERT -1.50, -0.75, 1 !z-direction COOR 2+256, 1, 2, 3, 4BODY -1

DEL 4END:!_____________________________

10:szx=2.25:szy=1.5ratx=3.38:raty=2.25 RETURN20:szx=2.6:szy=1.3ratx=3.9:raty=1.95 RETURN30:szx=1.98:szy=1.71ratx=2.97:raty=2.57 RETURN40:szx=2.12:szy=1.6ratx=3.18:raty=2.4 RETURN50:szx=2.35:szy=1.44ratx=3.53:raty=2.16 RETURN

60:szx=2.37:szy=1.43ratx=3.56:raty=2.15 RETURN70:szx=1.4:szy=0.7ratx=2.1:raty=1.05 RETURN80:szx=2.16:szy=1.57ratx=3.24:raty=2.36 RETURN90:szx=1.84:szy=1.84ratx=2.76:raty=2.76 RETURN100:szx=2.53:szy=1.34ratx=3.80:raty=2.01 RETURN

Mapping the TextureStart with BASE to reset counters. Now define the fourvertices that define where the texture will go. Vert1states the origin (bottom left) of the texture, and fromthat, Vert2 and Vert3 define the direction towards Xand Y; that defines the flat plane of the texture. TheVert4 points to the Z direction, perpendicular to thetexture; in this case the wrapping mode for the textureis ‘box’ which is applied to both sides of the flag sur-face. The COOR command finally applies the texture:2 is for ‘box’ and 256 makes it start from VERT1. Roundoff the whole procedure with a BODY -1.

Comment: Instead of click-click tracing out the flag outlineon plan, I would have defined the planshape as amathematically defined parallelogram, drooping more asthe windspeed dropped.

Wrapping mode here is ‘box’

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 261: Cookbook3_1

2.158

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Values List Script

VALUES 'shape' '1_Single bar','2_Two-bar','3_Three-bar','4_Four-bar','5_Five-bar','6_Six-bar','7_Seven-bar'

Value Lists are the way to make objects very userfriendly. This one is easier to parse because each onestarts with a numerical digit, making it possible to usethe SPLIT command to extract the flag. It only takes asimple “%n” to extract that vital digit.

Bendy Bar! Reinforced Concrete assistant

BENDYBAR is an object that can be put to many uses, but itsprimary use is as reinforcement in concrete. It can be used

for drainage and plumbing, or for neon lettering. It consists of abar that can be bent in six ways, with any degree of curvature,bending angle and twisting angle at each bend.

It is a useful exercise in demonstrating the simple but effec-tive use of ARRAYS, and of making that array visible to the user.It makes what is a complex object vastly more user friendly.

You have to click on this button to make theparameter adopt the form of an Array

The array is now visible to the user, who can enterdata for the bar, such as twist angle, length and sweepwith little difficulty.

User Interface for the FlagThere can be few candidates more suitable for a visualUser interface than a bunch of national flags! The tiledimage of flags is 280x560 which makes it easy to breakinto 3 wide and 8 rows. The names in the index list mustexactly match the names of the flag files and the Value list.In this case, with only a few parameters, the whole objectcan be presented in a user interface box, but you need tojuggle the font and infield box sizes to make everything fitsnugly!

UI_DIALOG "Country Flag"

UI_INFIELD 'FLG',6,16,298,166, 1,'flags_all_ui.jpg',24,8, 92,80,90,60, 1,"Arg", 2,"Austl", 3,"Austria", 4,"Belgium", 5,"Canada", 6,"Denmark", 7,"Finland", 8,"France", 9,"Germany", 10,"Hungary",11,"Italy", 12,"Lithua",13,"Mexico", 14,"Moldova",15,"Neth", 16,"Norway",17,"Nz", 18,"Peru",19,"Russia", 20,"Sa",21,"Switz", 22,"Uk",23,"Usa", 24,"Venez"

UI_STYLE 2,0UI_OUTFIELD 'International',4,210,100,25UI_OUTFIELD 'Flag pole',4,226,100,25UI_STYLE 1,0UI_OUTFIELD 'Copyright Frank Chin',4,244,100,12UI_SEPARATOR 106,186,106,262UI_STYLE 0,0UI_OUTFIELD 'Height of Pole',110,190,78,16UI_OUTFIELD 'Length of flag',110,208,78,16UI_OUTFIELD 'Pole Material',110,226,78,16UI_OUTFIELD 'Wind Speed',110,244,78,16UI_INFIELD 'zzyzx',200,186,102,14UI_INFIELD 'FLGL',200,208,102,14UI_INFIELD 'MTL',202,226,98,18UI_INFIELD 'WSPD',200,244,100,18

©Copyright Frank Chin and David Nicholson-Cole

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 262: Cookbook3_1

2.159

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!2D ScriptPEN pcolHOTSPOT2 0,0

PROJECT2 3,270,2

!Cross hair at startLINE2 br,0,-br,0LINE2 0,br,0,-brARC2 0,0,brad,60,120ARC2 0,0,brad,150,210ARC2 0,0,brad,240,300ARC2 0,0,brad,330,390

With a bit of work, you can build up complexcages like this; the bars get easier and easier toimagine and manipulate with more practice.

!Bendibar- Reinforcing bars!3D ScriptMATERIAL bmatPEN pcolRADIUS brad,brad*2 ROTx rottx ROTy rottyCYLIND leng[1],bradFOR k=1 TO shp-1 ADDz leng[k] ROTz twist[k]ELBOW crad[k],bend[k],brad ADDx crad[k] ROTy bend[k] ADDx -crad[k]CYLIND leng[k+1],brad NEXT kDEL 5*(shp-1) DEL 2 !Remove ROTsEND:!-----------------------

3D ScriptBecause this uses arrays, the final 3D routine is incredibly short. The FOR...NEXT loop does all the work and the value of ‘k’ in each run through theloop decides which section of the rod and which bend will be created. Itend to get one run of it working, and then a second. Once that is proven,you can increase the size of the loop. An engineer advised me that 6 or 7bends in a reinforcing bar would be as many as you could want. But forsomething like neon lettering, there is a case for making the total numbereven larger. The routine follows a similar idea to that used in the first Hand-rail in the Discovery course – simple really. The twist added to the barroutine adds 3 dimensional quality to the bar.

2D ScriptThis tool could be bent into such wierd shapes that it is not practical towork out a 2D script for it. You will have to depend on PROJECT2 for the2D. However, as a bunch of these bars could get mighty confusing, it helpsa great deal to write a script to place cross hairs at the start of the tool, andto a starting Hotspot. It might help to remove Hotspots on the Boundingbox, as these could become a dense forest of hotspots when you built areinforcement cage.

!Bendibar- Reinforcing bars!Master Script

DIM leng[7],crad[6],twist[6],bend[6]

!This is the long hard!way to parse a value listIF shape='1_Single bar' THEN shp=1IF shape='2_Two-bar' THEN shp=2IF shape='3_Three-bar' THEN shp=3IF shape='4_Four-bar' THEN shp=4IF shape='5_Five-bar' THEN shp=5IF shape='6_Six-bar' THEN shp=6IF shape='7_Seven-bar' THEN shp=7

!If all you want is a flag!then use SPLIT() insteadn=SPLIT(shape,"%n",shp)

!Parameter checks brad=diam/2000 !Bar radius br=brad*1.5

FOR k=1 TO shp-1IF crad[k]<brad THENcrad[k]=bradIF bend[k]<0 THEN twist[k]=twist[k]+180 bend[k]=ABS(bend[k]) ENDIFIF leng[k]<0 THEN leng[k]=0 NEXT kIF leng[shp]<0 THEN leng[6]=0

This Routine parses the Value List to work outthe user’s requirements. These can be convertedto a number. You can either use a series of IFstatements, or a single SPLIT command canextract the right figures in a single hit.

This routine does some error checking –converting to metres, looking for minusquantities and other user errors.

Master ScriptThe primary job is to parse theValue List. I have shown twomethods of doing it. The pa-rameter checks build in anumber of safeguards, in caseof problems such as the curveradius being smaller than thetube radius. I usually write theobject first, get it working, thendiscover the things that canupset it with user-abuse, andwrite in safeguard routines tocatch the snags.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 263: Cookbook3_1

2.160

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Curvy Roof!Name:Curvy Roof!Master Script

!Raw Data for points!Stolen from a POLY2B (Fill)PUT 0.0, 0.0, 1, !pt 1 0.350873, 0.0, 1, 0.589629, 0.057864, 1, 0.851114, 0.158436, 1, 1.092485, 0.299235, 1, 1.273514, 0.480264, 1, 1.434428, 0.661292, 1, 1.555114, 0.822206, 1, 1.675799, 1.023349, 1, 1.765522, 1.247996, 1, 1.778437, 1.421734, 1, 1.789253, 1.611861, 1, 1.789253, 1.785883, 1, 1.789253, 1.991546, 1, 1.789253, 2.213029, 1, 1.789253, 2.347501, 1, 1.789253, 2.529433, 1, 1.789253, 2.735096, 1, 1.789253, 3.042829, 1,!pt 2 5.665204, 3.042829, 1,!pt 3 5.665204, 2.236759, 1, 5.665204, 1.690962, 1, 5.665204, 1.010693, 1, 5.665204, 0.354154, 1, 5.665204,-0.262834, 1, 5.665204,-0.927283, 1, 5.665204,-1.512631, 1, 5.665204,-2.153349, 1, 5.586103,-2.738697, 1, 5.245969,-3.284494, 1, 4.668531,-3.648359, 1, 4.027812,-3.759101, 1, 3.355453,-3.759101, 1, 2.714735,-3.759101, 1, 2.035076,-3.759101, 1, 1.377927,-3.759101, 1, 0.737209,-3.759101, 1, 0.0, -3.759101, -1 !pt 4

!Defining the arrayDIM x[50],y[50]FOR k = 1 to 38x[k]=GET(1)y[k]=GET(1)nul=GET(1) !throw away all 1’sNEXT k

p1=1 !Array index of Point 1p2=19 !Array index of Point 2p3=20 !Array index of Point 3p4=38 !Array index of Point 4

3D ScriptFirst the main roof surface roof is to be made with a COONSmesh. For this it is important that the number of pointsalong the ridge and the eaves are the same. Then a numberof roofing welts are to be drawn that join the eaves to theverge (using TUBE). Then the vertical wall along the ridge,using EXTRUDE. Then, the same technique to do the fas-cia. Finally, a gutter section (defined by TUBE) must followthe eaves fascia around the curve. Note that TUBE needsphantom points before start and after the end of each sec-tion.

THIS LOOKS very complex at first sight – but if you are a trueVoyager, you will have a go at trying something like it.

The exercise includes:• Arrays, to store locations• COONS: form a surface from a profile• TUBE: form a gutter following a complex path• EXTRUDE and POLY from an array• PUT & GET as if it was going out of fashion!

The first version of this was written by one of my students, AlfredMan in AC 5.1, and was part of a model we did for part of the roof ofan office refurbishment scheme in North Notts. I have extensivelyupdated it for AC 6.X. This is a solid that could not be created by anyof the solids in the GDL vocabulary – so it must be built from a seriesof Surfaces for top, sides and bottom, made by GDL. Because theyare all repeating the same set of XY locations, use Arrays.

ProcedureFirst a hand drawn drawing of the required roof was scanned ingreyscale – then pulled into ArchiCAD. A Fill is clicked around theoutline, making sure the clicks coincide with roofing welts. The Fillis dragged into the 2D script window of a new object, as a POLY2B.The XY list from the fill is dragged into the Master Script (then therest of the fill thrown away). This seems like a cheat, but it’s a verylaboursaving way to get XY locations established and more accu-rately than any other method. If you make the Fill to site on the mainorigin, then you get a nice clean set of coordinates (without an offsetto consider.)

Master ScriptThe idea is to PUT all the XY points (and the point status code) fromthe Fill into memory, then to flow them into Arrays for X and for Y,discarding the status codes along the way; then to identify the mid-dle and end points, to help build our COONs and other shapes. Be-fore you build the array, you have to use the DIM command to pre-pare for the array to be filled – use a number that is Equal to orLarger than the number you intend to put in there. We have 38 points,so a round number of 50 will do for now. Then a For.. Next Loopdoes the hard work.

ParametersThe size on plan is determined by the Fill, so A and B are not used,but Heights are parametric, as are the Materials and Gutter details.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 264: Cookbook3_1

2.161

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Curvy Roof!first written:AlfMan Sept98!totally rewritten Jan2000!by DNC

PEN L_!Array is in the Master Script

!Drawing the roofMATERIAL rmat!Data for Roof Coons!1 to 2FOR k = p1 to p2 PUT x[k],y[k],hit2NEXT k

!4 to 3FOR k = p4 to p3 step -1 PUT x[k],y[k],hit1NEXT k

!1 to 4 PUT x[p1],y[p1],hit2 PUT x[p4],y[p4],hit1

!2 to 3 PUT x[p2],y[p2],hit2 PUT x[p3],y[p3],hit1

COONS 19,2,63, GET(NSP)

!Drawing the end fasciaMATERIAL wmatPLANE 4, x[p1],y[p1],0, !Point 1 x[p1],y[p1],hit2, ! x[p4],y[p4],hit1, ! x[p4],y[p4],0 !Point 4

!Drawing the other end fasciaPLANE 4, x[p2],y[p2],0, !Point 2 x[p2],y[p2],hit2, ! x[p3],y[p3],hit1, ! x[p3],y[p3],0 !Point 3

!Drawing the inside curveMATERIAL wmatFOR k=p1 TO p2 PUT x[k],y[k],1 NEXT kEXTRUDE NSP/3,0,0,hit2,0, GET(NSP)

!Drawing the outside curveMATERIAL wmatFOR k=p3 TO p4 PUT x[k],y[k],1 NEXT kEXTRUDE NSP/3,0,0,hit1,0, GET(NSP)

!Drawing the CeilingMATERIAL cmatFOR k=p1 TO p4 PUT x[k],y[k] NEXT k

POLY NSP/2, GET(NSP)

!Drawing the roofing weltsMATERIAL rmatFOR k = p1 to p2 PUT 0,0,1000,0 !1st Phantom Point PUT x[k],y[k],hit2,0 PUT x[p4+1-k],y[p4+1-k],hit1,0 PUT 0,0,-1000,0 !last Phantom Pt NEXT k

numb = NSP/16FOR K=1 TO numb TUBE 5,2+2,63, -0.03,0.00,0, !Sectionpoints -0.03,0.05,0, 0.03,0.05,0, 0.03,0.00,0, -0.03,0.00,0, GET(16) !PathpointsNEXT k

!Drawing the gutterMATERIAL gmat!PathpointsPUT x[p4]-0.01,y[p4],0,0!1st Phant.PtFOR k = p4 to p3 STEP -1 PUT x[k],y[k],0,0 NEXT kPUT x[p3],y[p3]+0.01,0,0!Last Phant.Pt

ADDz galtBODY -1TUBE 9,NSP/4,63, 0, 0,0, !Sectionpoints 0, ghit,0, -gthk,ghit,0, -gthk,gthk,0, -gdep+gthk,gthk,0, -gdep+gthk,ghit,0, -gdep,ghit,0, -gdep,0, 0, 0, 0, 0, GET(NSP) !PathpointsBODY -1DEL 1

!Curvy Roof!2D ScriptHOTSPOT2 0,0PROJECT2 3,270,2

FOR k=p1 TO p4HOTSPOT2 x[k],y[k] NEXT k

IF shonum THENDEFINE STYLE 'CR_txt' 'Arial', 2*gdep*1000/A_,3,1SET STYLE 'CR_txt'TEXT2 x[p1],y[p1],1TEXT2 x[p2],y[p2],2TEXT2 x[p3],y[p3],3TEXT2 x[p4],y[p4],4ENDIF

The 1-2-3-4 numberingconvention for the COONs

is shown in the 2Ddisplay. See the pages onmaking COONs and the

Catamaran exercise.Those exercises used real

values for the COONS,these ones get the values

from the Array, and PUTthem into memory.

All of these forms aremade by plucking out

the appropriatenumbers from the

Array that was builtin the Master Script

2D Scriptis used here to place Hotspots at all the welt ends,and to illustrate the numbering convention for theCOONS that forms the roof surface. Project 2 is usedto form the roof because there are only 2 on thebuilding, but for hardened GDL users with morespace than I have on the page, it’s easy to write aPOLY2 routine for the outline and some LINE2 rou-tines for the welts, using the same techniques as inthe 3d script.

CommentWhy doesn’t this use Subroutines? Well, there areno cursor movements until the Gutter – all com-mands use precise XYZ locations. Therefore eachroutine is tidily modular already.

Byzanti
Highlight
Page 265: Cookbook3_1

2.162

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

3D View: Here is the finished solid looking roof, built from 6surfaces, plus welts and gutter.

Did I hear you ask? Why cannot this all be done with the wonder-ful MASS command that combines Surface and Solid building soeffectively? – well it ALMOST succeeds – except for the flattenedareas around the curve.

!Do everything in!one go! 3DScriptFOR k=p1 TO p2 PUT x[k],y[k],hit2,15 NEXT kFOR k=p3 TO p4 PUT x[k],y[k],hit1,15 NEXT kPUT x[p1],y[p1],hit2,-1

MASS rmat,cmat,wmat, NSP/4,0,127,0, GET(NSP)

Flat area caused byMASS connecting points

unexpectedly

!======STRING CONVERSION========RECT2 0,0,1,0.5 !something visible in the plan

! Do it! ParVar="oLeG sHmIdT" !<-- INPUT parameter ResVar="" !Initialise as a stringGOSUB 1010 ! UpperTestString="UPPER: "+ResVar+'\n'

GOSUB 1020 ! LowerTestString=TestString+"LOWER: "+ResVar+'\n'

GOSUB 1030 ! Words UpperTestString=TestString+"WORDS UPPER: "+ResVar+'\n'

GOSUB 1040 ! First char upperTestString=TestString+"FIRST UPPER: "+ResVar+'\n'

PRINT TestString

END: ! =======================

1010: ! === UPPER FUNCTION === CvtMode=0 goto 1000

1020: ! === LOWER FUNCTION === CvtMode=1 goto 1000

1030: ! === WORDS UPPER === CvtMode=2 goto 1000

1040: ! === FIRST CHAR UPPER === CvtMode=3 GOTO 1000

1000:!--- CONVERTING FUNCTION ---!-- Parameters: ParVar (String type)!CvtMode 0-Upper,1-Lower,2-Word Upper,3-First Upper!-- Result: ResVar (String type)DIM AlphaBet[2]AlphaBet[1]="abcdefghijklmnopqrstuvwxyz"AlphaBet[2]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"

CvtFlag=CvtMode<>1 ResVar="" CvtLen=STRLEN(ParVar) FOR CvtCnt=1 TO CvtLen CvtChar=STRSUB(ParVar,CvtCnt,1) CvtPos=STRSTR(AlphaBet[2-CvtFlag],CvtChar) IF CvtPos THEN CvtChar=STRSUB(AlphaBet[CvtFlag+1],CvtPos,1) ENDIF ResVar=ResVar+CvtChar IF CvtMode=2 THEN CvtFlag=(CvtChar=' ') IF CvtMode=3 THEN CvtFlag=0 NEXT CvtCntRETURN

String ParsingGDL by Oleg Shmidt

IF there is one thing that cooks the brain in GDL, it’sstruggling with String Parsing. This may be needed

if you are bringing in text from a datafile and trying toorganise it into something like labels, or a grid for aschedule or a title block. Oleg has supplied this littletest piece. It’s not an object in its own right, it’s a sub-routine that you could copy and paste into another ob-ject. All you have to do it pass it the 2 parameters ParVarand CvtMode, and it creates a new string with the UP-

PER and lower case correctly displayed. The examplehere displays the possibilities in a warning dialog box.This subroutine could be adapted and used to help infilling out project title boxes, or a schedule in a grid.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 266: Cookbook3_1

2.163

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

String Wrappingby Laurent Godel <[email protected]>

THIS is a Text Wrapping routine. It may be helpfulif you are bringing in text from a datafile and need

it to fit correctly into a box. It wraps strings of any length(including ones with numerals) to a desired characterwidth. It works on any string (apparently), except that

!SUBROUTINE100: !Extract first word

spacepos=STRSTR(stringval," ")doublespace=STRSTR(stringval," ")

IF spacepos>1 THENword=STRSUB(stringval,1,spacepos-1)wordlen=STRLEN(word)IF wordlen> charwrap THEN

PRINT "Too small value for characterwrapping- please increase!"

ENDENDIFcumulen=cumulen+wordlen+1stringval= STRSUB(stringval,STRLEN(word)+2,

STRLEN(stringval)-STRLEN(word)-1)ELSE

word=stringvalENDIFRETURN

!******End of Text wrapping subroutine! Laurent Godel, 'gdlguru', GDLa!***Maker of the GDL Calculator ***! available for FREE download at:!http://personal.ibernet.com/personal/gdl/!---------------------------------------------

!*******Text wrapping subroutine********

!STRING TO BE WRAPPEDstringval="Sometimes numerical values like5'-0'' and 10'-0'' did not make it inside theold version."

!NUMBER OF CHARACTERS ALLOWED IN ONE LINEcharwrap=24

!FONT HEIGHT IN MMMfonth=2linespace=2*fonth*A_/1000 !Line spacing

!PARAMETER DEFINITION & INITIALIZEDEFINE STYLE "TEXT" "ARIAL",2,1,0SET STYLE "TEXT"word=" "Stringtemp=""

!SCRIPTGOSUB 100: !extract first wordStringtemp=word

WHILE spacepos>0 AND doublespace=0 DOIF cumulen< charwrap THEN GOSUB 100 IF spacepos>0 THEN

oldstringtemp=StringtempStringtemp=Stringtemp+" "+wordENDIF

ELSETEXT2 0,0,oldstringtempcumulen=STRLEN(word)Stringtemp=wordADD2 0,-linespace

ENDIFENDWHILE

!Display last lineTEXT2 0,0,stringtemp+" "+word

END!-------------------------------

!Hider!Idea by Bert Nijs, GDL by DNC

bpen=GLOB_DRAWING_BGD_PENIF sholin THEN PEN pcol ELSE PEN bpen

DEFINE FILL 'nofil' 0,0,0,0,0, 0,0,0,0,0,0 !eleven zeroesSET FILL 'nofil'

HOTSPOT2 0,0HOTSPOT2 A,0HOTSPOT2 A,BHOTSPOT2 0,B

POLY2_B 5,2+sholin,bpen,bpen, 0,0,1, A,0,1, A,B,1, 0,B,1, 0,0,-1

Hider‘Whiteout for ArchiCAD users’

H IDER is a little 2D Utility that comes from anidea by Bert Nijs of Belgium, and GDL’d by DNC.

It is a stretchy 2D Rectangle that copies the BackgroundPEN colour for its outline and fill and can be maneovredover your drawing when you want to hide somethingtemporarily. (Graphisoft, why aren’t there ‘Hide Ob-ject’/’Unhide All’ commands, I have asked for them forlong enough).

Whatever colour your background is, it works, us-ing the Global Variable GLOB_DRAWING_BGD_PEN!Make sure you ‘Bring to front’, and that you ‘Use Sym-bol Pen colours’. With a bit more work on your part,you could provide a Value list and a choice of Circular,Hex, Oval and Triangular stretchy patches, each withdistinctive hotspot positions.

if it finds two contiguous spaces it will stop parsing. Ihope this can be of some use to someone...

This is not an object in it’s own right, it’s a routinethat you could paste into another object that has tohandle text.

If you define your own fillpattern, you can be sure it willwork in any language version

of ArchiCAD

This is a ‘Framefill’ switch thatenables the Edgelines on or off

Masking code for Edgelines arealways ON, subject to Framefill

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 267: Cookbook3_1

2.164

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

3D ScriptThe script is done without subroutines. If you wantthe arch to be part of a much larger object, for exam-ple Sydney Harbour bridge, or the Golden Gate bridge(in which you invert the arch to make a cable), thenyou will want to call it as a macro (using CALL); or, inthis case, you can copy and paste the text from hereinto the larger object as one subroutine. This means itis written without line numbers, or subroutines – be-cause the whole thing could be a subroutine in thelarger object.

If you did use it as a subroutine, you would have topass the parameters to it (bmat, nstep, twid, tdep etc.etc.). If you only want one type of arch, you coul dmoreeasily, copy and paste the relevant routine and rebuildit yourself for the specific type of arch.

Foot cuttingThe CUTPLANE routines are to give you three ways ofcutting the feet of the arch to help it fit better into alarger model. This is no problem for waveform arches,but for the circular arch, you have to use some IF...ENDIF logic to avoid cutting if the arch sweeps throughmore than 180o. Finally one Cutplane action (4) allowsyou to have only half an arch or a cable.

Arches and Waves!

Parameters: This object is stretchy in plan so it usesA. Height is based on zzyzx, to allow vertical stretch-ing of the 3D arch. The cutting styles determine howthe legs of the arch will be treated. The number of stepsnstep will define the smoothness of curvature of thearc of the arch itself, whereas tres determines thesmoothness of the actual tubular surface, if circular.

Planning: The Circular and Elliptical and Fillet archare to be drawn from a notional centre, using angularsteps – the X and Z locations are worked out aroundthat centre. The SIN and Parabolic arch are drawn sym-metrically around the centre, from an X-value of-span/2 to +span/2, with distance based steps.

IN THE LONG Handrail exercise, you were shownhow to use the TUBE command to follow a long

pathway. I called this ‘Swing the Cat!’ which is to dowith swinging cats, not with punishment. However,some of this maths might put you off and you wouldprefer the punishment. Circular arcs are very easy, andif you don’t like maths, you can use ELBOW. It’s theothers that may cause you pain.

However, there is scarcely an arch in real architec-ture that uses a perfectly round arc, except in the Ro-manesque style, or in situations where there is somereinforcement to prevent collapse. Round arches are

This exercise is useful for:• Building Arches, of course• Using PUT and GET and TUBE• Exploring Mathematics to create more authentic form

unsafe. Engineering arches, shells and cables are morelikely to use the ‘funicular line’. The Catalan architect,Antonio Gaudi used hanging chains to calculate theprofile of his arches and vaults to ensure that therewas axial compression through the arch. For this youneed to know how to make a Parabolic arch whichclosely follows the funicular line, or a SIN wave whichis also close to a parabola.

I have worked out my own formulae for derivingSin wave and Parabolic forms, when you only knowthe span and height of the arch. See the Maths Primerfor more detail.

!BOWARCH - Tube Arch Macro!Demonstrates different mathematical forms!Master Script

!Stretchy variables!Use span and higt in case the arch!is a macro and A and zzyzx are in usespan=Ahigt=zzyzx

!Number of StepsIF nstep< 4 THEN nstep=4IF nstep>36 THEN nstep=36

!Value listsIF arcshap='Circular' THEN arcshp=0IF arcshap='SIN Wave' THEN arcshp=1IF arcshap='Parabola' THEN arcshp=2IF arcshap='Ellipse' THEN arcshp=3IF arcshap='Gothic' THEN arcshp=4IF arcshap='Fillet' THEN arcshp=5

!Neat way to parse the Tube profile x=SPLIT(tubetyp,'%n',ttyp)

!Neat way to parse the cutting style x=SPLIT(cutstyl,'%n',cutstl)

The arch shape is parsed in the normal way, but theSPLIT command achieves the same result in one line,providing that the Value list choice begins with anumeral. Write Value list in Parameter script.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 268: Cookbook3_1

2.165

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Calculating the PathwaysThe Formulae for Circular, Sin, Parabolic, Ellipticaland Gothic arches are first explained in the MathsPrimer.

Because we are making a Tube, all these routines haveto start one point earlier and end one point later thanthe real end of the arch – these are the ‘phantom points’that you have to define for a TUBE command. Y is al-ways Zero, as this is an Arch. If you were doing a longhandrail or tent edge, you would use the routine tocalculate Y, and have a value of zero for Z.

• The Circular routine is a standard ‘swing the cat’ rou-tine of defining X and Z by using radius, SIN and COSof the angle.

• The SIN routine goes by X-distance, from zero tothe equivalent distance of 180 degrees (full span), cal-culating the height as it goes.

With a bit of furtherdevelopment, this arch can bedeveloped into a truly complexstructure!

• The Parabolic routine goes by X-distance, from mi-nus half the span to plus half the span, calculating theheight as it goes.

• The Elliptical routine is similar to the Circular, butassumes a 180˚ sweep around a centre that is level withthe feet of the arch – as it swings, it multiplies the heightby the aspect ratio, height*2/span.

• The Gothic routine works out the theoretical centreand radius, and describes an arc up to the centre, andthen the same arc in reverse down to the opposite side.

• The Fillet arch assumes that there is a hypotheticaltriangle, and the head of the triangle is filled in with atangential curved line. This requires logical thinking.

In doing this, we work out the X, Y, and Z of eachpoint along the Arch, and ‘PUT’ them to the memorybuffer. By the way, the pathpoints include a Zero atthe end of each line for ‘twist angle’. Then, the TUBEcommand GETS the section and pathway points in onegulp.

The 0.1 in each path calculation is a deliberate over-run to ensure that arch doesn’t stop short of full length.As this is usually for the calculation of the phantompoint it does not affect the visible part of the arch.

For the final construction, it is almost insultinglyeasy. A very easy TUBE command, followed by a rou-tine to provide the CUTENDs for the feet.

People think that SIN waves aremore curvaceous, but

surprisingly, it is more pointy thanthe pure Parabolic arch form.

If you want a hanging cable – fora bridge – use the arch upside

down. Either tilt it round X or Y tomake it hang. If it hangs at an

angle, then juggle the tilts aroundX and Y.

2D ScriptThe arch could be represented as a Project2. Here theemphasis is on defining text style in the 2D script. Whenthere is a variety of messages that could be written, it’sbest to prepare the text string first and then deliver itto the TEXT2 command.

Fillet Arch:

rounding the triangleEllipse Arch:

Distorted circle

Parabola:

funicular arch

form

Gothic Arch:

2 circular

segments

Theoretical

high point

Theoretical

gothic arch

centre

Sin Wave:

based on angle from

-180 to 180˚

Circular Arch:

based on Chord

and Bulge

VALUES 'arcshap' 'Circular','SIN Wave', 'Parabola','Ellipse', 'Gothic','Fillet'VALUES 'tubetyp' '0-Circular','1-Rectangular'VALUES 'cutstyl' '0-No cuts','1-Vertical', '2-Horizontal', '3-Vert & Horiz','4-Half cut'

!BOWARCH - Tube Arch Macro!2D Script

!PROJECT2 3,270,2

HOTSPOT2 0,0HOTSPOT2 span/2,0HOTSPOT2 -span/2,0RECT2 -span/2,-twid/2, span/2, twid/2

IF fonthit THEN !user requires textIF arcshp=0 THEN arcshapstr="Arch"IF arcshp=1 THEN arcshapstr="SIN Arch"IF arcshp=2 THEN arcshapstr="Parabola"IF arcshp=3 THEN arcshapstr="Ellipse"IF arcshp=4 THEN arcshapstr="Gothic"IF arcshp=5 THEN arcshapstr="Fillet"

DEFINE STYLE "arctxt" 'Arial',fonthit,7,1STYLE "arctxt"TEXT2 -span/2,0,arcshapstrENDIF

Keep this handyfor testing

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 269: Cookbook3_1

2.166

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Cutends, thisis a useful

routine that Iuse every time

I have anumber of

CUTPLANEs.

!Put pathway values to memory, ELLIPTICALIF arcshp=3 THEN stan=180/nstep !Stepping angleFOR k=-stan*ct TO 180+stan*ct+0.1 STEP stan x= (span/2)*COS(k) z= (span/2)*SIN(k)*higt/(span/2) PUT x,0,z,0 NEXT k ENDIF

!Put pathway values to memory, GOTHICIF arcshp=4 THEN sp = higt*2 !'span' of the curve bg = span/2 !'bulg' for the arch angl =2*(90-ATN((sp/2)/bg))!Half angle brad =(sp/2)/SIN(angl) !Radius stan =angl/INT((nstep+2)/2)!Stepping angle

!Left side of archFOR k=-stan*ct TO angl+0.1 STEP stan x=-span/2+brad-brad*COS(k) z= brad*SIN(k) PUT x,0,z,0 NEXT k

!Right side of archFOR k=angl-sta TO -stan*ct-0.1 STEP -stan x= span/2-brad+brad*COS(k) z= brad*SIN(k) PUT x,0,z,0 NEXT k ENDIF

!Put pathway values to memory, FILLETIF arcshp=5 THEN!Span of fillet is half span (arbitrary) sp =span/2 !span of bend angl=ATN(higt/(span/2)) !angle of legs brad=(span/4)/SIN(angl) !Radius of curve bulg=(sp/2)/TAN(90-angl/2) !bulge of curv stds=angl*2/nstep !angular stepsPUT -span*0.75,0,-(span/4)*TAN(angl),0,!Phant -span/2,0,0, 0, -span/4,0,(span/4)*TAN(angl),0

FOR k=-angl+stds TO angl-stds+0.1 STEP stds x=brad*SIN(k) z=(span/4)*TAN(angl)+bulg-brad+brad*COS(k) PUT x,0,z,0 NEXT k

PUT span/4,0,(span/4)*TAN(angl),0, span/2,0,0, 0, span*0.75,0,-(span/4)*TAN(angl),0!PhantENDIF

!The 0.1 is a deliberate over-run!--------------------------------------------

!Start building the actual ArchRESOL tres!Enables Elliptical section ProfileMULy twid/tdep

!This is the Arch! TUBE np,(NSP-np*3)/4,63,GET(NSP)DEL 1

IF kut THEN FOR k=1 TO kut:CUTEND: NEXT k ENDIF DEL 2 !Undo Tilts

!BOWARCH - Tube Arch Macro!Demonstrates different mathematical forms!3D Script

ROTx tiltx: ROTy tilty !Tilt or rotate

!--------- Cutplane routine -------------- MATERIAL bmat PEN pcol!Specify before cuttingIF arcshp=0 AND higt>=span/2 THEN IF cutstl=1 OR cutstl=3 THEN cutstl=cutstl-1 ENDIF ENDIF

!Vertical CutIF cutstl=1 OR cutstl=3 THEN ADDx -span/2 ROTy -90 CUTPLANE : kut=kut+1 DEL 2 ADDx span/2 ROTy 90 CUTPLANE : kut=kut+1 DEL 2ENDIF

!Horizontal CutIF cutstl=2 OR cutstl=3 THEN CUTPLANE 180: kut=kut+1 ENDIF

!Half CutIF cutstl=4 THEN CUTPLANE 180 :kut=kut+1 ROTy 90 CUTPLANE: kut=kut+1 DEL 1 ENDIF

ct=1+cutstl !cutting flag

!---------------------------------------!PUT Sectional Values to MemoryIF ttyp THEN !Square Section PUT tdep/2, tdep/2,0, -tdep/2, tdep/2,0, -tdep/2,-tdep/2,0, tdep/2,-tdep/2,0 ELSE !Round Section PUT 0,0,901, tdep/2,360,4001 ENDIF

np=NSP/3 !Number of points

!Put all pathway values to memory, CIRCULARIF arcshp=0 THEN!Formulae for Circle Geometry angl = 2*(90-ATN((span/2)/higt))!Half angle brad = (span/2)/SIN(angl) !Radius stan = (angl*2)/nstep !Stepping angleFOR k=90-angl-stan*ct TO 90+angl+stan*ct+0.1STEP stan PUT brad*COS(k),0,brad*SIN(k)+higt-brad,0 NEXT k ENDIF

!Put pathway values to memory, SIN waveIF arcshp=1 THEN!Formula is y=height*SIN(X*180/span) stan = 180/nstep !Stepping angleFOR k=-stan*ct TO 180+stan*ct+0.1 STEP stan PUT span*k/180-span/2,0,higt*SIN(k),0 NEXT k ENDIF

!Put pathway values to memory, ParabolaIF arcshp=2 THEN!Formula is y=height-(4*height/(span^2))*X^2 stds= span/nstep !Stepping distanceFOR k=-span/2-stds*ct TO span/2+stds*ct+0.1STEP stds PUT k,0,higt-(4*higt/(span^2))*k^2,0 NEXT k ENDIF

kut – Thistechnique of using‘kut’ to record the

number ofcutplanes means

that you know howmany CUTENDs to

do. Material mustbe specified before

you issue Cutplanecommands.

Store the outlineof the tube section

in the memorybuffer using PUT,

and rememberthe number orstored points.

ct is a flag to make thearch longer if its to be

cut

End NoteAny of these arches could be made without maths byclicking out the pathway in ArchiCAD using a Fill,dragging it to GDL to extract the pathway andmaking the Arch from those points. All you need toknow is how to define the TUBE profile. But it willnot be accurately stretchy or parametric.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 270: Cookbook3_1

2.167

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Multi-Lingual Object!Using VALUES List in ArchiCAD 6.0!Using Parameter Script in ArchiCAD 6.5

VALUES "language" "English", "Deutsch", "Francais"IF language="English" THENVALUES "object" "Table","Chair","Stool"VALUES "shape" "Round","Rectangular"ENDIFIF language="Deutsch" THENVALUES "object" "Tisch","Stuhl","Hocker"VALUES "shape" "Rund","Viereckig"ENDIFIF language="Francais" THENVALUES "object" "Table","Chaise","Tabouret"VALUES "shape" "Rond","Carré"ENDIF

!Multi-Lingual Object!Master Script

IF language="English" THEN lingo=1IF language="Deutsch" THEN lingo=2IF language="Francais" THEN lingo=3IF lingo=1 THEN !English IF object="Table" THEN thing=1 IF object="Chair" THEN thing=2 IF object="Stool" THEN thing=3 IF shape="Round" THEN sqroun=0 ELSE sqroun=1 ENDIF

IF lingo=2 THEN !Deutsch IF object="Tisch" THEN thing=1 IF object="Stuhl" THEN thing=2 IF object="Hocker" THEN thing=3 IF shape="Rund" THEN sqroun=0 ELSE sqroun=1 ENDIF

IF lingo=3 THEN !Francais IF object="Table" THEN thing=1 IF object="Chaise" THEN thing=2 IF object="Tabouret" THEN thing=3 IF shape="Rond" THEN sqroun=0 ELSE sqroun=1 ENDIF

MATERIAL SYMB_MATPEN SYMB_VIEW_PENRESOL 12

The students I work with at Nottingham have given me theappropriate words in Spanish, Portuguese, Swahili, Gujerati,Malay, Portuguese, Arabic, and any number of Nigerian andChinese Dialects. But lets stick to just three here!!

Surprisingly, the Value list is capable of using IF state-ments. You use the Master script to parse the resultsof the user’s choice, and create parameters. InArchiCAD 6.5, the Value list goes into the ParameterScript.

By the way, youdo not need to

convert thechoices to

numbers, but itmakes the 2D

and 3Dscripting tidier.

WITH earlier versions of GDL, I long complainedthat it needed scriptable Pop-Up menus to se-

lect options. I also argued that you needed a way toinform both the 2D and the 3D scripts of commonlyused preambles, especially if there are complex cal-culation and error checking routines that both mustgo through.

Well you now have both of these with ArchiCAD6.x. Popups can be created with the VALUES com-mand. The other problem is solved with the MasterScript in which you write the common preambles.

This Multilingual object is an illustration of oneway to use IF statements in VALUE lists to cover avariety of languages within the same object. Threeobjects, in three languages are chosen. The actualTable, Chair and Stool used in the example are ex-tremely simple; the actual form of them is not theissue – the exercise focuses on the Nesting of IFstatements in the Value List Script to achieve therequired result.

Parameters: It is still not possible to script the namesand descriptions of the Parameters, but in this case,the words Object and Form are common to Eng-lish, German and French (with insignificant spellingvariations). The details in each language can be madeto popup.

In the Parameter script popup, write your Val-ues List. The actual choices are separated by com-mas.

Multilingual Object

No ‘On Error’ is an error: FIX!!BASIC used to have an ON ERROR command: when an er-ror occured, the programmer could plan for the executionto move on, or print a warning. GDL has been around foralmost 2 decades and still doesn’t support ON ERROR!Shame!

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 271: Cookbook3_1

2.168

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Multi-Lingual Object -3D

!3D form is kept very simple! - to focus on the purpose! - the use of! - branching Value lists.

squilind=400GOSUB thing

END:!___________________

1:!Table,Tisch!Table Top ADDz 0.70 h=0.03: w=A: d=B: GOSUB squilind DEL 1

!Legs FOR k=1 TO 4 ROTz 90*k ADD B/2-0.1,A/2-0.1,0 h=0.7:w=0.1:d=0.1:r=0.05 IF sqroun THEN GOSUB squilind ELSE CYLIND h,r ENDIF DEL 2 NEXT kRETURN

2:!Chair,Chaise,Stuhl!SeatADDz 0.5 h=0.03: w=0.45: d=0.45: GOSUB squilindDEL 1

!Legs FOR k=1 TO 4 ROTz 90*k ADD 0.18,0.18,0 h=0.5:w=0.05:d=0.05:r=0.03 IF sqroun THEN GOSUB squilind ELSE CYLIND h,r ENDIF DEL 2 NEXT k

!Back ADD -0.18,0.18,0.5 ROTx -5 IF sqroun THEN GOSUB squilind ADDx 0.36 GOSUB squilind ELSE CYLIND h,r ADDx 0.36 CYLIND h,r ENDIF DEL 3

ADD 0,0.18,0.80 ROTx 85 w=0.45:d=0.35:h=0.03 GOSUB squilind DEL 2RETURN

3:!Stool,Tabouret,Hocker ADDz 0.4 w=0.3:d=0.25:h=0.03:r=0.17 IF sqroun THEN GOSUB Squilind ELSE CONE h,r,r*0.9,90,90 ENDIF DEL 1

!Legs CUTPLANE 180 FOR k=1 TO 4 ROTz 90*k ADD 0.12,0.12,0 ROT -0.01,-0.01,0.4,180 h=0.4:w=0.03:d=0.03:r=0.02 IF sqroun THEN GOSUB squilind ELSE CYLIND h,r ENDIF DEL 3 NEXT k CUTENDRETURN

400:!SquilinderIF sqroun THEN EXTRUDE 4,0,0,h,63, -w/2,-d/2,1, w/2,-d/2,1, w/2, d/2,1, -w/2, d/2,1ELSE EXTRUDE 10,0,0,h,63, -w/2, 0, 1, -w/2, d*2/5, 1, -w*2/5, d/2, 1001, w*2/5, d/2, 1, w/2, d*2/5, 1001, w/2, -d*2/5,1, w*2/5, -d/2, 1001, -w*2/5, -d/2, 1, -w/2, -d*2/5,1001, -w/2, 0, 1 ENDIFRETURN

There are several other thingsdemonstrated here.

• Using variables as names for sub-routines (‘thing’ and ‘squilinder’.)

• ‘Passing Parameters’ to a stand-ardised subroutine; this saves a lotof repetitive typing.

• Using EXTRUDE when PRISMwould normally do just as well. Thisis because, with a fully 2D scriptedobject it is possible to copy the 3Dlist of XY locations and paste theminto a POLY2_ command.

• The use of the ROT command –whereby you can do a rotation in 3Ddimensions in a single line, by stat-ing an X,Y,Z location to define anaxis of rotation.

!3D Command EXTRUDE 10,0,0,h,63, -w/2, 0, 1, -w/2, d*2/5, 1, -w*2/5, d/2, 1001, w*2/5, d/2, 1, w/2, d*2/5, 1001, w/2, -d*2/5,1, w*2/5, -d/2, 1001, -w*2/5, -d/2, 1, -w/2, -d*2/5,1001, -w/2, 0, 1!is easily converted to:-!2D Command POLY2_ 10,1, -w/2, 0, 1, -w/2, d*2/5, 1, -w*2/5, d/2, 1001, w*2/5, d/2, 1, w/2, d*2/5, 1001, w/2, -d*2/5,1, w*2/5, -d/2, 1001, -w*2/5, -d/2, 1, -w/2, -d*2/5,1001, -w/2, 0, 1

I normally script the 2D buthaven’t done so to focus on thepoint of the exercise – IF state-ments in Value lists.

Delete unwantedlayersIf you have imported a DXF file withdozens of unwanted layers, you may beunsure which layers are empty, but stillwant to shorten the list. Perhaps youhave organised the file and groupedroad lines together, building lines to-gether, and so on. Now, try the AttributeManager in the Options menu. This al-lows you to purge all empty layers andunused line types.

!Multi-Lingual Object!- 2D Script

HOTSPOT2 0,0PROJECT2 3,270,2

‘Quote marks’GET into the habit of using single quotemarks instead of double quotes formaterial names, text strings and so on.If you have any intentions of doing APIdevelopment, it’s worth knowing thatyou cannot use double quotes if GDL isembedded inside a C++ script as partof the script of an object that will begenerated by the API. It will cause anerror.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 272: Cookbook3_1

2.169

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Cellular/Castellated Steel BeamTHIS is a demonstration of the use of CUTPOLY

and CUTPOLYA, two of the most useful addi-tions to GDL offered by AC6.x. These act as ‘cookiecutters’ which will travel through the model until youissue the CUTEND command. The technique of us-ing them is no more complex than that required tomake PRISM and PRISM_. Really!

!Stretchy Cellular Beam!3D Script!Iterative and sizing calculations!in Master Script

MATERIAL bmat: PEN pcolRESOL 20 !HiRes for large holes

!Design Holes with CutpolyFOR k=1 TO numhol ADD holst+holsp*(k-1),0,-bdep/2 ROTx 90 ROTz 0GOSUB 110:!Put profile – round/hexCUTPOLYA NSP/3,1,0, GET(NSP) DEL 3NEXT k

!Build BeamsADDz -bdep/2GOSUB 100:!Upper Beam ProfileGOSUB 150:!Main BeamDEL 1 ADDz -bdep/2 ROTx 180GOSUB 100:!Upper Beam ProfileGOSUB 150:!Main Beam DEL 2FOR k=1 TO numhol: CUTEND: NEXT k

END:!---------------------------

100:!UPPER Beam Profile!Starting with middle as originPUT 0,0,13,-webth/2, 0,15,-webth/2, bdep/2-flant-rootr,13,-webth/2-rootr,bdep/2-flant, 1013,-bwid/2, bdep/2-flant, 15,-bwid/2, bdep/2, 15, bwid/2, bdep/2, 15, bwid/2, bdep/2-flant, 15, webth/2+rootr,bdep/2-flant, 13, webth/2, bdep/2-flant-rootr,1013, webth/2,0,15RETURN

110:!Profile for CUTting holesIF rndsq=0 THEN !Round Hole PUT 0,0,913, holdm/2,360,4013 ENDIFIF rndsq=1 THEN !Castellated hole PUT -holdm/8,holdm/2,15, -holwd/2,0,15, -holdm/8,-holdm/2,15, holdm/8,-holdm/2,15, holwd/2,0,15, holdm/8,holdm/2,15 ENDIFRETURN

150:!Main Beam – half outlineRESOL 12 !for root radius ROTz -90 ROTx 90 ADDz -blenPRISM_ NSP/3,blen, GET(NSP) DEL 3RETURN

This is a very small sub-set of an ‘intelligent’beam project that Iworked on in 1999. Thisparticular beam is onlysuitable for spacing at

centres of 6metres (20 feet)with a floor loading of 5kN/m2

using steel and concrete flooring; andit applies a standard hole size. The intelli-

gent beam will adapt its size automatically (asit is stretched) to fit any beam length and spacing

from 3m to 18m, and also does an iterative check that theholespacing will work satisfactorily with the hole diam-eters (for the hot cutting + welding process) and adjustseither accordingly. This beam can change from Castellatedto Cellular, and obeys the general geometric requirementsof both types and behaves intelligently within the 6m spac-ing limit.

The beam-size and hole-shape are dependent on theresults of a Values List, so the first script that does anywork is really the Master Script (next page). To get the 3Dscript working you can put the details of a single beaminto the Master Script, and when the 3D works, you gradu-ally add more options into the Values List, and into theMaster Script, with IF... ENDIF statements to help it readin all the information.

3D ScriptIn the arched beam in the cookbook, the web of thebeam is made from a Prism with holes for the web, andthe flanges are made separately with TUBE. In this onethe entire beam is one PRISM, stretched along its length,and perforated by a series of CUTPOLYA commands. Theplacing of these is exactly the same as if you wanted todump a load of Prisms along the line of the centre of thebeam, at a regular holespacing. In order to provide a con-vincing looking centre weld, and to reduce the amount ofpoints required to define the beam profile, only half the

Note the use of PRISM_instead of PRISM. This is toget a realistic curve for the rootradius of the beam

This plants all theholes before the

beam is built

The beam is built intwo symmetrical

halves (upper andlower)

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 273: Cookbook3_1

2.170

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Stretchy Cellular Beam!Master Script!!Beam conditionblen=A !Beam length for stretchingIF blen>18 THEN blen=18 !Span limit

!Main Beam Sizes(relate to max span)IF btype="627x191 [6]" THEN bcon= 6IF btype="828x229 [9]" THEN bcon= 9IF btype="1078x267[12]" THEN bcon=12IF btype="1219x305[15]" THEN bcon=15IF btype="1235x305[18]" THEN bcon=18IF btype="Automatically sized" THEN bcon=3+3*INT((blen*0.99)/3) ENDIF !Trick to derive 6/9/12/15/18

!Determine profile of HoleIF holeshape="Round Holes" THEN rndsq=0IF holeshape="Castellated" THEN rndsq=1IF bcon<=18 THEN !------914x305----bwgt=253 !Weight indexbwid=0.305 !Beam widthbdep=1.235 !Beam depthwebth=0.017 !Beam webflant=0.028 !Beam flangerootr=0.019 !Root radiusholdm=0.700 !Hole diameterholsp=1.000 !Hole spacingENDIF

IF bcon<=15 THEN !------914x305-------bwgt=201 !Weight indexbwid=0.303 !Beam widthbdep=1.219 !Beam depthwebth=0.015 !Beam webflant=0.020 !Beam flangerootr=0.019 !Root radiusholdm=0.700 !Hole diamholsp=1.000 !Hole spacingENDIF

IF bcon<=12 THEN !------762x267------bwgt=173 !Weight indexbwid=0.267 !Beam widthbdep=1.078 !Beam depthwebth=0.014 !Beam webflant=0.022 !Beam flangerootr=0.017 !Root radiusholdm=0.700 !Hole diameterholsp=1.000 !Hole spacingENDIF

IF bcon<=9 THEN !------610x229------bwgt=125 !Weight indexbwid=0.229 !Beam widthbdep=0.828 !Beam depthwebth=0.012 !Beam webflant=0.020 !Beam flangerootr=0.013 !Root radiusholdm=0.500 !Hole diameterholsp=0.750 !Hole spacingENDIF

IF bcon<=6 THEN !------457x191------bwgt=67 !Weight indexbwid=0.190 !Beam widthbdep=0.627 !Beam depthwebth=0.009 !Beam webflant=0.013 !Beam flangerootr=0.010 !Root radiusholdm=0.400 !Hole diameterholsp=0.600 !Hole spacingENDIF!continued, right ->

A is the means ofstretching, but if A is

longer than 18 metres,blen sticks at a max of

18m.

The Value list isparsed with a seriesof IF statements.The numbers after

the beam name,which are also

used as a ‘flag’ forthe beam are the

‘recommendedmaximum span

in metres’.

I hope that all thesemetre dimensions donot offend the eyes ofmy U.S. friends, but I

do not have a set ofU.S. steel tables.

The castellation algorithm follows BritishSteel guidelines.

Each beam isthoroughly

documented for easychecking.

The author does not accept liability forthe structural accuracy of the beams: theyare taken from tables.

Values ListMakes the object behave quirkily if there is an error in the GDL, soyou often have to be very patient. Put dummy data in the Master Scriptuntil everything else is working well.

VALUES "holeshape" "Round Holes","Castellated"

VALUES "btype" “Automatically sized”, "627x191 [6]","828x229 [9]","1078x267[12]", "1219x305[15]","1235x305[18]"

Master ScriptThis routine checks onthe number of holes andhole spacing, and worksout how much steel toleave at each end to cen-tre the holes perfectly.In the intelligent beam,the hole diameters arechecked and modified.

!Master Script Continued!Procedure for round Holes

IF rndsq=0 THEN numhol=INT(blen/holsp) !Number of holes holsp=blen/numhol !Final HolespacingIF numhol=1 THEN holsp=holdm*1.5

!Hole starting position holst=(blen-numhol*holsp)/2+holsp/2ENDIF !end procedure for Round Holes

!Complex Procedure for CastellatedIF rndsq=1 THEN holdm=bdep/1.5 !Hole diameter holsp=holdm*1.08 holwd=holdm*0.83 !Hole width numhol=INT(blen/holsp)!Need to centre the Holes in the beam holst=(blen-numhol*holsp)/2+holsp/2ENDIF

beam is done, and then it is repeatedupside down.

It is risky to put an IF statement directlyinto a FOR next statement, so the sub-routine 110: decides whether the sectionis castellated or round, and stores the ap-propriate coordinates in the memorybuffer.

Do not forget that all CUT statementsrequire a CUTEND to finish; here theyare enclosed in a tidy loop.

The PRISM outline is defined first witha sequence of PUT statements. Once youare a Voyager, this is the best way to doALL but the smallest prisms – simply be-cause you can add, subtract and alterpoints while you are building it, with-out syntax errors; and it’s tidy – thewhole put sequence can be organisedin a separate subroutine.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 274: Cookbook3_1

2.171

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Arched CellularSteel BeamTHIS EXERCISE produces a useful object, but is also

a powerful demonstrator of the parametrics of Ar-chiCAD 6. It has been created especially for AndrasHaidekker, the CEO of Graphisoft UK to demonstrateto British Steel an example of parametric componentmaking with GDL.

In particular, it demonstrates:• The use of Arrays. Although it could be done with

PUT and GET only, this would require much repeti-tive typing and time consuming calculation.

• The use of Value Lists to make the object friendly.• The use of Trigonometry for forming curves.• TUBE command.• 2D Scripting to enhance the object’s usefulness.• The Master Script playing a major part.

You have this on your diskette, and you are very wel-come to play with it, but I hope those with a truly Voy-ager level of courage will work through some of thescripts to glean the jewels therein. Although it looksquite polished, it is like most complex things, simpleat first, and then added to gradually until it has all thefeatures one wishes for.

PlanningThe first thing is to create a PRISM for the Web of thebeam. From the start it is best put into an array. Thespan and curve-line of the beam follows the neutralaxis of the beam. Therefore the outline of the upperand lower edges are based on Radius plus or minushalf the depth of the beam. The Tapered end is a com-plication, but this determines the ‘stepping distance’of each polygonal increment in the beam.

Either add all the parameters all at once, but it ismore instructive to add them as you come across themin the scripts. This way, you appreciate their purposemore clearly.

The feet can be swivelled into pre-planned angles, or freelyangled. The Hole spacing can be varied.

Although it enlarges the size of your file, add a Picture intothe Preview Window, to make it more user-friendly.

!Stretchy Cellular Beam!2D Script

HOTSPOT2 0,0HOTSPOT2 A,0

IF A>blen THENHOTSPOT2 18,0HOTSPOT2 18, bwid/2HOTSPOT2 18,-bwid/2ENDIF

!PROJECT2 4,270,1

RECT2 0,-bwid/2,blen,bwid/2RECT2 0,-webth/2,blen,webth/2

!Put in HolesIF rndsq=0 THEN holwd=holdmIF A_<=50 THENFOR k=1 TO numhol ADD2 holst+holsp*(k-1),0 RECT2 -holwd/2,-webth/2,holwd/2,webth/2 DEL 1NEXT kENDIF

2D ScriptIf you used PROJECT2, the plan would take too long toredraw/rebuild, so a script built up of RECT2s is the fast-est solution.

The final part of the 2D script uses data from theMaster script to draw the plan of the holes in the web. Itcould be left out, as it doesn’t really show clearly exceptat large scale. The IF statement means that it is ‘scalesensitive’: it is only to be drawn in 1:50 or 1’=1/4” draw-ings or larger.

The first hotspots are the stretching ones. They mustbe written before the beam, or the beam will stretch butwill be unable to shrink. The next hotspots mark theend of the beam itself, even if the stretchy hotspots havegone beyond 18 metres.

The Project2 line can be enabled if you want a quickview in elevation to make sure the holes drilled cor-rectly. The holes routine is scale sensitive.

This isthe Beam

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 275: Cookbook3_1

2.172

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Artlantis no parallel views?

I am often asked why Artlantis does not cater for parallel(axonometric) views. Artlantis is a ray tracer, which means

that each ray of light is followed from its source to the eyeof the viewer. With parallel projection, there is no one eyepoint to trace the light back to.

If you want parallel views, position the camera 1000 me-tres, or even 10000 metres away from the model, zoom intothe model and you will have the nearest thing that it canprovide to a parallel view. If that’s not parallel enough, makethe camera more distant.

Tips and TricksArtlantis Export

EXPORTING an ArchiCAD model to Artlantis must bedone from a camera perspective view. A plain Artlantis

save does not export ALL textures; the resulting file is man-ageable but may need you to feed textures to the surfaces.Exporting to full Artlantis 3 format can create a databasefile of textures and everything, and beware, this could be 20or 30 megabytes in size. If any one material in the ArchiCADmodel has more than 65000 polygons, your export may fail,or Artlantis may be unable to open the file. If you have a lotof trees or tubes, make a duplicate of the Leaf material or ofStainless Steel, or whatever has the most polygons.

Artlantis – Losing VR cameras on ResaveFrom: Bruce Haniel

Iwas doing a multicamera VR in Artlantis 3.5. Went backto Archicad to amend the model, saved over the original

Artlantis file and nominated the original as the 'model'. Andthe 'model' cameras were to be used in the dialogue win-dow.From: Michael HohmannDon't save over the original file but use a new file nameand use the previous Artlantis file as the template file. Settextures, cameras lights and sun to be used from the tem-plate file. works for me....

!Arcing Beam with Portholes!3D Script

!Array is for!XY Points on circumf of beam!and masksDIM pt[125][3] MATERIAL bmat: PEN pcol ROTy tilty

!Master Script calculates!internal parameters

GOSUB 100:!Fill Array with PointsGOSUB 110:!Build Web of BeamGOSUB 120:!Build Flange of Beam--GOSUB 150:!Thrust Bearings-------GOSUB 160:!Feet------------------

DEL 1 !Undo TiltyEND:!----------------------------

! Arcing Beam with Portholes! Master Script

!Calculate parameters for main beam IF nostep<4 THEN nostep=4 IF nostep>60 THEN nostep=60 IF taplen<bdep/2 THEN taplen=bdep/2 IF taplen>bdep*2 THEN taplen=bdep*2 span=A: higt=B !DefineStretchyparams IF higt<0.02 THEN higt=0.02 !prevent error angl =2*(90-ATN((span/2)/higt))!Halfangle of bow brad =(span/2)/SIN(angl) !Radius of Bow arch circum= 2*PI*brad !Circumference lena = circum*angl*2/360 !Length of Arc nostep= INT(lena/taplen+0.5) stangr= (angl*2)/nostep !Step angle:Rotation

!Thrust Bearing and Foot IF bdim< bdep/10 THEN bdim=bdep/10 IF bdim> bdep*0.8 THEN bdim=bdep*0.8 blen = bwid+flanth*3 !Bearing Length ftwid=ftsiz: ftlen=ftsiz IF ftwid<blen THEN ftwid=blen IF ftlen<bdim+flanth*2 THEN ftwid=bdim+0.04

!Calculate Circle spacing IF hdens="No Holes" OR cdim=0 OR holetyp="None" THEN noholes=1 ELSE IF hdens ="Condensed" THEN hd=1.2 IF hdens ="Normal" THEN hd=1.4 IF hdens ="Extended" THEN hd=1.8 IF holetyp="Circular" THEN ht=0 IF holetyp="Hexagonal" THEN ht=1

IF cdim>bdep*0.9 THEN cdim=bdep*0.9 crad= cdim/2 !Circle Radius cspa= cdim*hd !Circle Spacing !Control Number of Circles is adjusted by angle numcirc=INT(lena/cspa-2-angl/60) cstang =cspa*360/circum !Stepping angle for Holes hangl =cdim/circum*360 !Sweep angle of one hole cangl =cstang*numcirc !Sweep angle of holes numhole=numcirc-1 !Actual number of holes hcrad =crad*SQR(3)/2 !Radial Height of HexHole ENDIF

Parsing the ValueList can be

verbose. But its gotto be done!

I would not advise anyone to type this in. It’s more useful toexamine the object and then do some textual analysis of the scriptto see what is going on.

3D ScriptSomething as complex as this needs to be rigor-ously structured, so the executive portion of the3D script is notably short – it is just a few lines –the rest of the work is done in the subroutines.

The Array is only used in the 3D, so it is builthere in the 3D script. Arrays can be one dimen-sional e.g. x[125],y[125],m[125]. Although it ismore verbose, it is easier to manage. But this ex-ample demonstrates the use of a 2 dimensionalarray where the X, Y, and M values are all storedin the one array called ‘pt’.

Byzanti
Highlight
Byzanti
Highlight
Page 276: Cookbook3_1

2.173

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Continuing Master Script........!Calculate Feet OrientationIF footang="Horizontal to Span" THEN ftang1=0:ftang2=0 ENDIF

IF footang="Horizontal to Ground" THEN ftang1=-tilty:ftang2=tilty ENDIF

IF footang="Tangential" THEN ftang1=90-angl:ftang2=90-angl ENDIF

IF footang="None" THEN nofeet=1

!Arching Beam with holes drilled!Value List

!Hole DensityVALUES "hdens" "Condensed","Normal", "Extended","No Holes"

!Hole TypeVALUES "holetyp" "Circular","Hexagonal", "None"

!Foot OrientationVALUES "footang" "Free Angle","None", "Horizontal to Span", "Horizontal to Ground", "Tangential"

110:!Build Web of Beam-------------!Put all points from array to BufferFOR k=1 TO np PUT pt[k][1],pt[k][2],pt[k][3] NEXT k!Drill Holes, unless "No Holes"IF NOT(noholes) THEN RESOL 16 FOR k=-cangl/2 TO cangl/2+0.1 STEP cstang GOSUB 200+ht:!Circular or Hex NEXT kENDIF

!Now Build it! ROTx 90 ADDY -brad+higt ADDz -0.01PRISM_ NSP/3,0.02, GET(NSP) DEL 3RETURN:!-------------------------------

120:!Build Flange of Beam-------------- IF flanth<0.01 THEN flanth=0.01 IF flanth>bdep/8 THEN flanth=bdep/10

!PUT Sectional outline PUT -bwid/2, 0, 0, -bwid/2,-flanth,0, bwid/2,-flanth,0, bwid/2, 0, 0

!Put Pathway points for Tube PUT pt[np][1],0,pt[np][2],0 !1st Phantom pt FOR k=1 TO np PUT pt[k][1],0,pt[k][2],0 NEXT k PUT pt[2][1],0,pt[2][2],0 !Lst Phantom pt ADDz -brad+higt TUBE 4,np+2,63, !Flange GET(NSP) DEL 1

RETURN:!-------------------------------

100:!Fill Array with Points-------!First Two Points pt[1][1]=(brad+bdim/2)*SIN(-angl) pt[1][2]=(brad+bdim/2)*COS(-angl) pt[2][1]=(brad-bdim/2)*SIN(-angl) pt[2][2]=(brad-bdim/2)*COS(-angl)

!Underside points rad=brad-bdep/2:np=2FOR k=-angl+stangr TO angl-stangr+0.1 STEP stangr np=np+1 pt[np][1]=rad*SIN(k):pt[np][2]=rad*COS(k)NEXT k

!End of span np=np+1 pt[np][1]=(brad-bdim/2)*SIN(angl) pt[np][2]=(brad-bdim/2)*COS(angl) np=np+1 pt[np][1]=(brad+bdim/2)*SIN(angl) pt[np][2]=(brad+bdim/2)*COS(angl)

!Upperside Pointsrad=brad+bdep/2FOR k= angl-stangr TO -angl+stangr-0.1 STEP -stangr np=np+1 pt[np][1]=rad*SIN(k) pt[np][2]=rad*COS(k)NEXT k

!First and Final Point np=np+1 pt[np][1]=(brad+bdim/2)*SIN(-angl) pt[np][2]=(brad+bdim/2)*COS(-angl)

!Fill Masking Values in ArrayFOR k=1 TO np-2 pt[k][3]=8 !Masking ValuesNEXT k pt[np-1][3]=13 !Last but one Point pt[np ][3]=-1 !Last Point !0.1 deliberate errorRETURN:!-------------------------------

The diameterof the end

bearingdetermines

the shape ofthe beam

end.

It is hard work building the array, but if you do nothave an array, you must go through this process twice,once for the web and again for the flange. So the arraysaves time – reducing the length of the script and thethinking and typing time. Considering the work theyhave to do, the web and flange routines are remark-ably short and easy as a result.

SIN and COS are the standard ways of definingcartesian coordinates from Radius and Angle – the tech-

continued next page....

Arched Cellular Steel Beam: continued

The Value List should be in the Parameter script in6.5, the Value List script in 6.0, or can be in the Mas-ter script in either – providing it comes at the verybeginning.

The Master script grows from the basic stepping an-gles and other parameters, to the monster you see here.Value Lists make the object enormously more helpfulto the user, but make the scripts more verbose, as youhave to parse the value list to extract or convert theresults.

Details, such as this section on the feet of the beamdo not get added in until they are needed.

nique I call ‘swing the cat!’ The web is built as a prismlaid flat on the ground. The flange is quite different, itis a rectangular section drawn through space along theoutline of the prism – so for the flange, a TUBE is theideal solution.

When you get to this level, almost everything is doneusing PUT and GET. You cannot build up a set of pointsfor any 3D form unless you know the exact number ofpoints. With PUT and GET, NSP is your automatic coun-ter, it knows how many points are on the prism or inthe tube.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 277: Cookbook3_1

2.174

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Arcing Beam with Portholes!2D Script

PEN pcol

!Main Outline HOTSPOT2 0,0 HOTSPOT2 (A/2)*COS(tilty),0 HOTSPOT2 (-A/2)*COS(tilty),0 RECT2 -A/2*COS(tilty),-bwid/2, A/2*COS(tilty), bwid/2

!Centreline LINE2 B*SIN(tilty), bwid, B*SIN(tilty),-bwid HOTSPOT2 B*SIN(tilty), 0

!Points for stretching HOTSPOT2 -A/2,0 HOTSPOT2 A/2,0

!Thrust Bearing ADD2 -A/2*COS(tilty),0 GOSUB 100:!Bearing ADD2 A*COS(tilty),0 GOSUB 100:!Bearing DEL 2

!Elevational viewIF truvu THEN PROJECT2 4,270,2 HOTSPOT2 0,B HOTSPOT2 B*SIN(tilty), B*COS(tilty) HOTSPOT2 -A/2*COS(tilty), A/2*SIN(tilty) HOTSPOT2 A/2*COS(tilty),-A/2*SIN(tilty) GOSUB 200:!Text Display ENDIF

END:!-------------------------------------

100:!Bearing RECT2 -bdim/2,-blen/2, bdim/2, blen/2 LINE2 0,bwid,0,-bwidRETURN

200:!Text DisplayDEFINE STYLE "btext" ‘Arial’,fsize,1,0 SET STYLE "btext" btstr="Arc’d beam, Rad="+ STR(brad,5,2)+",

Span="+STR(span,5,2) TEXT2 -A/2,bwid*3,btstrRETURN

150:!Thrust Bearings------ ADDx -A/2 ROTx 90 ADDz -blen/2 CYLIND blen,bdim/2 ADDx A CYLIND blen,bdim/2 DEL 4RETURN:!-------------------------

160:!Feet------------------------ IF NOT(nofeet) THEN ADDx -A/2 ROTy ftang1 GOSUB 170:!Foot DEL 2 ADDx A/2 ROTy -ftang2 GOSUB 170:!Foot DEL 2 ENDIFRETURN

170:!FootADDz -bdimPRISM 4,flanth, ftlen/2, ftwid/2, ftlen/2,-ftwid/2,-ftlen/2,-ftwid/2,-ftlen/2, ftwid/2 ROTx 90 ADDz bwid/2GOSUB 175:!flange in foot ADDz -bwid-flanthGOSUB 175:!flange in foot DEL 4RETURN

175:!Flange in footPRISM_ 7,flanth, -ftlen/2,0,15, -bdim/2-flanth,bdim,15, 0,bdim,915, 0,bdim*3/2+flanth,3015, bdim/2+flanth,bdim,3015, ftlen/2,0,8, -ftlen/2,0,15RETURN

200:!Circular Hole definition------- PUT brad*SIN(k),brad*COS(k),913, crad,360,4013RETURN

201:!Hexagonal definition----------- PUT (brad)*SIN(k-hangl/2), (brad)*COS(k-hangl/2), 15, (brad+hcrad)*SIN(k-hangl/4),(brad+hcrad)*COS(k-hangl/4),15, (brad+hcrad)*SIN(k+hangl/4),(brad+hcrad)*COS(k+hangl/4),15, (brad)*SIN(k+hangl/2), (brad)*COS(k+hangl/2), 15, (brad-hcrad)*SIN(k+hangl/4),(brad-hcrad)*COS(k+hangl/4),15, (brad-hcrad)*SIN(k-hangl/4),(brad-hcrad)*COS(k-hangl/4),15, (brad)*SIN(k-hangl/2), (brad)*COS(k-hangl/2), -1RETURN

2D ScriptUse PROJECT2 while you are do-ing this, until you get the script work-ing. This object requires some Trig,as it can be tilted.

When your text string is morecomplicated than a single quotation,build it up using the PLUS symbol.Mathematical quantities have to beconverted with the STR function. UseArial font to be sure of being usableon PC and Mac.

It is useful for the userto know the centre of

the beam

Whenever you have torepeat some typing,

use a subroutine.

truvu draws anelevation of the truss,

super-imposed over theplan view, with

additional Hotspotsand Text display.

Essential for ‘docking’it to the building

accurately.

Note the use of a BooleanNOT(…) command to

decide if the feet should bedrawn.

Note that I have used theflange thickness flanth as

an all purpose definer ofthickness for the feet

modules.

When you have thearray correctly

organised, it is as easyand quick as this!

It’s fun working out the algorithm for rotated hex holes!

The hexagonal holes are worked out using an advancedform of ‘swing the cat!’. For each point on the hole it ispossible to work out the theoretical radius and angle,assuming that the centreline of the hole is angle ‘k’.This routine is called by a For Next loop in subroutine110.

I apologise that this exercise is not enormously an-notated, but the script contains plenty of comments,and has a logical structure. If you are a true Voyager, it

will be interesting to analyse how it’s done from theobject in the Cookbook library. I realise that traditionalsteel castellation is not done to a curved beam, but Ihave seen photographs of curved castellated beams –presumably cut out after curving.

900 and 4000 are thepolylines to draw a

circular hole, and the 13will hide the lines of the

edges.

Byzanti
Highlight
Byzanti
Highlight
Page 278: Cookbook3_1

2.175

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Hyperbolic ParaboloidTHIS OBJECT was written as a result of visiting the

gas station in Palm Springs by Albert Frey in April1999 with architectural students. It used to greet visi-tors come to Palm Springs from LA. It was due for demo-lition, but was saved by architectural conservationists.It has now been converted into a garden sculpture gal-lery and sales area.

COONS is difficult enough to write in any circum-stances, but if you can devise a maths routine that willcalculate all the points along the side, then it is consid-erably easier. First, analyse the shape – a HyperbolicParaboloid is distinguished by the fact that all the mem-bers connecting the sides are perfectly straight, butwhen used in combination, they produce an elegantsaddle shaped curve.

ParametersYou have to decide how the user will ‘describe’ this inthe parameter box. Wherever possible, make use ofthe A and B, to make it stretchy, and to reduce thenumber of options in the remainder of the dialog box.Because the ‘hyparb’ is assymmetrical, you can base iton A and B with an offset to define the centre location.Once the basic structure is working, add in the Materi-als and get the Value lists working.

Project planningThe strategy is to get all the work done by a sequenceof PUT statements, and then (if these are all arrangedcorrectly), you throw the whole lot at the COONS inthe form of a GET(NSP) statement.

If you first create an array holding the XYZ loca-tions of each corner, you only need to derive the XYZof all the points along the straight lines joining them todescribe the COONS.

If the 2D was to be based on PROJECT2, you coulddo the whole thing in the 3D script, but as this object is2D scripted, you must start with the Master Script.

Master ScriptAlthough the parsing of the Value List appears first, itis best to fit that in later, and just get the surface work-ing. You can still write the Value List out, and think outthe range of options you will offer the user.

3D ScriptHas been annotated section by section on the nextpage. Notice how small the executive script is, becausethis is a difficult one and is best subdivided into modu-lar tasks.

VALUES 'edgt' "Square","Round"VALUES 'tubecon' "Surface, No tubes", "Edge Tubes+Surface", "Surface Tubes+Surface", "All Tubes+Surface", "All Tubes, No Surface"

!Hyperbolic Paraboloid – Master Script!Parse Value ListIF tubecon="Surface, No tubes" THEN tcon=0IF tubecon="Edge Tubes+Surface" THEN tcon=1IF tubecon="Surface Tubes+Surface" THEN tcon=2IF tubecon="All Tubes+Surface" THEN tcon=3IF tubecon="All Tubes, No Surface" THEN tcon=4

!State ArraysDIM pnt[3][10]x=1: y=2: z=3

!Build Array: main points!Point WestPUT -A/2+ofst,0,hita!Point NorthPUT 0,B/2,0!Point EastPUT A/2+ofst,0,hitb!Point SouthPUT 0,-B/2,0

FOR k=1 TO 4 !Main array pnt[x][k]=GET(1)!X value pnt[y][k]=GET(1)!Y value pnt[z][k]=GET(1)!Z valueNEXT k

FOR k=5 TO 7 !Extend array by 3 pnt[x][k]=pnt[x][k-4]!X value pnt[y][k]=pnt[y][k-4]!Y value pnt[z][k]=pnt[z][k-4]!Z valueNEXT k

!Correct User ErrorsIF smoo<2 THEN smoo=2IF smoo>36 THEN smoo=36IF numsub<1 THEN numsub=1IF smoo<numsub THEN smoo=numsub

The easiest way to fillan array is to use a

series of PUTstatements to build the

numbers, then useGET to fill the array. The array needs to be7, not 4, so that when

you use a TUBEcommand for the edge

beams, you will be ableto do the ‘phantom

points’.

Because the sides of thehyparb will be

subdivided by beams,you might like a denser

degree of subdivisonfor the surface than forthe beams. So the error

correction routineensures that the surface

is never coarser thanthe beam layout.Values List: you can write this later when you

have got the basic surface working correctly

It makes it easier to manage if the arrays arealways referred to by letters x, y, and z, even

though numerically, they are 1, 2, and 3.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 279: Cookbook3_1

2.176

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Hyperbolic Parabaloid!3D Script!Voyager Course, Cookbook

!Main parameters set up in Master Script

!Build SurfaceIF tcon<=3 THEN GOSUB 100:!Surface

!Build EdgetubesIF tcon>=1 THENGOSUB 130:!EdgetubeENDIF

!Do Surface tubesIF tcon>=2 THEN GOSUB 150:!Surface tubes routine MULy -1 GOSUB 150:!Surface tubes routine DEL 1ENDIF

END:!_____________________________________

100:!Build Surface!Feed COONS points to memoryp1=1:p2=2 !1 to 2 GOSUB 110p1=4:p2=3 !4 to 3 GOSUB 110p1=1:p2=4 !1 to 4 GOSUB 110p1=2:p2=3 !2 to 3 GOSUB 110

!Build itADDz slif*dimt*sftbpc/150MATERIAL hpmatCOONS NSP/12,NSP/12,63, GET(NSP) DEL 1RETURN

110:!Subroutine: workout XYZ !Increments xinc=(pnt[x][p2]-pnt[x][p1])/smoo yinc=(pnt[y][p2]-pnt[y][p1])/smoo zinc=(pnt[z][p2]-pnt[z][p1])/smoo

FOR k=1 TO smoo+1PUT pnt[x][p1]+xinc*(k-1)PUT pnt[y][p1]+yinc*(k-1)PUT pnt[z][p1]+zinc*(k-1)NEXT kRETURN

120:!Define Section ProfileIF edgt="Square" THEN PUT w, w,0 PUT -w, w,0 PUT -w,-w,0 PUT w,-w,0ELSE PUT 0,0,901, !Round w,360,4001ENDIF

sp=NSP/3 !Section pointsRETURN

130:!Build Edge Tubesw=dimt/2 !Section RadiusIF tcon=2 THEN w=dimt*sftbpc/200GOSUB 120:!Define profile

!Define edge pathway FOR k=1 TO 7 PUT pnt[x][k],pnt[y][k],pnt[z][k],0 NEXT k

!Build tube all in oneRESOL 8MATERIAL frmat TUBE sp,7,63, GET(NSP)RETURN

150:!Surface tubes routine!Increments for first line xinc1=(pnt[x][2]-pnt[x][1])/numsub yinc1=(pnt[y][2]-pnt[y][1])/numsub zinc1=(pnt[3][2]-pnt[3][1])/numsub

!Increments for second line xinc2=(pnt[x][3]-pnt[x][4])/numsub yinc2=(pnt[y][3]-pnt[y][4])/numsub zinc2=(pnt[z][3]-pnt[z][4])/numsub

!Points for start+end of surface tubesFOR k=1 TO numsub-1 x1=pnt[x][1]+xinc1*k x2=pnt[x][4]+xinc2*k y1=pnt[y][1]+yinc1*k y2=pnt[y][4]+yinc2*k z1=pnt[z][1]+zinc1*k z2=pnt[z][4]+zinc2*k

!Define Phantom Points x0=x1+(x1-x2) x3=x2-(x1-x2) y0=y1+(y1-y2) y3=y2-(y1-y2) z0=z1+(z1-z2) z3=z2-(z1-z2)

w=dimt*sftbpc/200 !Profile sectionGOSUB 120:!Define profile

!Draw itMATERIAL frmat TUBE sp,4,63, GET(NSP), x0,y0,z0,0, x1,y1,z1,0, x2,y2,z2,0, x3,y3,z3,0NEXT kRETURN

This subroutinedoes the real workof calculating theXYZ locations of

the side points. Foreach side, the

increments in X, Y,and Z are

calculated (xinc,yinc and zinc) and

applied in a For..Next loop to build

the list. ‘smoo’ is thenumber of pointsalong the surface

edge.

This routine drawsout the beam

sections, based on theuser’s preferences in

the Value List.

The tricky IF statement above is to convertthe edge beamroutine to build the same sizeas the surface beams if the real edge beamsare required to be omitted. Using GET, thefinal TUBE command is simple.

Build the tube pathway in a Loopcontaining PUT statements

I am surprised at howdifficult this was. It

turns out to be easier todo just one set of beams,

on the north side, andthen repeat the wholelot, using a MULy -1

command in theexecutive script.

As the distribution of edge points forthe beam is different to that for the

surface, it’s not worth filling anarray. As the beams are all onepiece, it’s not worth using PUT.

Generate the XYZ locations on thefly and just throw them at the TUBE

command.

Two lots ofincrementsneed to be

worked out,for the pointsat each endof the beam.

COONSThe surface building exercise follows the techniqueoutlines earlier in the book,for COONS commands. 1to 2, 4 to 3, 1 to 4 and 2 to 3. The corners of the Hyper-bolic Paraboloid have been numbered in the orderWest, North, East, South. The COONS, when it comes,is short and decisive. You can later apply a lift com-mand (ADDz) if the user wants it raised above the sur-face beams.

Yes!This routine for devising the phantom points is a fiend-ishly useful piece of script for ensuring that singlelengths of TUBE always have butt ends – no matterwhere they are in 3D space. I turn to this page and useit frequently. I feel almost reluctant to give it away. It isthe kind of thing that if you try to think it out, youcannot find the answer. I spent a long while thinkingabout it without getting an answer; then went down-stairs to do the washing up and do the crossword. Theanswer got written on the edge of the crossword, andthen copied to the 3D script.

Yes!

COONS: Remember theroutine:

1>2, 4>3,1>4, 2>3

Setting Standards: use a ModuleFrom: Duane Valencia, [email protected] is a great use for a module. Create to your heart'scontent and then arrange in a small area all the things youwould like to move from one file to another. Copy them,and save as a MODULE. Next file that needs them, MERGEthe module in. I have done this for all my fills, line types etc.Sorry, Pens won't port over...

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 280: Cookbook3_1

2.177

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Hyperbolic Parabaloid – 2D Script!May 1999: David NicholsonCole!Main parameters set up in Master Script

HOTSPOT2 -A/2+ofst,0HOTSPOT2 A/2+ofst,0HOTSPOT2 0,B/2HOTSPOT2 0,-B/2HOTSPOT2 0,0

!PROJECT2 3,270,2

FOR k=1 TO 5PUT pnt[x][k],pnt[y][k]NEXT k

POLY2 5,1, GET(NSP)

!Surface Tube linesIF tcon>=2 THENGOSUB 150:!Surface tubes routine MUL2 1,-1GOSUB 150:!Surface tubes routine DEL 1 ENDIFEND:!----------------------

150:!Surface tubes lines

!Increments for first line xinc1=(pnt[x][2]-pnt[x][1])/numsub yinc1=(pnt[y][2]-pnt[y][1])/numsub

!Increments for second line xinc2=(pnt[x][3]-pnt[x][4])/numsub yinc2=(pnt[y][3]-pnt[y][4])/numsub

!Points for start+end of surface tubesFOR k=1 TO numsub-1 x1=pnt[x][1]+xinc1*k x2=pnt[x][4]+xinc2*k y1=pnt[y][1]+yinc1*k y2=pnt[y][4]+yinc2*k

!Draw it LINE2 x1,y1,x2,y2 HOTSPOT2 x1,y1 HOTSPOT2 x2,y2NEXT k

RETURN

32

1

4

2D ScriptThe PROJECT2 command is used until you are surethat your 2D script is working. The first five activelines are all you need, if you are in a hurry, and wouldmake my pagination a lot easier – I could fit this allon 2 pages. But this is an impressive demonstrationof how easy 2D scripting can be once you have con-quered a very difficult routine in 3D. Just omit theheight factor, and replace 3D entities with their 2Dequivalent. The Loops are virtually the same.

The POLY2 routine issimply a re-hash of the

routine which draws theedgebeam tubes, except that

you do not bother withheight (z), and POLY2 doesnot require phantom points.

If you are in a hurry, theProject2 and the Hotspots

are all you need

The surface beam lineroutines are a simple re-

hash of the same thing inthe 3D script, omitting

height (z), and usingLINE2 instead of TUBE

to draw the beam lines. Itis good to add in the

Hotspots at ends, as theobject can more easily be

picked up.

Reasons to use ArchiCAD-Talk: No. 1

Gyuri Juhasz [email protected] Graphisoft R&D Rtphone 361 437 3121 fax 361 437 3099

TO all who recently questioned whether Graphisoftreads at all your input: YES.

Many GS people in the US and in Hungary watch the maillist,including programmers, designers, techsup staff. We haveno strict policy on how we respond. Access to ArchiCAD-TALK is free and we would like to participate in this list onthe same non-compulsory basis as you.

We do not want to answer each and every problem men-tioned here. We read the digest version with a long delayand in most cases the AC-Talker community responds fasterthan we do.

Suggestions for product improvements are always wel-come. In many cases we do not talk just listen, archive,analyze and think. All problems and wishes are entered inour databases which are the foundation of future Archi-CAD releases. And we spend so much time with our com-puters that progress, simply statistically, is unavoidable :)

And please do not forget: we are no maillist police, youbash our product and company as you wish. However weare just humans and in many cases, we prefer stay silent ifa posting just hurts.peace, gyuri[Editors Note: see elsewhere in the Cookbook how toconnect to ArchiCAD-Talk[

Hide window symbol?

YOU may want to place a window above a door, or place aminor window above a major window, but want to be able to

decide which one will show. This depends on whether you createdthe window, or if it is a Graphisoft library window. (One is reluctantto alter them so perhaps you should do this to copies.)Laszlo Nagy ([email protected]) offers:Add a new parameter 'show2d' /Boolean type/"Show 2D symbolON/OFF?". In the 2D script, insert this line at the top: IFNOT(show2d) THEN 1000Place the window, then use the settings box to switch 2D off. Thiswill have the effect of leaving the window existing in 3D but invis-ible in the plan. If show2d=1 it means there is a 2D Symbol. In thiscase the normal Script is executed. If it is zero it will go to 1000where the following lines are:

END:!this stops the existing script running into this one1000:!Place this script at the END of the existing scriptADD2 0, WIDO_SILLIF WIDO_REVEAL_SIDE=1 THENADD2 0,WALL_THICKNESS-2*WIDO_SILL-WIDO_FRAME_THICKNESSENDIFPEN WALL_FILL_PENFILL WALL_FILLPOLY2_B 4,6,WALL_FILL_PEN,WALL_FBGD_PEN,- -A/2,-C_,0,A/2,-C_,0,A/2,0,0,-A/2,0,0PEN WALL_SECT_PENLINE_TYPE WALL_LINETYPELINE2 -A/2,-C_,A/2,-C_LINE2 -A/2,0,A/2,0ENDThis will basically draw a fill and lines which get their types fromthe Wall's global variables. It works even if you flip the window (atough task to do). Regards, Laszlo Nagy, Graphisoft Budapest

Page 281: Cookbook3_1

2.178

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Tents? – the big questionARCHICAD is undoubtedly the easiest to use CAD

software for architectural design, because mostbuildings include Walls, Slabs, Columns, Windows,Doors, Roofs and all the good things that occur in the3D tools palette. The construction of Tents is one ofthe most difficult in real life and in CAD. If there isONE THING that made me start GDL it was my stu-dents bringing me pictures of membrane structures thatthey had done in AutoCAD and implying that either Ior ArchiCAD was deficient. It was ‘learn GDL or die ofshame’. Make ArchiCAD ‘sing’ or they would not useit. After several years of doing GDL, I still find that tentsare the most difficult objects to make.

Since 6.x, we are all grateful that we have the Meshtool because at last it has been possible for people toform solid terrains to make sites, and to form mem-branes to make tents. However, these are still labori-ous and are not parametric.

There are two ways to make tents, one is withCOONS, and one is with MASS. COONS is a surfacewhere you define the edges and allow GDL to smoothlyinterpolate the middle areas. The outline needs to beapproximately quadrangular, so some membranes mayhave to be cut into tiles. COONS is powerful in that itcan tolerate extraordinary amounts of gravity defyingdeformation.

MASS is, in effect, the Mesh tool, and is built by de-fining the edges, but it can also accept points and ridgeswithin its outline. If you do not add points, you getlarge flat planes, so more work has to be done by theuser to insert extra ridges and points. MASS cannot al-low overlaps – every part must be visible in plan – ifany part of the mesh is tucked under any other part(when viewed in plan) it will not build.

The next problem is that every tent is different. Tentscan be inflated, where the pressure comes from belowand is widely distributed. Tents can be suspended bycables and stretched downwards to anchorage points,or pushed up by pointy push rods, or pushed up bymushroom shaped supports. The anchorage pointsmay all be at different levels. Tent membranes havevarying degrees of elasticity. Tents may be isolated, orthey may be part of a continuum of linked menbranes,as in the illustration here.

Serious tent design software, in which you canspecify locations of the push and pull points, the ten-sile properties of the membrane, the connectivity ofthe membrane and so on costs many thousands. It takesa long time for the user to feed in all the information;in fact the user needs to be an engineer to answer allthe complex questions at input.

Tents made by non engineers can only ‘look right’;we can use GDL to make the curvature at the edgeslook reasonably authentic. Any tent thus designedneeds to be subjected to the rigour of a structural analy-sis before it could be safely mounted on a building.

Try these tentsThese tents are designed to link to each other, so theydistort vertically, but do not pull laterally. I have donea commercial version of this where there were differ-ent profiles for different edges conditions. There is abaseframe with cones at each corner to which the mem-brane elements are anchored. A kingpost pushes thecentre of the tent upwards, and suspension cables fromthe centre of the kingpost pull up on a ringbeam at thetop of the tent, and down on the baseframe. The sys-tem is in equilibrium. The baseframe gets diagonal brac-ing from the cables and from the membrane itself.

An option can be available to cap the tent with afabric cone, to leave it open, or to change the top ofthe kingpost to a mushroom head that pushes the cen-tre of the tent into a dome-shape.

This is only one of many tent shapes, but it is anadequate vehicle for teaching something about -Circular and Parabolic scripting. The designer shouldlook for every opportunity for using symmetry, anddivide the roof into ‘tiles’, as in the 3D view above.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 282: Cookbook3_1

2.179

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Planning and 3D ScriptUse symmetry as much as possible. In this case, weonly make one quarter, in the positive quadrant. Wedevise different curvatures for each side. It’s best tonumber each node on the quarter tent. Draw it out onpaper, number the nodes and think about the curve ateach surface. Remember, there is no lateral deforma-tion of the membrane edges as these are designed tojoin together. If we include a variety of end conditions,we would require more pages.

• 1 to 2 are a circularcurve, ending at thehigh point of thesaddle shape betweenmembranes.

• 2 to 3 are a parabolicshape, ending at theanchorage on thebaseframe.

• 3 to 4 are the sameparabolic shape,rising to the height ofthe saddle shapebetween membranes.

• 4 to 5 are a circularshape, same as 1 to 2.

• 5 to 1 are a horizon-tal curve around thehole, circular in planform.

!Tent form – Master Script!GDL Cookbook

!Also adjust height in Parameter scriptIF zzyzx>A/2.1 THEN zzyzx=A/2.1IF zzyzx<A/10 THEN zzyzx=A/10 hit=zzyzx !Height of top hole

!Ensure Positive values hrad= ABS(hrad) kpostup=ABS(kpostup) kpostdn=ABS(kpostdn)

!Elasticity index (height of saddle)IF elast<0.1 THEN elast=0.1IF elast>0.9 THEN elast=0.9IF adjust<0.0 THEN adjust=0.0IF adjust>0.5 THEN adjust=0.5

bulg=hit*elast !Height of bulge at saddle

!Curve from point 1 to 2 span=A-hrad*2 higt =hit-bulg ang12=(90-ATN((span/2)/higt))*2 rad12=(span/2)/SIN(ang12)

Formulae from GDLCookbook maths pages

Master ScriptYou do not need all of the Master script at the start. Itgrows as the needs of your 3D work grow. Error cor-rection routines, like forcing variables to be positiveare ones you put in before you let others use the ob-ject. One useful function of the Master script here is toget one’s thoughts down in writing about the curveshapes between nodes.

!Tent form – 3D script!First attempt

PEN pcol3

GOSUB 100 MULx -1GOSUB 100 MULy -1GOSUB 100 MULx -1GOSUB 100DEL 3

END:!__________________

100:!Do one quarter first!prepare points for a MASS!Node points only

PUT hrad,0, hit,15 !node 1PUT A/2, 0, hit*elast,15 !node 2PUT A/2, A/2, 0,15 !node 3PUT 0, A/2, hit*elast,15 !node 4PUT 0, hrad,hit,15 !node 5PUT hrad,0, hit,-1 !node 1

BODY -1MASS tentmat,tentmat,tentmat, NSP/4,0,0,0, GET(NSP) BODY -1

RETURN

!Curve from point 2 to 3!Parabolic half arch

!Curve from point 3 to 4!Parabolic half arch

!Curve from point 4 to 5!Same as 1 to 2, but swap X & Y

!Curve from point 5 to 1!Quarter circle with known rad & sweep

!Cap StyleIF capst='Hole with cables' THEN cs=0IF capst='Fabric cone with cables' THEN cs=1IF capst='Rounded membrane cap' THEN cs=2 span=hrad*2 angdom=ang12 !angle of existing curve raddom=(span/2)/SIN(ang12) ENDIF

This flipping routine means that youonly have to write one quarter of thetent. Once you introduce varied edgeconditions, then of course, you needto use a more complex method, callingthe appropriate subroutine for eachquadrant.

The circle and parabolaare defined by these

variables

Do it without curves first. This establishes the basicshape of the tent and boosts the confidence enormously.Only a few miles to go!

‘elast’ makes the saddle heighta proportion of the tent height

Write down these planning thoughts for the pathsbetween nodes, in conjunction with diagrams like theone here. It will make you feel more composed

This routine needsto be matched by a

routine in theParameter script

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 283: Cookbook3_1

2.180

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Modifications to 3D Script

sr=1 !Subroutine to be runGOSUB 100+sr MULx -1GOSUB 100+sr MULy -1GOSUB 100+sr MULx -1GOSUB 100+srDEL 3

END:!__________________

101:!Do one quarter first!prepare points for a MASS!Node points, plus one hopeful guess!in between each one

PUT hrad,0, hit,15 !node 1 PUT hrad+(A/2-hrad)/2,0,bulg+0.4*(hit-bulg),15!*PUT A/2, 0, bulg,15 !node 2 PUT A/2,A/4,bulg*0.75,15 !*PUT A/2, A/2, 0,15 !node 3 PUT A/4,A/2,bulg*0.75,15 !*PUT 0, A/2, bulg,15 !node 4 PUT 0,hrad+(A/2-hrad)/2,bulg+0.4*(hit-bulg),15!*PUT 0, hrad,hit,15 !node 5 PUT hrad*COS(45),hrad*SIN(45),hit,15 !*PUT hrad,0, hit,-1 !node 1

BODY -1MASS tentmat,tentmat,tentmat, NSP/4,0,48,0, GET(NSP) BODY -1RETURN

This guesswork solution works prettywell if you have smoothing turned on.If this is good enough, you do’nt needto do more. It’s delightful how effectivethe MASS command (mesh tool) can be.

!Tent form

PEN pcol3

sr=2 !Subroutine to be run

GOSUB 100+sr MULx -1GOSUB 100+sr MULy -1GOSUB 100+sr MULx -1GOSUB 100+srDEL 3

END:!__________________

102:!Parabolic version!prepare points for a MASS!Node points, calculated in between each onePUT hrad,0, hit,15 !node 1

stpang=ang12/smothFOR k=ang12-stpang TO stpang-1 STEP -stpang x=A/2-rad12*SIN(k) y=0 z=bulg+rad12-rad12*COS(k) PUT x,y,z,15NEXT k

PUT A/2, 0, bulg,15 !node 2

span=Astp=(span/2)/smothFOR k=stp TO span/2-stp+0.01 STEP stp x=A/2 y=k z=bulg-(4*bulg/(span^2))*k^2 PUT x,y,z,15 NEXT k

PUT A/2, A/2, 0,15 !node 3

span=Astp=(span/2)/smothFOR k=A/2-stp TO stp-0.01 STEP -stp x=k y=A/2 z=bulg-(4*bulg/(span^2))*k^2 PUT x,y,z,15 NEXT k

PUT 0, A/2, bulg,15 !node 4

Making it more curvyThe next level of work is to define parametric curvesin the edges. This is not necessary if the tent is its finalheight and size. You could put the tent above into Ar-chiCAD, view it in section/elevation, plot out somesmoother in between points, then copy these and in-sert them between the node points. In fact the wholetent could be done this way if it does not have to beparametric. But we are here to learn parametrics, solet’s introduce calculated curves.

Subroutine 103 uses circle chords for the seams fromthe hole down the saddle, and parabolae for the outeredges.

Smoth is a smoothness index. It decides how manysteps are to be used in the edge. If you have smooth-ing turned on in photorendering, you do not needmany steps.

Curve from 1>2 is a standard ‘Swing the Cat!’ rou-tine. It is based on angular change during the loop.Curve from 2>3 is based on a Parabola, descending. Atthe end of each curve, we reach the safety of a nodepoint that we worked out back in subroutine 100. Be-cause we are using PUT and GET all the time, GDLdoesn’t mind if we add the curves in one at a time, getthem worked out, see how they look in the 3D win-dow, then move on the the next. It always counts upcorrectly, using NSP.

The slightly verbose way of writing out the valuesof X, Y and Z on separate lines and then finishing withPUT x,y,z,15 is easier on the brain and eye, and easierto adapt if you want to try different profiles later – forexample if you wanted to extend this object to includelateral deformation, or having the membrane tied downto the baseframe at one or two edges.

The curve routines omit the First and Last points onthe curve, because these are already there in the formof the node points.

Change this line so that the‘flipping’ routine with the

GOSUB 100’s can show themore complex tent shape

Swing the Cat!See the circle

diagram opposite toappreciate this

This is the parabolicformula devised by

me in the Cookbookmaths primer1

Do the parabola again,this time climbing up

the curve

These steps are angular:the extra 1 at the end point

is to avoid an error (seeTips and Tricks on Errors).

These steps aredistance based: the

extra 0.01at the end point isto avoid and error

1 I would be grateful if all use of this parabolic formula incommercial GDL work could include a documentation lineacknowledging its original author.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 284: Cookbook3_1

2.181

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Continuing from Node 4stpang=ang12/smothFOR k=stpang TO ang12-stpang+1 STEP stpang x=0 y=A/2-rad12*SIN(k) z=bulg+rad12-rad12*COS(k) PUT x,y,z,15 NEXT k

PUT 0, hrad,hit,15 !node 5

stpang=90/smothFOR k=stpang TO 90-stpang+1 STEP stpang x=hrad*SIN(k) y=hrad*COS(k) z=hit PUT x,y,z,15 NEXT k

PUT hrad,0, hit,-1 !node 1nextpts=NSP/4 !Number of External points

!Internal Points-----------------------!Near the hole – each hole ends in -1 x=COS(30)*(A/2-rad12*SIN(ang12-ang12/smoth)) y=SIN(30)*(A/2-rad12*SIN(ang12-ang12/smoth)) z=bulg+rad12-rad12*COS(ang12-ang12/smoth) PUT x,y,z,-1 PUT y,x,z,-1

!Midway on the surface x=COS(30)*A/3 y=SIN(30)*A/3 z=bulg+(hit-bulg)*adjust PUT x,y,z,-1 PUT y,x,z,-1

!Number of Internal ptsnintpts=(NSP-nextpts*4)/4

!Build the membraneBODY -1MASS tentmat,tentmat,tentmat, nextpts,nintpts,16,0, GET(NSP) BODY -1RETURN

The same curveas 1>2 but with

adjustments to Xand Y

For the MASS command we are building up the ex-ternal points of the membrane, so it requires X,Y,Z andan edge masking of 15 on each line.

The curve 5>1 is a circle horizontally arranged, sothat the hole is parametric. At this point, it might bepossible to use a polyline, but when you have had thismuch practice at swinging the cat, it does not hurt thewriter or the cat to do one final turn.2

Provide some internal pointsTo complete this, you need a routine to sum up thetotal ‘Number of External Points’, which is called here,nextpts. This is NSP/4 (easy!). Next we have to put insome internal points, and sum them up as nintpts(Number of Internal Points). The method for workingthese out is to steal the algorithm from the curved sur-faces and assume that an extra point is placed at 30˚and 60˚ spacing, equal in height to the points onthecurve just below the hole. We do the same for thepoints in the middle of the membrane. Without these,the MASS command will display a large flat area in thesurface because it breaks the surface down into flatareas defined by the most convenient straight lints be-tween points. (COONS would not do this, because it isalways smoothing the middle areas.) The height ofthese points has to be adjusted by the visual judge-ment of the user – it all depends on how highly orwidely the membrane is stretched. A parameter calledadjust is provided for this.

2 This does not imply that the author in any way condones crueltyto cats nor that I partake of corporal punishment when at sea. I have2 cats and love them very much, even if they only love me becauseI feed them! Perhaps the same applies to the crew of my yacht.

!Tent form

PEN pcol3GOSUB 200:!Corner Points + FrameGOSUB 210:!Cables lowerGOSUB 300+cs:!Capping

!3D HotspotsHOTSPOT 0,0,hit

!All the Tentmaking subroutines in here

END:!__________________

200:!Corner Points – frame etcRESOL 6MATERIAL tubmatADDz -chit-tradFOR k=0 TO 3 ROTz k*90 ADD A/2,A/2,0 CONE chit+trad,trad,trad/2,90,90 DEL 2 NEXT k

!Frame tubingMATERIAL tubmatTUBE 2,7,63, 0,0,901, trad,360,4001,-A/2,-A/2,0,0, A/2,-A/2,0,0, A/2, A/2,0,0,-A/2, A/2,0,0,-A/2,-A/2,0,0, A/2,-A/2,0,0, A/2, A/2,0,0DEL 1

!Tent 2DHOTSPOT2 0,0HOTSPOT2 A/2, A/2HOTSPOT2 -A/2, A/2HOTSPOT2 -A/2,-A/2HOTSPOT2 A/2,-A/2PROJECT2 3,270,3

2D ScriptThis object is stretchy inheight, and could be madestretchy in plan. The com-mercial one from which isis derived is stretchy, eventhough the centre hole al-ways remains correctly cir-cular. This is done by doinga separate algorithm for thecurves for every face of themembrane. For the simpleexample here, we have keptthe membrane square.

Add in the new parameters and add the subroutinesbelow to provide the cables and frame

Cones at the corners

The tubing for the baseframe iscircular in section. When two aretogether, the frames merge. With acommercial object one can build

in options to hide parts of theframe structure

Nice for stretching thetent vertically!

Why do we use BODY -1here? It is always advisablewith MASS, COONS, TUBE

and other complex 3Dobjects, but the primaryreason is that you may

wish to make themembrane transparent ortranslucent. If you wish it

to CAST SHADOWScorrectly, then BODY -1 is

essential!

Notice that in allcurves, the FIRST and

LAST points are notcalculated

-1 finishesthe circuit

So... we just do aPROJECT2 here forsimplicity. But youcould use a RECT2and a CIRCLE2.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 285: Cookbook3_1

2.182

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Central Kingpost ADDz -chit-trad-kpostdn CONE kpostdn+chit+trad,trad/4,trad,90,90 ADDz kpostdn+chit+tradCYLIND hit,tradIF kpostup THEN ADDz hit CONE kpostup,trad,trad/4,90,90 DEL 1 ENDIF DEL 2RETURN

210:!CablesGOSUB 211:!Cable lowerROTz 90GOSUB 211:!Cable lowerDEL 1RETURN

211:!Cable lowerMATERIAL cabmatTUBE 2,5,63, 0,0,901, trad/4,360,4001, A , A ,-chit-trad,0, A/2, A/2,-chit-trad,0, 0,0,-chit-trad-kpostdn,0, -A/2,-A/2,-chit-trad,0, -A ,-A ,-chit-trad,0RETURN

300:!Hole with cablesGOSUB 310:!Ring around holeGOSUB 320:!Cables UpperRETURN

301:!Hole with membrane cone capeGOSUB 310:!Ring around holeGOSUB 320:!Cables UpperRESOL smoth*4MATERIAL tentmatPUT -kpostup-trad/2,0.001,1, -trad/2,hrad,1

ADDz hit ROTy 90REVOLVE NSP/3,360,0,GET(NSP) DEL 2RETURN

302:!Round Capping!Continues line of membraneRESOL smoth*4MATERIAL tentmatPUT raddom*COS(ang12),0,901, raddom*COS(ang12)-raddom,0.001,1, raddom,-ang12,4001ADDz hitROTy 90REVOLVE NSP/3,360,0,GET(NSP)DEL 2RETURN

310:!Ring around holestp=360/(smoth*4)FOR k=-stp TO 361+stp STEP stpPUT hrad*COS(k), hrad*SIN(k), hit, 0NEXT kMATERIAL tentmatRESOL 5TUBE 2,NSP/4,63, 0,0,901, trad/3,360,4001, GET(NSP)RETURN

320:!Cables Upper ROTz 45GOSUB 321:!Cable upper ROTz 90GOSUB 321:!Cable upper DEL 2RETURN

321:!Cable upperMATERIAL cabmatTUBE 2,5,63, 0,0,901, trad/4,360,4001, 0, hrad*2 ,hit,0, 0, hrad, hit,0, 0,0,hit+kpostup,0, 0, -hrad, hit,0, 0, -hrad*2, hit,0RETURN

Build the Baseframe and CablesAdd the extra parameters required for the frame andcables, then build them using TUBE and CONE. Thesesections are fairly straightforward for the confidentVoyager. Simple assumptions are made here for cablediameters.

Tents: continued

Swing the Cat! tomake the hole-

ring

CappingThe parameters for the domed capping were workedout in the Master script. It’s smoothly bonded to themembrane and the RESOL of the dome matches the‘smoth’ parameter to make sure that lines and poly-gons are continuous. This is done by working out theANGLE of the membrane as it reaches the top holeand continuing the curvature of the dome at the sameangle. This detail would be used for a membrane thatwas pushed from below by a mushroom head sup-port. With this option selected, the top ring and cablesdisappear. The membrane designer could provide amushroom head detail.

The conical fabric cape is floating just above thering, and you can extend the upper length of thekingpost to project through the top of the cape.

This continues theline of the membrane

at the same angle

IF hit>A/2.1 THEN PARAMETERS zzyzx=A/2.1IF hit<A/10 THEN PARAMETERS zzyzx=A/10

VALUES 'capst' 'Hole with cables', 'Fabric cone with cables', 'Rounded membrane cap'

Parameter ScriptThis little routine is to stop the height being stretchedto the point where the circle chord would exceed90˚. It works in harness with the lines at the start ofthe Master script

EndnoteTents take many forms, and you will often achieve whatyou need by scratching around with the mesh tool, orbringing in a mesh from other software. I hope that,for you, this is a starting point for parametric tents.

Byzanti
Highlight
Page 286: Cookbook3_1

2.183

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Making ChoicesA way to use binary maths to make a choice

WHEN we want to offer our user a choice, we almost always offer a Value list, either in text or

number form, or in a pictorial form in the User Inter-face. In earlier versions of ArchiCAD, if we had 25 dif-ferent door styles, we were offered ‘Style of Door 1-25’. There was no hierarchy about it, the task was sim-ply to select one from a list of 25, with no pictures ordescriptions to guide us.

There are occasions when the choice is too subtleand interactive, and neither of the above works. As acase study, I have extended the Tent structure in thenearby pages. Dwight asked me to provide a set ofstiff edge hoops so that if the tent is at the edge of thebuilding, the form of the membrane is maintained.There are many conditions – of the four sides, youcould have no hoops, one hoop on any of the sides, 2hoops adjacent or opposed, 3 hoops, or 4 hoops. Ifyou are free to rotate the object, there are in fact only 6choices and a Value list could easily deal with this.

There are cases where the choice involves the fullrange of combinations. Four distinct possibilities comesup with 16 combinations. If this tent had a wide rangeof edge conditions, such as one side coming down thebase frame, another ending in a pointed edge (as onthe real version of this which I had to do just beforepublication) you could try using the Binary system tohelp you.

In PRISM masking we are used to the idea that 4options makes 16 choices. Bottom line=1, Side line=2,Top line=4, Face=8. Any number from 0 to 15 can iden-tify and include any combination of these. In the case

No HoopsHoop on one sideHoops on 2 sides adjacentHoops on 2 sides opposedHoops on 3 sidesHoops on 4 sides

!Tent form

GOSUB 200:!Corner Points + FrameGOSUB 210:!Cables lowerGOSUB 300+cs:!CappingGOSUB 400:!Edge Hoops

END:!__________________

400:!Edgehoops – Binary analysisIF edghp>=8 THEN GOSUB 410 edghp=edghp-8 ENDIF

IF edghp>=4 THEN ROTz 90 GOSUB 410 DEL 1 edghp=edghp-4 ENDIF

IF edghp>=2 THEN ROTz 180 GOSUB 410 DEL 1 edghp=edghp-2 ENDIF

IF edghp>=1 THEN ROTz 270 GOSUB 410 DEL 1 edghp=edghp-1 ENDIFRETURN

410:!one edgehoop!Parabolic pathway

span=A stp=(span/2)/smothFOR k=-span/2-stp TO span/2+stp+0.01 STEP stp x=A/2 y=k z=bulg-(4*bulg/(span^2))*k^2 PUT x,y,z,0 NEXT k

MATERIAL tubmatRESOL 6BODY -1TUBE 2,NSP/4,63, 0,0,901, trad/2,360,4001, GET(NSP)RETURN

of the tent, with 4 sides, we could have South side=1,West side=2, North side=4 and East side=8. Any com-bination of numbers from 0 to 15 will identify whichones we want, because we can do a binary analysis ofthe numbers. 11 must include an 8, and you have aremainder of 3. So that must be 2 and 1.

In GDL, I present you with an easy way to do abinary analysis. You will also find a perfect demon-stration of parabolic arch building.

Parameters: Add in one more parameter, edghp

Procedure: Write IFstatements, progressively

looking for the largestnumber possible, and if

found, draw the 3Dedgehoop, deduct that

number, and then continueto the next lowest binary

number.

Whenever possible,find a way of offeringchoice through Valuelists. This tiled imagecould be the basis of apictorial Value list.

This is a perfect demonstration of how to produce a parabolicarch using the TUBE statement. The procedure runs from -span/2 to span/2 (passing through zero on the way). TUBEneeds the phantom points, so the loop must start one step earlier,and finish one step later than the real arch pathway.

Page 287: Cookbook3_1

2.184

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Planning drawing: Do this freehand. The gourd canbe made in FOUR curved tiles, and the zero point willbe at the mid-height. If you re-read the pages onCOONS, you will see that the corners have to be num-bered, and the sequence in which the numbers aregiven to the COONs statement are strictly in the order:1>2, 4>3, 1>4, 2>3. Many COONS shapes can be builtby getting those corners right and just guessing andinserting the middle points. You can use ArchiCAD todo the guessing for you.

Draw out the shapes: The three main outlines in planare drawn. Plan to have a consistent number of pointsat each level. In this case, there are 8 points in planand in the vertical seams there are 5 points. With thehelp of smoothing in photorendering there is no needto put in more points. Here I have used the FILL tool tostart off with, but later, I used the magic wand to changethem to slabs because slabs are transparent. When youstart overlaying more fill shapes (right) you need tosee the ones underneath. You can see the final draw-ing, using slabs where all the lines of the gourd aredrawn.

Gourd with COONSTHIS gourd was made for a student who wanted to

build gourd shaped buildings, based on the Pitcherplant (that attracts insects, then digests them in its stickyinterior). I am not sure where he plans to put the dooror what he plans to do with the people inside!

Although you may never build a gourd, it is a per-fect example of building a complex shape using theCOONS command. I have used it for boat and aero-plane hulls. It uses as little GDL as possible, surpris-ingly – it’s all about stealing from ArchiCAD, and usingsome knowledge of GDL to tweak it into shape. Onceyou know what you are doing, it is approximately halfan hour’s work!

It is important to build around the Origin, as wedraw out slabs and drag them, one at a time into theGDL script windows. The first thing to do is to planhow the gourd will be built.

Outline ofthe ‘fat lip’

Plan outlines ofthe gourd, top,

middle andbottom.

Line of thevertical

seam

Line of the top rim,viewed from the side

These vertical and horizontal lines provide guaranteed‘snapping’ (gravity). This gourd was made in 30 mins withno errors, even though ArchiCAD is working to 6 decimals.

Copy and Rotatethe plan outlines,

to enable you toknow the start

and end pointsfor the vertical

seams.

This technique oftiling and joining

COONS shapescan be applied

successfully to softfurnishing andvehicle forming

problems

Byzanti
Highlight
Byzanti
Highlight
Page 288: Cookbook3_1

2.185

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Dragging and dropping: The slabs have to bedragged over one at a time, and dropped into the 3Dscript window of a new object. The 3D script windowmust be floating free of the object palette for this towork. Here is the first slab, the outline of the mid-heightplan-line of the gourd. It comes as a cPRISM. cPRISM_ "Whitewash","Whitewash","Whitewash", 9, 0.2, 0.0, 0.44148, 15, 0.0, -0.397114, 15, 0.172577, -0.377148, 15, 0.356269, -0.261342, 15, 0.456102, 0.0, 15, 0.408182, 0.225841, 15, 0.276403, 0.377587, 15, 0.116671, 0.44148, 15, 0.0, 0.44148, -1

As these are points from nodes 1 to 2, put in a com-ment, and massage the points. The slab is closed, sothe start and end points are included. Remove the startpoint so that the line of points moves systematicallyfrom nodes 1 to 2. Put a PUT in front of them, youhave the first part of your COONS made. !1>2 PUT 0.0, -0.397114, 0, 0.172577, -0.377148, 0, 0.356269, -0.261342, 0, 0.456102, 0.0, 0, 0.408182, 0.225841, 0, 0.276403, 0.377587, 0, 0.116671, 0.44148, 0, 0.0, 0.44148, 0

Make all the heights (Z values) zero. Do the same fornodes 4 to 3.

On the ArchiCAD file one rotates copies of the slabsaround the origin so you can see how far they projectsideways. Then you can draw single lines vertically andhorizontally to establish how far the gourd rises verti-cally. By doing this, you know that when you drawslabs for the vertical sides, you will get gravity (snap-ping to the line) to help get a perfect fit. Using gravity,all these figures used in this exercise were obtained to6 figure precision without any fudging – I promise!

To get the heights for points from nodes 4 to 3, youhave to drag over the slab which delineates the upperside profile of the gourd. The Y-Values in the prismgive you the heights.cPRISM_ "Whitewash", "Whitewash", "Whitewash", 9, 0.2, -0.600773, 0.545306, 15, -0.490312, 0.561279, 15, -0.274673, 0.605205, 15, 0.044791, 0.693058, 15, 0.316336, 0.804871, 15, 0.631807, 0.944636, 15, 0.819492, 1.040476, 15, 0.988563, 1.188228, 15, -0.600773, 0.545306, -1

The Y values here need to be painstakingly copied andpasted to form the Z values of the points from nodes 4to 3. copy them, Then throw away the prism. This takestime, but if you keep your head and have drawn yourslabs well, it will work. Ensure that your XYZ loca-tions for the primary nodes are correct and match eachother. After massaging, the points for nodes 4 to 3 looklike this:

Straight sides (left) and shapely sides (right)

It’s time to add some material and pen colours. Thevariable rm is included because it helps to see if theCOONS is working corectly – it shows all the lines ofthe polygons in the surface.

!4>3PUT 0.0, -0.600773, 0.545306, 0.308349, -0.544867, 0.561279, 0.575901, -0.321242, 0.605205, 0.663753, 0.0, 0.693058, 0.607847, 0.337654, 0.804871, 0.380229, 0.677085, 0.944636, 0.136637, 0.856784, 1.040476, 0.0, 0.988563, 1.188228

Now, to get a quick result, copy and paste points 1, 2,3 and 4 below the work you have already done andmake the sides straight. Be careful to put PUTs andcommas in the right place.

!1>4 PUT 0.0, -0.397114, 0, 0.0, -0.600773, 0.545306

!2>3 PUT 0.0, 0.44148, 0, 0.0, 0.988563, 1.188228

This routine uses COONS with 8 points along the topand 2 downwards (until we add in the more detailedpoints). Introduce a MULx -1 to make the COONS mir-ror and you have the top half done. PEN pcol MATERIAL gourdmat COONS 8,2,63, USE(NSP) MULx -1 COONS 8,2,63, GET(NSP) DEL 1

Then you can drag the slab to discover the lines whichtrace out the vertical seam of the gourd.

cPRISM_ "Whitewash", "Whitewash", "Whitewash", 7, 0.2, -0.397114, 0.0, 15, -0.397114, 0.090069, 15, -0.414439, 0.225841, 15, -0.454372, 0.3696, 15, -0.600773, 0.545306, 15, -0.118934, 0.337654, 15, -0.397114, 0.0, -1

Page 289: Cookbook3_1

2.186

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

This is how the slab comes in for nodes 1 to 4. Docu-ment it with a comment. Now, because X is zero onthis line, insert a zero before each number, and knockoff the old masking codes. Reduce the list to the 5 sig-nificant points. Then you remember to change thenumber of points in the COONS statement from 2 to 5.You can also add to the object masking, 64*rm (rough-ness masking) which allows you to switch on the vis-ibility of the polygon lines.

!1>4 PUT 0, -0.397114, 0.0, 0, -0.397114, 0.090069, 0, -0.414439, 0.225841, 0, -0.454372, 0.3696, 0, -0.600773, 0.545306 PEN pcol MATERIAL gourdmat COONS 8,5,63+64*rm, USE(NSP) MULx -1 COONS 8,5,63+64*rm, GET(NSP) DEL 1

There isn’t space to take this through every step. Lookat the gourd object on the GDL Cookbook CD (alongwith all its slabs) and you can getthe idea more clearly.

The next stage is to apply the same technique to thebottom section of the gourd. It is much easier secondtime round.

Put a ‘fat lip’ around the topThis requires a TUBE to follow round the upper linefrom nodes 4 to 3. It’s easy because you have alreadydone the work of defining points from nodes 4 to 3.Trace an outline of the lip with a Fill tool because ithas the similar syntax to the profile for TUBE. Copythis fill across to a 2D script window. Massage thesepoints and move them to the 3D script. For some rea-son, TUBE inverts the profile, so I had to change thesign of the X values.

POLY2_B 13, 3, 1, 91, 0.0, -0.034897, 1, -0.038289, 0.0, 1, -0.027938, 0.06085, 1, 0.0, 0.08414, 1, 0.05487, 0.097079, 1, 0.129915, 0.089315, 1, 0.160968, 0.045324, 1, 0.137678, 0.016858, 1,

The gourd shape, with theCOONS finished and working

The lines can be displayed on the surfaceby adding 64 to the object masking.

The finished gourd, including the‘fat lip’ around the opening.

0.106625, 0.011683, 1, 0.072985, 0.019446, 1, 0.036756, 0.009095, 1, 0.036756, -0.024546, 1, 0.0, -0.034897, -1

The routine here uses a crafty little device to count upthe profile points. Use this in other TUBEs.

!Fat lip around the rim!Profile of the Lip (x-values reversed sign) PUT 0.0, -0.034897, 1, +0.038289, 0.0, 1, +0.027938, 0.06085, 1, -0.0, 0.08414, 1, -0.05487, 0.097079, 1, -0.129915, 0.089315, 1, -0.160968, 0.045324, 1, -0.137678, 0.016858, 1, -0.106625, 0.011683, 1, -0.072985, 0.019446, 1, -0.036756, 0.009095, 1, -0.036756, -0.024546, 1, 0.0, -0.034897, -1

profpts=NSP/3 !Profile Points

!4>3 PUT -0.308349,-0.544867,0.561279,0,!phantom

0.0, -0.600773, 0.545306, 0, 0.308349, -0.544867, 0.561279, 0, 0.575901, -0.321242, 0.605205, 0, 0.663753, 0.0, 0.693058, 0, 0.607847, 0.337654, 0.804871, 0, 0.380229, 0.677085, 0.944636, 0, 0.136637, 0.856784, 1.040476, 0, 0.0, 0.988563, 1.188228, 0,

-0.136637, 0.856784, 1.040476, 0 !phantom

pathpts=(NSP-profpts*3)/4 !Path Points

TUBE profpts,pathpts,63, USE(NSP) MULx -1 TUBE profpts,pathpts,63, GET(NSP) DEL 1 DEL TOP END:!----------------------------------

At the head of the script put in your rotation commands:ROTx rottx: ROTy rotty

...and your object is now finished.

You will get many error messages at times with thismethod, but read the error messages, correct the er-rors with commas or whatever, and you will succeedin making shapely objects with only the minimum ofGDL. It is much easier than the Tent!!

Page 290: Cookbook3_1

2.187

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Furniture Legs! – and how to make them

A serious use for the GOURD exercise is in themaking of soft furnishing. You just cannot get

away with making this using PRISM and BLOCK.A working knowledge of COONS and MASS is es-sential. In fact, apart from Tents, soft furnishing callson the courage and stamina more than almost anytask in GDL. In this soft furniture, there are 8 dif-ferent choices of leg style, including a soft wavyfringe (based on the Curtain object in the Cook-book).

This exercise looks at LEGS. The main com-mands are SWEEP and CUTPOLYA. The routinescould easily be adapted and patched into some fur-niture you are working on, or called as a macro.The legs here are made with three methods:

• SWEEP – for the Sabre leg shape (lower right)• Cabriole, with CUTPLANE (lower left)• Cabriole, with a claw foot using CUTPOLYA (left)

– For the the Cabriole legs, draw out a shape us-ing the Fill tool. Set yourself a standard height, hereit is 450mm (1’-6”). You can use MULz to make smalladjustments in height.

– For the Sabre leg, just trace out the pathway thatwill be followed by the square section, using theFill tool.

Do both of these on the Origin of the project file,and drag the fill into the 2D script window of yournew Library part.

This diagram shows how we cut the two versions of theCabriole leg. The simple one is cut by two angledCutplanes. Their angle is determined by a formula basedon the height, and on the top and bottom section sizes.The better Cabriole is much more difficult. This involvesusing both the same Cutplanes, but adding two circularCutpolyA shapes either side of the leg – to carve it so thatthe lower portion is like a claw foot.

When you embark on anything like this, do lots of draw-ings on paper. Drawing it in ArchiCAD helps too, espe-cially this one with arcs and cutting lines and centre axes.

These leg subroutines can be copied andpasted into a larger chair or called asmacros

Outline ofCabriole leg

Pathway ofsweep forSabre leg

Centre axisthrough origin

Line of Cutplanefor Cabriole leg

Line of circularCutpolyA. Centreand Radius arecalculatedmathematically

Centreline is 0.35of height of theleg so that the topis fatter

Arc passesthrough foot

VALUES 'legtype' 'Sabre', 'Cabriole simple', 'Cabriole better'In a professional furniture item you either make theleg as it is in the real item, or you offer the choice thatare provided by the manufacturer. The sofas above have8 different leg styles.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 291: Cookbook3_1

2.188

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

!Leg building

IF legtype='Sabre' THEN ls=1IF legtype='Cabriole simple' THEN ls=2IF legtype='Cabriole better' THEN ls=3

GOSUB 100+ls

END:!-----------------

101:!Leg SabreMATERIAL legmatMULz leghit/0.45!Height adjustPUT 0.0,0, 0.0, 0.019917, 0, 0.05448, 0.040903, 0, 0.118731, 0.063012, 0, 0.196965, 0.075097, 0, 0.247865, 0.089533, 0, 0.327075, 0.096902, 0, 0.393513, 0.099, 0, 0.45nstp=NSP/3-1 !Number of steps

!Scaling with each stepsca=(ltsec/lbsec)^(1/(nstp))SWEEP 5,NSP/3,0,sca,63-32, 0, lbsec/2, 0, -lbsec, lbsec/2, 0, -lbsec,-lbsec/2, 0, 0, -lbsec/2, 0, 0, lbsec/2, 0, GET(NSP)DEL 1RETURN

102:!Leg Cabriole simpleMATERIAL legmatMULz leghit/0.45 !adjusts the height ADDy -lbsec/2 ROTx 90 ROTx ATN(((ltsec-lbsec)/2)/leghit) CUTPLANE DEL 3

ADDy lbsec/2 ROTx -90 ROTx -ATN(((ltsec-lbsec)/2)/leghit) CUTPLANE DEL 3

ROTx 90ADDz -ltsec/2PUT -0.025314, 0.45, 1, -0.025314, 0.430845, 1, -0.04828, 0.424466, 1, -0.067418, 0.40788, 1, -0.078901, 0.377259, 1, -0.078901, 0.356845, 1, -0.077625, 0.322396, 1, -0.066142, 0.277741, 1, -0.0141, 0.063608, 1, -0.020211, 0.04298, 1, -0.034245, 0.041704, 1, -0.040625, 0.048083, 1, -0.052755, 0.043916, 1, -0.0564, 0.02737, 1, -0.052108, 0.013635, 1, -0.027866, 0.002152, 1, -0.010004, -0.0004, 1, 0.004031, -0.0004, 1, 0.017991, 0.014742, 1, 0.023825, 0.033705, 1, 0.023169, 0.057014, 1, -0.024038, 0.304534, 1, -0.021487, 0.324948, 1, -0.012555, 0.340258, 1, 0.002755, 0.346638, 1, 0.024445, 0.347914, 1, 0.024445, 0.45, 1, -0.025314, 0.45, -1EXTRUDE NSP/3,0,0,ltsec,63,GET(NSP)DEL 3CUTENDCUTENDRETURN

103:!Leg Cabriole betterMATERIAL legmatMULz leghit/0.45 !Height adjust!Circular Cutplaneclen=leghit*0.7 !Chord lengthlbul=ltsec/2-ltsec/3 !Leg bulge!Formulae from the Maths Primerlang=(90-ATN((clen/2)/lbul))*2 !cutting anglelrad=(clen/2)/SIN(lang) !leg cutting radius

ADDy lrad+lbsec/3 ADDz clen/2 ROTy 90RESOL 120!CIRCLE lradCUTPOLYA 2,1,0, 0,0,913, lrad,360,4013 DEL 3

ADDy -(lrad+lbsec/3) ADDz clen/2 ROTy 90RESOL 120!CIRCLE lradCUTPOLYA 2,1,0, 0,0,913, lrad,360,4013 DEL 3

RESOL 36

ADDy -lbsec/2 ROTx 90 ROTx ATN(((ltsec-lbsec)/2)/leghit) CUTPLANEDEL 3

ADDy lbsec/2 ROTx -90 ROTx -ATN(((ltsec-lbsec)/2)/leghit)CUTPLANE DEL 3

ROTx 90 ADDz -ltsec/2PUT -0.025314, 0.45, 1, -0.025314, 0.430845, 1, -0.04828, 0.424466, 1, -0.067418, 0.40788, 1, -0.078901, 0.377259, 1, -0.078901, 0.356845, 1, -0.077625, 0.322396, 1, -0.066142, 0.277741, 1, -0.0141, 0.063608, 1, -0.020211, 0.04298, 1, -0.034245, 0.041704, 1, -0.040625, 0.048083, 1, -0.052755, 0.043916, 1, -0.0564, 0.02737, 1, -0.052108, 0.013635, 1, -0.027866, 0.002152, 1, -0.010004, -0.0004, 1, 0.004031, -0.0004, 1, 0.017991, 0.014742, 1, 0.023825, 0.033705, 1, 0.023169, 0.057014, 1, -0.024038, 0.304534, 1, -0.021487, 0.324948, 1, -0.012555, 0.340258, 1, 0.002755, 0.346638, 1, 0.024445, 0.347914, 1, 0.024445, 0.45, 1, -0.025314, 0.45, -1EXTRUDE NSP/3,0,0,ltsec,63,GET(NSP)DEL 3CUTENDCUTENDCUTENDCUTENDRETURN

This formula isthe biggest

learning point ofthe exercise:

it provides accuratecontrol to the size ofthe SWEEP at the toprelative to the bottom

We made theoutline with a

2D fill becausethe syntax of

EXTRUDE andPOLY2_B aresimilar – noextra typing

required, justdrop it in!

Use PUT & GETand you do not

have to countthe points

Make the whole leg the thicknessof the top portion, then cut it

back with two CUTPLANEs

This formulaworks out the

angle of cutting

These Circle Geometryroutines are in theMaths primer: for

working out the angleand radius

You need a high RESOL tomake this look any good.

Don’t over do it. ExcessiveRESOL with CUTPOLYA

will crash ArchiCAD(insufficient memory)

Put a Planar 3D CIRCLEjust before the CUTPOLYA

to make sure that it’s inthe right place. Then hide

it once the routine isworking

Revert RESOL toprevious value

Sameroutineas for the

simple Cabriole leg

If the leg outlineis identical, as

here, you couldmake it into a

separatesubroutine and

call it each time,once it’s

incorporatedinto a larger

program for achair or table

All of these aremade to thesame height

(0.45m) andadjusted with a

MULz command

Temporary CIRCLEshows the cut

happening

Page 292: Cookbook3_1

2.189

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

– Check ‘Library Part Name’ in the ‘Global Element Parameter’ list.1.6. on the fourth (List Format) tab-page:– Select ‘Text List’.– Set <Group & Count Identical > in the ‘Elements’ pop-up menu.

Answer:The easiest way to do this job isto set up two separate listschemes:

1. Zones with all included objecttypes summarized (subtotal byzones)

2. Object types summarized forthe whole project (grand total)

- and then merge the two reportstogether. Here is a step by step‘How-to-do-this’.

Exercise 11.1. Choose Calculate/Setup List

Schemes... to open the dialog box.1.2. Duplicate one of the Zone list

schemes and name it e.g. ‘Objectsby Zones’.

1.3. On the very first (Zones) tabpage, be sure to set filters appro-priately: if you want to list allzones, check all stories, all zonecategories, etc.

1.4. On the second (Properties & Pa-rameters) tab page:

– Set <None> in the ‘Components’,‘Descriptors’ and “Library part’sadditional parameters” pop-upmenus.

– Enable objects (click the chair icon)in the ‘Enable Listing of related El-ements’ box.

– Set <All> in the ‘Linked PropertyObjects’ pop-up menu.

– Check ‘Zone Name’ and ‘ZoneNumber’ in the ‘Zone Parameters’list.

1.5. On the third (Related Elements)tab-page:

– Set <None> in the ‘Components’,‘Descriptors’ and ‘Library part’s ad-ditional parameters’ pop-upmenus.

READERS are always asking for this to be discussed in the Cookbook. It’s notstrictly GDL, but it does touch on GDL, in the making of Property objects, and

giving GDL objects proper descriptions in their property scripts – so let’s look at it.Laszlo Vertesi of Graphisoft HU has kindly supplied this easy tutorial which I haveworked through and for which I have provided some illustrations and added com-ments. If this makes it a tiny bit easier then it’s worth the effort.

Question: I have a large office building that I'm working on. I have used the'zone' tool to set out different departments. I have now set out the variousworkstations/chairs etc. How do I get a list of these elements grouped in theirdepartmental sub-headings with totals and a grand total?

Calculate Menuby Laszlo Vertesi – illustrated by DNC

Zones tab page

Properties and Parameters tab page

Byzanti
Highlight
Page 293: Cookbook3_1

2.190

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

– Be sure to have the following parameter list at the bottom:01 Zone Number02 Zone Name03 Library part name

1.7. Click OK and choose the previously saved List Schemefrom Calculate/List Zones. You will get a list like this:

Exercise 22.1. Choose Calculate/Setup List

Schemes... to open the dialog box.2.2. Duplicate one of the Element list

schemes and name it e.g. ‘Objectstotal’.

2.3. On the very first (Elements) tabpage, be sure to set filters appro-priately: check Objects (chair icon)under ‘... by Types’, check all sto-ries, all zone categories, etc.

2.4. On the second (Properties &Parameters) tab page:

– Set <None> in the ‘Components’, ‘Descriptors’ and‘Library part's additional parameters’ pop-up menus.

– Check ‘Library Part Name’ in the ‘Global ElementParameter’ list.

2.5. On the fourth (List Format) tab-page:– Select ‘Text List’.– Set <Group & Count Identical > in the ‘Elements’ pop-

up menu.– Be sure to have the following parameter list at the bottom:

03 Library part name

2.6. Click OK and choose the previously saved List Schemefrom <Calculate/List Elements>. You will get a list show-ing only the grand total for each object type.

Properties & Parameters tab page

List Format tab page

| Zone Name | Zone Number | Library Part name------|-----------|-------------|------------------ 1 | Boardroom | 004 | / 13 | / | / | boccaciochair 1 | / | / | fire_extinguisher 1 | / | / | pot_put 1 | / | / | tablestorey 3 | / | / | table_02 1 | Office | 001 | / 1 | / | / | fire_extinguisher 1 | / | / | swivel_chair 1 | / | / | table_02 1 | Reception | 002 | / 1 | / | / | fire_extinguisher 2 | / | / | swivel_chair 1 | / | / | table_02 1 | WC | 003 | / 1 | / | / | WC_armsh_601------|-----------|-------------|------------------

---------|------------------ 13 | boccaciochair 1 | Filestamp 3 | fire_extinguisher 1 | pot_put 3 | swivel_chair 1 | tablestorey 5 | table_02 1 | WC_armsh_601---------|------------------

Note: There is a way to get subtotals and grand totalwithin the same list. This requires a complete listingenvironment, not only setting up a list scheme. We lookat this next.

Byzanti
Highlight
Page 294: Cookbook3_1

2.191

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Exercise 3Creating the ‘Object Counter’Property Object3.1. Choose Calculate/New Properties – a blank

Property object editor opens up.3.2. Click the Property Script button to open it.3.3. Copy the following two lines into the property

script:

dummy = REQUEST ("Name_of_Listed", "" , name) COMPONENT name , 1 , "", 1 , name

3.4. Save the Property Object under the name e.g.‘Object Counter’, into a loaded library. Note: this ob-ject will generate a separate column for the Quan-tity (number) of each object type (name).

Exercise 4Linking ‘Object Counter’ To TheObjectsAlternative I – Individual Link4.1. Select all objects to be included in the list.4.2. Open the Object Settings Dialog.4.3. Go to the Listing Atributes tab-page (click the cal-

culator icon on the right).4.4. Enable the ‘Link Properties: Individually’ checkbox

to open the Link Properties dialog box (be sure todisable the ‘Link Properties: by Criteria’ checkbox)

4.5. Select ‘Object Counter’ in the list and click link(make sure to see ‘Object Counter’ under thecheckbox as you return to the Object SettingsDialog).

4.6. Click <Link> to establish the link.

Note: Objects placed afterwards have to be linked in-dividually

Exercise 5Alternative II – Dynamic Link By Criteria5.1. Choose Calculate/Link Properties to Criteria.5.2. Select a Database Set in the ‘Show Links in’ pop-

up menu.5.3. Click ‘New Link’, then click ‘Edit Criteria...’ the Cri-

teria Selector opens up.5.4. Set the ‘Find Elements:’ pop-up menu to <Of

Type>> >, and select Object (chair icon) in the pop-up palette on the right.

5.5. Click Apply and return to the Link Properties toCriteria dialog.

5.6. Close the dialog and save the criteria as you willbe prompted.

5.7. Select all objects to be included in the list.5.8. Open the Object Settings Dialog.5.9. Go to the Listing Atributes tab-page (click the cal-

culator icon on the right).5.10. enable the ‘Link Properties: by Criteria’ checkbox

to open the Link Properties dialog box (be sure todisable the ‘Link Properties: Individually’ checkbox)

Note: if you have other existing links in the list forobjects, they can be in conflict with this criteria for aparticular object: additional links can be valid as well,or more specific links can be applied instead of thislink.

Exercise 6Setting Up The List Scheme6.1. Follow the steps from 1.1. to 1.6. or Duplicate the

existing ‘Objects by Zones’ list scheme and name itas e.g. ‘Objects by Zones + Total’.

6.2. on the third (Related Elemets) tab-page:– Set <Object Specific items Only> in the

’Components’ pop-up menu.– B sure to check ‘All’ above the Keys list.6.3. on the fourth (List Format) tab-page:– Be sure to have the following parameter list at the

bottom:01 Zone Number02 Zone Name03 Library part name04 Local Component(s)

6.4. Click OK and choose the previously saved ListScheme from Calculate/List Zones>. You will get asmany columns additionally to the ‘Objects by Zones’list, as many different Object types (names) you havein the project, with the total number of each type atthe bottom of the column, like this:

| Desk 65 | Office Chair1 65 | Office Chair2 65-|------------|------------------|------------------ | / | / | / | 2.000 | | | | 2.000 | | / | / | / | 3.000 | | | | 1.000 | | | | 2.000 | / | / | / | 2.000 | | | | 2.000 | | / | / | / | 2.000 | | | | 1.000 | | | | 1.000 | / | / | / | 2.000 | | | | 1.000 | | | | 1.000-|------------|------------------|---------------- | 11.000 | 7.000 | 4.000

Editor’s note: The best way to learn anything is to doit (or teach it!), so a project-based approach is, for me,the answer. After working one’s way through this, theCalculation Guide manual doesn’t look nearly as mys-tifying as it did. However, this has just scratched thesurface. The whole matter of Graphic templates is outthere, waiting for the Cookbook style treatment.

Best Regards from the development team, Laszlo Vertesi --- Product Design

The Cookbook is for life, not justfor Christmas!This book shouldn’t be used just to learn a few bits of GDLand then put aside while you struggle to make furtherprogress. The author uses the Cookbook as a GDL manualand as a ‘Memory Bank’. By making so many routines vis-ible (and findable through the index) it is a continuing re-source for the whole of your GDL career.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 295: Cookbook3_1

2.192

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Special Menu functionsThe first 4 lines seem to do nothing.

Save GDL: saves your file as a set of GDL primitives,and you can opt to save some aspects of the file suchas the linetypes or material definitions. This only workswhen you have the 3D drawing displayed. This is in-credibly useful. You can save a list of Materials for yourpresent project. Save this list as Master_GDL.GDL andput it in your project Library. It will rebuild your mate-rials list next time you open the file. That means youcannot get caught out if you open your old project witha newer copy of ArchiCAD – because it will rebuild allyour materials from that file. Just remember to keepyour textures folder.

Special hidden line: shows a dialog box: you willget the hidden lines visible in a 3D view. You also haveto tick the options on the next block, such as Showspecial lines, and set contours to Best in 3D windowsettings – shows hidden lines on shaded views.

Use section tool in 3D: It’s easier to set up 3D sec-tions than with 3D cut-away, and shows the correctmaterials along the cut line.Very Useful!

Render w/o Autosave: normal rendering saves a tem-porary copy of the render in the System folder – todisplay in case you restore after a crash. W/o disablesthis (saves disk space).

Place all objects: This places all objects from theloaded libraries into the floor plan. Beware that youdo not have the entire ArchiCAD Library loaded (takea long coffee break). It’s extremely useful for check-ing out a library of parts that you have built. They willbe placed with default parameter settings.

Place all windows/doors: This does the same thing,but builds some walls and places your windows anddoors into them.

Update library parts: This is unbelievably powerful,but use with caution. Copy your library first, OpenArchiCAD and load the Copy of the Library – not theoriginal! Unload the original. It can romp through yourloaded library rewriting bits. Configure your

Special MenuTHERE is a hidden menu called SPECIAL which is used by programmers at Graphisoftfor debugging, and can be enabled by users with a bit of daring. Some of the com-mands are dangerous, so try them out only on copies of your project files and libraryobjects, not originals.

When you boot up ArchiCAD hold down the Alt-Cmd (or Alt-Ctrl keys on PC) toenable this menu. Alternatively, you can make SPECIAL menu permanently avail-able with RESEDIT on the Mac or Registry Editor on the PC.

On the Mac, find the ‘menu’ resource, find ‘special’ and enable it. For 6.5 you willfind this in the ‘ArchiCAD Resources 1 file’. On the PC, find the flag for the ‘specialmenu’ and change it from 0 to 1.

Since ArchiCAD 6.x permits <Transparency in 3D views> and <Rebuild EachFrame>, I have not used this Special menu much, so do not fret if you cannot get itworking. But here is a run down of some of the features in the Special Menu.

For the serious GDL developer, these functions are incredibly useful!

photorendering set-tings, set this runningand it will build andattach new previewimages to every objectin the loaded library!(deleting all the pre-vious preview im-ages). For a FrenchGDL writer convert-ing objects from Eng-lish, you can dump allthe parameter de-scriptions, have themtranslated into French, then reimport them and all yourobjects will be rewritten in French (make sure you didthis to a copy of your original library!). You can dumpall the scripts of the loaded library. This is excellent forrecord keeping and for a company who wishes to keepa text record of all the scripts. This can be used formaintenance, training, protection of copyright and con-version of objects to other versions, such as older ver-sions of ArchiCAD or foreign language versions. Savesaves to disk – this cannot harm your objects. Loadwrites to your objects – you have been warned!

Purge Library parts: this removes *.gs&, *.do& filesand other bits of garbage from old Library folders. itdoesn’t remove cache files, or objects that are not pres-ently in use.

Capture Defaults: Updates your ArchiCAD prefer-ences file in the System folder.

Capture Defaults (Text): writes a vast number of textfiles into your ArchiCAD folder recording all the de-faults at that time. These can be opened with a texteditor, but you cannot do much with them.

Set Undo queue: There are other ways of doing this,but the valuable feature is that it shows you the numberof Undos in the current stack.

Set Vector fill origin: See the Voyager exercise oncasting shadows with Alph channels.

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 296: Cookbook3_1

2.193

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

DEFINE MATERIAL "teststuff1" 0, 0.64802, 0.638315, 0.574136, 0.8, 0.9, 0.15, 0, 1, 0, 0.894743, 0.861753, 0.786999, 0, 0, 0, 0

DEFINE MATERIAL "teststuff2" 20, 0.42179, 0.424506, 0.37705, 0.8, 0.9, 0.05, 0, 1, 0, 0.463569, 0.453376, 0.397696, 0, 0, 0, 0, IND(FILL, "Empty Fill"), -1,0

This set of definitions from the Master_GDL.GDL file appearsin the Materials list.

Master_GDL.GDLWhat does this do?

Master_GDL.GDL is a GDL script that is read and actedupon when you open ArchiCAD, providing it is in yourloaded library. This is the best place to store Materialdefinitions. If a project is shared between people withdifferent versions or in different countries, there couldbe chaos if some operators have different materialnames. For example, ‘Whitewash’ has a different namein every language. In fact, I have known such chaosoccur in the same room, between two people one ofwhom had been prolifically creating new materials and

deleting unwanted ones. All the material indexes wereredistributed, so that GDL objects placed on the othermachine came out with totally unexpected textures.

We read earlier how you can get the Special Menu/Update Library parts command to dump a GDL textfile of all your Material and Line and Texture defini-tions. If you do this and call the file Master_GDL.GDL,it makes an absolute record of all the definitions at thismoment in time.

According to the GDL manual, this file can do morethan Material and similar attributes. It can include Valuelists, Global Variable initialisations and even some 3DGDL commands. The 3D GDL commands will appearat the Origin of the project, but as they do not have a2D script, you cannot see them unless you view theproject in 3D.

Make your Building Grow!by Mick Kingsbury

THIS is a way of making an impressive movie foryour client – or perhaps to demonstrate the 4D nature of

the building process. You can give the impression that yourbuilding is growing.

Firstly build your model within ArchiCAD. Then save it asa GDL object. Then using the following GDL script, call theobject that you’ve modelled so that it can build up from thebase to the top. Set one camera looking at the object, andwhen the view is perfect, duplicate the camera and place itover the first. In the camera Path Settings, set ‘Camera mo-tion controls’ to ‘Polygon, Open’. Tick ‘Rebuild each frame’.Select the Cutter, not the object to be cut.

Then run the flythrough. If there are other cameras in themodel already, make a new cameras layer/path, and place your new cameras in that. Ad-just the number of frames in the path forsmoother motion.

With modification to the scripting youshould be able to set the start frame and fin-ish frame for your object to appear and growwithin your animation. A circular CUTPOLYAwould make an even more interesting effect.

!3D ScriptPEN 01ADDz (N_+1)/(P_+1)*ht CUTPLANE tiltxDEL 1CALL nam PARAMETERSCUTEND

!2D ScriptCIRCLE2 0,0,ht/2LINE2 -ht/2,0,ht/2,0HOTSPOT2 0, 0HOTSPOT2 -ht/2,0HOTSPOT2 0,-ht/2HOTSPOT2 -ht/2,0HOTSPOT2 0, ht/2HOTSPOT2 ht/2,0

‘Kingsbury’s Cutter’

Byzanti
Highlight
Byzanti
Highlight
Byzanti
Highlight
Page 297: Cookbook3_1

2.194

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Speed up your RenderingEric Bobrow’s adviceCheck out the 3D Image Items command under the Im-age menu. There are some little known options that al-low you to turn off categories of elements (objects, meshes,roofs, etc.) instead of by layers. The really interesting thingthat you can do here (that is impossible with the layers),is to turn off windows and/or doors – the 3D view willshow the openings in the walls, but leave out the actualframed windows or doors. Great for looking at the over-all massing and structural relationships quickly. You won'tbelieve how much faster the 3d views are generated.The layer combinations are a great thing to use as well,to turn off anything that’s not required – create a layercombo for exterior views without landscape, one withlandscape, one for interiors that leaves off exterior fa-cade details and landscape, etc. You can even switch layercombos or layer visibility while in 3d window, that wasadded in version 6.5. Another shortcut to hiding a groupof elements (like trim) is to right-click (control-click in Mac)an element of that type: in the context menu that popsup, you can see a Layers item, and a subitem can be cho-sen to Hide Layer of the selected element – hiding allelements on that layer.The marquee tool is a GREAT aid. Not everyone knowsthis most basic tool can cut a limited view of your projectwhen you go to 3D. So when you need to work on thefront entry, draw a marquee around the area, then go to3D. You can switch back and forth between thin-lined andheavy-lined marquee to choose either a single story ormultiple story excerpts. This greatly speeds up detailedwork on smaller areas of your project.Also, consider using hidden-line instead of shaded views,at least some of the time. It comes up quicker. And finally,in the 3D Window Settings under the Image menu, try outRaster instead of Analytic for either hidden-line or shadedviews. This breaks up the processing into strips, giving asomewhat cruder visualization but for large projects a sig-nificantly, sometimes dramatically, faster view. You canedit the model in this view just fine, the line work andshading just get a little pixelated.Eric Bobrow is a leading ArchiCAD dealer in Los AngelesWest.

Top Maths Trivia – Find the CircleCentre

I have always wanted to know how to find thecentre of a circle which runs through the node points

of an irregular triangle (right angled triangles are no prob-lem, the mid point of the hypoteneuse is the centre.) NowI know. It’s difficult. The proof is in the Cookbook CD.Here is the answer:

x1,y1

x2,y2

The Centre

x3,y3

X-axis

Y-axis

XCentre=XCentre=XCentre=XCentre=XCentre=-((y1+y2)/2+(x1-x2)/(y1-y2)*(x1+x2)/2 –((y2+y3)/2+(x2-x3)/(y2-y3)*(x2+x3)/2)) / (((x2-x1)/(y1-y2))+(x2-x3)/(y2-y3))

YCentre=YCentre=YCentre=YCentre=YCentre= Xcentre*(x2-x1)/(y1-y2) + (y1+y2)/2 +(x1-x2)/(y1-y2)*(x1+x2)/2

This is as compact as it gets without resorting to squaresand roots. Next question! A free ArchiCAD Universitysweater or similar gift plus a publication credit to the per-son who can work out the XYZ of the centre of a Spherebounded by three known XYZ coordinates!! email please!

Tips and TricksFAQs on the Internet

MANY of the problems you havewith rendering, plotting, fills,

dimensioning etc might be an-swered in a list of Frequently AskedQuestions (FAQ). Go on the Internetto www.graphisoft.com and look forthe Product Support Page. The an-swers will walk you step by step tosolving your problems.While you are there take the chanceto look at other support systemsavailable on the Web to the Archi-CAD user.

2 ArchiCADs for the price of one!

Mac users – If you only have one ArchiCAD and one dongle – read on. RAM is socheap now, you can put an extra 256megs of RAM into your machine if it has

enough slots. On your hard disk, make a duplicate of the ArchiCAD directory withjust ArchiCAD, Help and some of the Resource files. You don’t need to copy theArchiCAD Library over. Set both ArchiCAD’s memory settings to whatever you need,making sure that you are leaving at least 16megs for System.

Open your main file with one AC, and open a copy of the main file or a differentfile in the other AC. Now you can copy and paste from file to file, or set two differentflythroughs rendering overnight!! AC will give priority to the foreground task, butthe one behind will chug along in spare moments, and speed up with the fore-ground AC has finished rendering.

Windows machines manage memory differently and do not ‘lock out’ the appli-cation if it is already running. So the same one can run twice or more. This can leadto crashes and instability.

ArchiCAD-Talk on the Web!For those who do not want to receive AC-Talk as a listservice, it is available live on the web:

http://www.escribe.com/software/archicadtalkMessages are threaded, and you can view a history ofcontributor’s messages.

Page 298: Cookbook3_1

2.195

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Use Acrobat!

ACROBAT is one of the most helpful software innovationsof the decade. As a totally cross-platform format, inde-

pendent of applications, it can be used for drawings and bookswith the original quality retained, for viewing and printing.Acrobat is a PostScript display to screen & printer, somewhatlike a ‘Print Preview’.

Buy the Acrobat Authoring module to convert any file,including ArchiCAD drawings, into a readable format. Every-body buying a computer or software now has Acrobat Reader.This can do for ArchiCAD what .DWF files do for AutoCAD.Send drawings to Clients, Building Inspectors or Contractors.

With AC6.x, you can place an acrobat file into the Docu-mentation folder, for reading with the HELP menu. This couldbe a drawing reference list, the GDL Cookbook, an instruc-tion manual for special GDL objects, phone numbers of yourteam or anything else useful.

You can set flags to make Acrobat files safe against beingchanged or printed if you wish to – or add post-it notes orhot buttons to link to other documents or to the Internet.

Tips and TricksArchiCAD-Talk on the Internet

Amost excellent source of information and expertise isavailable to ArchiCAD users through the Internet.

Graphisoft US very kindly host a ‘listserver’ conference calledArchiCAD-talk. If you have email access, make a new mes-sage, address it to “[email protected]’ andmake the subject of the message ‘subscribe’. Leave themessage blank.

You will now get about 25 messages a day from usersall over the world, debating GDL, rendering, plotting, andall manner of useful things. You may be astonished at thequality of the messages. You will also be able to post ques-tions and answers on the conference.

If the quantity is so great that you are crushed by it(turn it off when you go on holiday!), then send anotherblank message using the words ‘subscribe digest’. Thisturns off the main flow of messages and sends you one bigone only, every day. Send the word ‘unsubscribe’ and youwill be able to stop both messages and digests.

Most of the Tips and Tricks in the GDL Cookbook haveevolved from ArchiCAD-Talk, and I am grateful to all thecontributors.

There is a similar conference called GDL-Talk.

MASS – terrain modelling

THE GDL MASS command which creates a terrain or membrane was a welcome addition to AC6.0, but is painful to

write from scratch. But if you use the Mesh tool in ArchiCADto create the outline, and some of the points, you can exportit as an object, open it in GDL. Or you can just drag it fromthe Project window into the 3D Script. It has now been savedas a MASS command. You can now change bottom and sideattributes, modify some of the existing points, add morepoints and change material.

Putting Roads into the Mesh toolRicardo Borges wrote:Is there a way to make cuts with 90 degrees on the mesh;and make "roads" that follow the differents heights of themesh to show on the rendering?

From: Duane Valencia [email protected], you can cut holes in your mesh and create roads of adifferent material. I use the following procedure....1. Create complete mesh2. Duplicate mesh a known distance from the original (soyou can move it back later)3. Draw your road using lines / arcs4. Add nodes at each topo intersection of the new road out-line(IMPORTANT!.. If you don't, the hole will force the toposback to the nearest node leaving a little gap in your mesh)5. Use the lines to cut the mesh, leaving only the road.6. Adjust this mesh up a short (minute) distance and give ita new material.You can also use the road geometry to CUT a hole into themesh if you want. I find this unnecessary if your road isslightly above the land mesh.

Server adviceGerald Abrams wrote:

I have three mac work stations am in the process of upgrading my equipment. I would like to know more about

the advantage, expense and special features of using a Serverfor AC. Also is there anything that I can read that can over-view servers in general.

Ralph Wessel, Walker Co-partnership ArchitectsBasically a dedicated server is much less likely to crash in ateamwork situation. It can keep the same software openand running continuously, unlike the average user who isconstantly opening and closing apps and documents.Memory allocation is more predictable and caching becomesmore effective. I don't think working on a machine that'sserving files is much fun either.

Moreover, you'll get much better performance if you run'real' file sharing software like AppleShare IP rather thanthe peer-to-peer sharing built in to the basic OS. Refer to:<http://www.apple.com/appleshareip/>

I wouldn't consider NT for serving files to Macs – forwhatever reason, it delivers data much slower to Macs thanto PC's. AppleShare IP delivers information to Mac clients atabout 3 times the rate of NT.

However, if you don't need to make a quick decision,take a look at Mac OS X Server:<http://www.apple.com/macosx/server/>

Mac OS X will provide excellent server performance, andhas some unique characteristics. If your client machines arerecent models (G3/iMac) you can boot and run them en-tirely from the server, which makes software updates andcoordination an easy task.

Page 299: Cookbook3_1

2.196

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Battered WallsFrom: Rex A. Maximilian [email protected] May 1999

ANSWERING the question: “Just curious if there is a wayto make non-vertical walls in AC 6.0. Has anyone run

into this situation?”

Here's the best work around we've come up with for mak-ing battered walls. Try this exercise, and then apply it ap-propriately for your needs. The key factor is that it remainsa wall, and accepts windows and doors! --- EXAMPLE ---1) Draw a 1'-6" thick wall at 90 degrees (up direction), with thereference line to the RIGHT. Set the height of the wall VERY high(around 20' or so.) Set the bottom of the wall to ZERO.2) Create a new layer called "Battered Wall Cutter." ...Or if youare using our Envision templates "Walls (Battered Cutter)," willwork with our system.3) Set the pitched roof settings with a ZERO thickness and set itto the layer mentioned in step #2. Make sure that the plate lineheight is set the same as the bottom of the wall (ZERO). Set yourroof pitch to your desired battered angle.4) Draw the plate line on the LEFT edge of the wall, or on theOPPOSITE side of the walls reference line and click the pitch di-rection to the right, or towards the wall. Draw the polygon shapeof the roof to match the shape of the wall.5) Select the roof and wall together and go under the EDIT menuand choose "Trim to Roof." Then choose the "Trim Top" button.6) Select the wall afterwards, and reset the height of the wall toyour desired height... Let's choose 6'-0".

If you look at the 3D view of the wall, you will see that it isbattered. Not only is it battered, but it also remains a wall.You can add windows and doors to it, stretch it, and otherwall functions. Try doing that to a roof, mesh or a GDL thatyou created for your battered wall... YOU CAN'T !!!

Other tips for battered walls:1) Group the wall and wall cutter roof together. When you do 3Dviews, simply turn off the "Walls (Battered Cutter)" layer off. Whenthey are grouped, you can be sure that if you move or deletethem, they act together.2) You can also select all the roofs, or some roofs as the case maybe, and reset their slope. Select the walls and "Undo Trim," raisetheir heights again, and recut to the adjusted slope!3) You can copy this wall to the side of your model. Then, dragcopies into place all over your project and stretch the walls tocreate all of your battered walls so you don't have to repeat thebattering steps above. Remember to copy and stretch the "cutterroof" as well incase you need to adjust the slope in the future.

Let me know if anyone encounters any problems with thismethod. It's all relatively simple!Good Luck, Rex A. Maximilian, Envision ATS, LLC Quicker Section Elevations

HERE is a great trick to open all elevations and sectionsat once:

Go to the plan view, select all section/elevation. Then withright mouse click(PC) or control mouse click, open section/elevation, then click OK to open all of the selections.

Now while it is regenerating go get a soda and comeback and there they are, ready to view.John Mulcahy Rockefeller/Hricak Architects, Venice, CA

Digital Cameras and Kodak CD...are wonderfully useful to the ArchiCAD user. Enjoyinstant results for catching textures of brickwork, shop win-dows, grass, paving etc. Instant access to Picture objectsfor people, plants and building facades. No waiting for thechemist to develop the photos and then find a scanner. Thequality is not as good as a ‘real’ camera, but for AC use thequality is adequate, and the speed is significant. Budget atleast £350. Try... Epson, Fuji, Canon, Sony, Kodak, Casio.

If you must use traditional camera film, consider askingyour developer to put it onto Kodak CD. Saves all the workof scanning and provides a permanent archive of site andtexture photos.

Using Comments

VERY few people use Project Comments, but it reallyis useful for making notes – a small text editor at your

fingertips. It is also good for leaving notes for colleagues toread if you are collaborating. Each note is automaticallydate and time recorded.

Another text editor is the Library Comment window.Use it as means of providing a small piece of Documenta-tion for your object – for example style settings for door orfurniture. You can place an Internet URL in the Commentfield. Also, under ArchiCAD 6.5 and 7.0, you are able toprovide extended information for the user in the USER IN-TERFACE.

Walls in conversion work

AC 6.x allows dotted or other linetypes for the outlineof walls, windows, doors and library parts – great for

those doing conversion work, to indicate walls to be takenout. If you don’t want the wall to show in 3D, just ‘explode’it to 2D!

Tips and TricksPicture SymbolsYou can place a digital picture in the floor plan, select, SaveSpecial as ArchiCAD object, and lo, it’s an object. It stillneeds to find the original picture in the loaded library. Theautoscripting routine uses the PICTURE2 command.

You can make your library object completely portableby copying the same photorender or digital photo and past-ing it into the 2D Symbol window. Use the FRAGMENT2command to display it. With 16 fragments at your disposal,you could have up to 16 pictures, callable from a popdownmenu. This could be a good way to store your favouritetextures or images, place one on the plan, explode and it’ssafe. Maybe it’s one for the staff in the office, as a digitalsignature for drawings.

These do not need the original images to be stored in aloaded library. It would be great if there was a way thesefragments could be called on for use in the UI, to ensurethat any tiled images for UI value lists, or Icons were neverlost.

Page 300: Cookbook3_1

2.197

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Making Patches scaleableLaurent Godel <[email protected]>To make scaleable patches, open the PatchTemplate_65.ISMlibrary part, included inside the ArchiCAD library.Create a new parameter called 'scal', real number type, de-fault value 0. The parameter definition is "Output Scale(0=current scale)"Then paste these lines at the beginning of the 2D script ofPatchTemplate:

!*Scaling routine, by Laurent GodelIF scal=0 THEN scal=A_fact=A_/scalmul2 fact,fact

Save and create a new patch. The Output Scale parameter isthere. Type in a scale different from your current drawingscale and the patch will be stretched accordingly. SorryPlotMaker...

Next all you need is a GDL dimension tool that allows youto dimension the scaled patch...I have one if you need it!

Crashes on Interface andParameter scriptsLaurent Godel <[email protected]>Just wanted to share with you a little security technique...

When scripting complex interface or/and parameter scripts,you are probably aware that AC will often crash upon sav-ing, sending all your work to the twilight zone. I alwayskeep a simple text utility opened along with ArchiCAD andbefore asking AC to save I will just copy each script andpaste it in a blank text document. It has saved me a lot oftimes. Hope it can save you!

About parameter scripts, I have found out that changesmade to this script actually activate themselves throughclicking on the parameters tab at the left of the ObjectEditor window. Only after that will they work inside theInterface script preview....

Roberto Corona adds:These crashes occur on both Mac and Win if I do a changein the UI preview window that involves the PARAMETERScommand. Sometime the file (the object) wasunrecoverable. Now I SAVE the object and test the inter-face directly from the ArchiCAD environment, instead ofthe GDL environment.

What about ArchiFORMA?People often ask, ‘Do I need GDL now that we can getArchiForma?’ I see nothing wrong in having both!ArchiForma is still not the answer for smart objects withdozens of IF statements, and highly parametric control overmaterials, nor for extended complex objects or tools withmany elements. But for shape making it is incredibly con-venient. It does not fill your library with many objects likeProfiler. It has a palette that offers you the chance to makealmost anything that is in GDL – a Revolve, a Sweep etc.These are in fact a set of super objects, governed by theArchiCAD settings for that object. As long as the AF libraryis loaded, everything will work. Objects can rotated freely.Formations can be assembled until your piece of furniture iscomplete, view in 3D then save as your final furniture ob-ject. Saving in Binary will make your object more portable,to a system which hasn’t got the ArchiForma super objectsinstalled.

Rex A. Maximilian <[email protected]> writes:ArchiFORMA is an elegant way to graphically customizehighly parametric GDL parts. It's never pretended to be any-thing other than just that. It in no way compares to FormZ,Zoom, or others. The way I see it, you can tinker manuallywith Graphisoft's primitive GDL shapes in a dialog box (orGDL Scripting), or spend $125 and have ultimatecustomization and ease of use than any other method ofgetting shapes via GDL! If you can save two billable hoursusing it instead of older, conventional methods, then it's paidfor itself!

Having used it, I feel it is an invaluable tool for higherquality modeling. I can't imagine not having it at my dis-posal. By exploding placed ArchiForma objects, tweaking theprofile or path that results, then re-executing the ArchiFormatool, you can easily remake existing ArchiForma shapes inno time... not possible with Profiler.

ArchiCAD does NOT have true primitive shapes in its pal-ette. Cigraph should be applauded for making an AWESOMEAPI for ArchiCAD...

What's even cooler, is that better things are coming downthe pipe! I think we'll see an API explosion, and I can't wait!

Putting an ArchiCAD render into aphotoPeter J Russell <[email protected]> writes:Get the render in the correct position first! This techniquewill save you HEAPS of time later as you won't have to doas much ‘fudging’ in Photoshop when you are bringing thetwo together.

1. Scan your photo at a size that will fit on your display eg.1024x7682. From your IMAGE/PHOTO RENDERING SETTINGS selectyour scanned picture as the background with the imagesize as 1024x768.3. From your IMAGE/3D WINDOW SETTINGS select the back-ground to ‘As in PhotoRendering’. The next time you openthe 3D window in ArchiCAD you will have your scannedpicture as a background image to your 3D model PRIOR torendering.4. Change your 3D render to ‘Wire Frame’.5. Model something simple close to your building like aneighbouring building (as a box) or road that is in the photo.6. Turn off most layers to hide most 3D except neighbour-ing building/road and some of your building.7. Open the 3D window and you will see a wireframe out-line of your model over the photo.8. Set a camera in approximately the right place, then usethe navigation tools to shift/adjust the camera settings un-til you get a tight match! Plant a new camera when you getit just right.9. Turn off the background, turn on your building andRENDER!

Page 301: Cookbook3_1

2.198

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

SOMETIMES, there are structures which so catchyour imagination that you feel compelled to try

them out with GDL. It’s a challenge. The London Eyesponsored by British Airways and designed by David

Marks and Julia Barfield is London’s most popular tour-ist attraction. This whole model took only a matter ofhours, although not in the same day. Somehow youget bogged down if you do it all in one sitting. If youdo a bit one day, and come back to it, you can crackproblems which bugged you the day before. The ba-sic routine for the wheel and lattice work took no longerthan an hour. It’s a pretty standard ‘Swing the Cat!’ rou-tine for the circular tubes, and the lattice uses the tech-niques in the ‘Winged Truss-1’ – short tubes with XYZlocations for each end. By the time it came to doingthe spoke work and cabins, I was so fascinated by theproblem that I took time out from a trip in London tovisit the wheel. As it was almost dark, I had to sketch

down all the details of the spokes and cabins – mak-ing appropriate decisions about levels of detail. The

‘Russian Doll’ effect is possible, because thewheel model is of course, totally parametric

in every conceivable way.

The Cabins are REVOLVEs, which dojust that! The wheel has an N_ frame

based animation. You can set thespeed and run a movie, and thewheel turns. The cabins turn sothat they remain upright (asthey must).

THE SYDNEY HARBOUR BRIDGE is famous as the site of the World’sbest fireworks display at the start of the Millennium (and a pretty good

one after the Olympics), but it is much more famous now that it has beenmodelled in GDL! The main arches are done as parabolic arches, as are

the road deck the handrails and traffic barriers and pedes-trian walkways. The entire bridge is parametric, so

you can see what it would look like if the en-gineers had changed the lattice spacing.The heights and widths of all the archesand the sections of tubing can be altered.The points along the arch are stored in anarray and the lattice sections are all tubesas in the ‘Winged Truss-1’. As square sec-tions, each tube is rotated 45˚ to makethem align correctly. Another array ofpoints is calculated for the hanging cables.As you change the camber of the bridgedeck, the cables are all recalculated, andthe numbers are all stored in the array.

In reality, the end of the main arches flat-ten out slightly before meeting the stonetowers – another challenge to meet withGDL some day!

This is another case of ‘Do some workon it until your brain hurts, then comeback another day to do the next bit!’Both models on this page by DavidNicholson-Cole

How do they do that?

Page 302: Cookbook3_1

2.199

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

How do they do that?THE deployable scissor form

space frame was devised byEmilio Pinero, an Italian architect/engineer who died in the nineteensixties. His work lives on, chieflythrough the work of ChuckHoberman and a number of re-search institutes around the world.Search on the Internet for‘deployable structures’ and you willbe amazed at how much there is.

The idea is that an entire spaceframe roof big enough to cover arailway station could be loosely as-sembled in a factory, folded up,taken to site on a low loader. Oncethere, it can be raised and stretched,and all the bolts tightened up. Thestudents in the Institute of Architec-ture (University of Nottingham)worked on this principle extendingit to include sliding cladding pan-els that close down and form a wa-tertight roof just as the roof arrivesat its perfect profile.

Railway Station for East Midlands Airport:– Stuart Winter, Stuart Buckenham, Andy Hitchcock,David Nicholson-Cole anno 2000

Incredible precision is required in setting the lengths of tubing – this de-fines the final curvature and extendability and the moment when the clad-ding panels slide into place and snap shut. This is an example of what canonly be done on a computer, not a drawing board. The GDL model en-tirely simulates the opening out and cladding, in an animation.

The first solution was done using TUBE (asin the Winged Truss–1) but once the geom-etry was established, it had to move ontoproducing members with conical ends, boltsand washers.

The whole frame can be ro-tated to any angle, so rational2D scripting was impossible.The use of PROJECT2 wassimilarly impossible. If you just

touched or tried to stretchthe frame you had towait minutes (evenwith the lowestpractical polygoncount). The 2D wasdone by writing it allin the 3D script us-

ing the techniquethat is also in the

W i n g e dTruss-1.

This section hereis not enough tocover the wholestation, it’s afraction of theentire roof!

Page 303: Cookbook3_1

2.200

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Laurent is the‘gdlguru’

THE beautiful and mysteriousgroup of Bamboo plants is

by Laurent Godel, who right-fully earns his name as ‘gdl-guru’with this glorious display.

This was done byA Man

THE Japanese Umbrellawas made by Alfred

Man. He lives in Nottingham,England, and was applyingfor a top job in Pasadena,California. Distance beingwhat it is, he could not be in-terviewed in the normal way.So the company asked him todo a test piece in GDL andhe did this in David NC’sstudy in just a few hours andsent it by email. Of course it’sparametric in every conceiv-able respect, and animatesbeautifully.

Page 304: Cookbook3_1

2.201

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Lost your Toolbar? – revisited

MAC users may envy the PC users who have the use of aToolbar. In an earlier message in AC-Talk, it seemed that

GS are unlikely to provide the Mac interface with one. Per-sonally, I am happy with menus and fast key presses.

Daniel Vareika of Montevideo, Uruguay, has created thisvisual floating toolbar for ArchiCAD using Quickkeys. It’s onthe CD with the GDL Cookbook 3. If you have Quickkeys youcan use it, in fact you can download a 30 day demo ofQuickkeys from the Internet to check it out and if you likeDaniel’s QK module, you might buy QK.

If you make more icons, you can extend this palette orbuild further palettes.

How do they do that?

Procedural Art forms with GDL

JAMES Willmott <[email protected]> from the GoldCoast of Australia has been using GDL to create pro-

cedural art forms for three or four years now, it stemsfrom a fascination for fractal imagery. He wrote a GDLMandlebrot explorer for one of his first projects andwas hooked.

“Sometimes we just like to create things and sit therespinning them around and marvelling. I do them as anentertainment, and as an expressive outlet, computerimages aren't as messy as paints. :)”

This is what he calls the Cracked Crystal. It is a threedimensional noise generator, the amplitude of the noisefunction is used to rotate and colour the smaller blocks.

Oleg for King!

OK, these curtains are magic! In fact Oleg Shmidt<[email protected]> from Russia is not

a designer, he is a programmer in GDL, API and C++.Unlike most of our architect and designer readers, hedoes not have to spend years dabbling in GDL to be-come half capable. He dives straight in with a dazzlinglevel of skill. David NC and Sanjay Patel arranged forOleg to have the API development kit and withinweeks, without going on any courses, he had pro-duced some compellingly useful looking Add-ons.

Expect more work of brilliance in the years to come.

Page 305: Cookbook3_1

2.202

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

APINOW that ArchiCAD 6.x has settled into use, and

Arrays, File I/O and the User Interface in GDL aremore commonly used, GDL has developed into some-thing smarter and more powerful. The addition of theUser Interface capability in the GDL of ArchiCAD 6.5brings GDL a happy step closer to API. The UI allowsGDL programmers to build user friendly dialog boxeswith editing fields and images, thus leaping far beyondthe confines of the normal parameter settings box. Themind boggles at the thought of the high quality of ob-jects that will be made in the next few years with anew generation of GDL users. The rest of the CAD in-dustry need be envious that only ArchiCAD gives itsusers the ability to create parametric smart objects.

The new age of Add-onsThe rival product AutoCAD has a huge sub-industry ofadd-ons which do heating engineering, lighting, solarheating, chemical engineering, structural calculations,membranes. Because GDL didn’t support arrays, theGDL developer couldn’t begin to do most of thesethings. Unless you had the resources of Abvent or otherdevelopers associated with Graphisoft, normal userswere deprived of the tools for small scale development– which could have turned into major products if theyshowed promise.

An exciting development offered by ArchiCAD 6.xis API, an ‘application programming interface’ that goeswell beyond GDL. API allows developers to buildhigher level Add-ons to ArchiCAD; these can be addedto the main menus, the tools palette or the menubar ofArchiCAD.

GDL is limited in that it only exists in the form oflibrary objects. GDL objects can read information aboutthe environment through Global Variables and canchange themselves, but they cannot change the modelas a whole.

Add-ons are more powerful because they can existin the whole environment of ArchiCAD – they can in-teract with live elements of the main project like walls,slabs and fills. The Add-ons are analogous to the plugins you can get for Netscape, Photoshop, Quark andPagemaker, appearing in the menus or tool palettes,and radically extending the usefulness of the parentapplication.

Add-ons can either perform a function – like checkduplicates, or extending the Multiply command. Theycan build things, in which they become, in effect, GDLgenerators – the product of their work is a chunk ofGDL – like Roofmaker and profiler. In fact they canbuild ArchiCAD elements too – Architerra creates agenuine mesh element that can be tweaked and modi-fied in ArchiCAD, not a GDL mesh object as you getfrom Archisite.

Add-ons produced by Graphisoft and partners in-clude such things as a timber roof wizard, drainageand tubing wizard, extrusion & lathing wizard (Profiler).

Add-On typesADD-ONS are small pieces of software that add func

tionality to ArchiCAD. By developing an add-on, youhave the possibility to extend the following menus andpopups of ArchiCAD:

1.1 General APIImport/Export filters that allow you to open and saveArchiCAD data in different foreign file formats. InstalledAdd-Ons may appear in the Open, Merge, Open LibraryPart and Save as dialog boxes, which are invoked from theFile menu.

Tools-type Add-Ons add editing possibilities. Their com-mands appear at the bottom of the Tools menu of Archi-CAD. They are allowed to perform any legal operation onthe ArchiCAD database like creating, deleting and modify-ing either elements, attributes, or library parts.

Listing-type Add-Ons add listing possibilities. Their com-mands appear at the bottom of the Calculate menu of Ar-chiCAD. They are allowed to process the ArchiCAD data-base and create listings which fit to any special needs. Thesekinds of Add-Ons also can assign custom properties to eachelement type through the listing page of the tool settingsdialogs.

1.2 Rendering APIRendering type Add-Ons add new rendering engines to Ar-chiCAD. They appear in the Rendering Settings dialog box,like the Z-Buffer Rendering Engine.

1.3 GDL APIYou can also extend the file I/O operations via GDL scripts.By developing a GDL add-on you can write GDL scriptswhich are able to connect to, read from, and write to ex-ternal databases.

1.4 Custom Object APICustom object editors, like StairMaker or ArchiSite, can ex-tend the standard toolbar of ArchiCAD. They are able tomount a new icon into the toolbar, and build custom li-brary parts.

All developer kits assume that you are a programmer whois familiar with the C language. With the exception of theRendering API they also require considerable knowledgeof GDL programming.

Several of these have already appeared on theGraphisoft website. One very useful add-on is the onethat checks for duplicates – objects that are the sameand that exist in precisely the same 3D or 2D space. Ihave had students who repeatedly pasted into a plan,unaware that they had already pasted. The record isover 20 duplicates of an entire apartment floor.

CiGraph of Italy are producing a range of ‘Archi-’products; the most interesting of these for a GDL junkyis ArchiForma. ArchiForma allows just about every 3Dcommand in GDL to be generated within the Archi-CAD environment just be clicking polygons. the ob-ject created can be rotated in the plan around the X-axis. It is not a replacement for native GDL because

Page 306: Cookbook3_1

2.203

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

you still need the smart parametric featuresof GDL to produce more powerful objects.ArchiForma is more like an extension ofthe Toolbox, in you can go beyond wall,slab and roof – you can have extrude, latheand sweep and many more, all easilyclickable.

Developing withAPITo develop API Add-ons, thereare two routes:If you are a programmerYou have to be experienced at C++ andyou need to buy the API kit fromGraphisoft, and go on courses to learn theinteraction between the two. You need tobe very expert at GDL and ar ArchiCAD,or prepared to learn both to a high stand-

ard. If you are a programmer, go for it!! If you are anArchitect or Designer, it is unlikely you will want to gofurther than being competent at GDL.

There won’t be a Cookbook on API, not from thisauthor, anyway! (who is an architect/teacher).

Getting API is more like a marriage than a transac-tion – you do not simply write out a cheque for $1500and expect the API toolkit to arrive in the post. Youform a relationship with Graphisoft first. The mainwebsite www.graphisoft.com has a series of pages in-viting people to sign up as developers. There is an in-ternal (password protected) website for API develop-ers, for Q&A and for technical support.

You are or you are not a programmer buthave a good idea:Graphisoft write:

“If you have an idea for a tool that would enhancedesign work in ArchiCAD, accommodate local build-

ing industry requirements, or address user-specificneeds, Graphisoft can help you turn that idea into aproduct.

The idea is simple: Graphisoft develops the core pro-gram and you add your custom functionality to it. Yoursolution could even become part of the standard Ar-chiCAD package!

Since it was launched in 1998, numerous solutionshave been developed using the ArchiCAD API Devel-opment Kit. Version 2.1 allows greater functional andinterface flexibility, increased reliability and a moretransparent development environment. And,Graphisoft is committed to upgrading the DevelopmentKit with each subsequent release of ArchiCAD.

Though ArchiCAD is a comprehensive solution, it isnot possible to address every user need in one prod-uct. This is where the API comes in. It allows Graphisoftand its Developer Partners to tailor ArchiCAD to meetthe specialized demands within the building industry.

There are three main areas where specializedfunctionality is needed.

Localized Functionality: In addition to the universal"rules" for design and documentation set by the build-ing industry, every country or region has special de-sign and structural standards, local regulations, etc.These local requirements should be satisfied, but with-out burdening the users to whom they do not apply.Graphisoft wants to work with local partners to createthis "local" functionality, and – if certain conditions aremet – localized versions of the software will includethe application.

Vertical Solutions: There is an increasing need forArchiCAD-based solutions for specialized markets,such as log house design, 2X4 housing, etc. When de-veloped, these can even be turned into "special solu-tion" packages (for example, the Graphisoft Log HomeSolution). Graphisoft welcomes the development ofsuch ArchiCAD-based solutions, independently or incooperation with our R&D team.

Customization: As a growing number of large com-panies choose to make ArchiCAD their standard CADsoftware, the need for customization is increasing. Uti-lizing Graphisoft's API technology, companies can cre-ate an ArchiCAD that satisfies all of their in-house stand-ards. These requests can be satisfied quickly and on alocal level by our developer partners. This also repre-sents an additional, potentially lucrative revenue sourcefor local distributors and resellers.

”Graphisoft run regular training courses in Budapest forwould be API developers. Further details are on thegraphisoft.com website.

Developing with GDL

There is no formal program for GDL developing.Because GDL has been around for 18 years, there

are many GDL developers who have long had friendlyworking relationships with GS and who have contrib-uted many of the objects in the libraries. Many GDLdevelopers offer their objects on the Internet in on-line object shopping malls.

If you wish to be more businesslike aboutGDL:• Develop a good level of expertise along the lines ofthe GDL Cookbook and the Technical Standards docu-ment.

• Join the GDL Alliance which is a professional asso-ciation of GDL developers.

• Form a good relationship with the Graphisoft in yourcountry region.

• Become active on the internet conferences such asGDL-Talk and ArchiCAD-Talk.

• Get on the database. Sanjay Patel of Graphisoft UKis building an international database of known devel-opers, and can be contacted at [email protected].

Page 307: Cookbook3_1

2.204

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

Master Script

3D Script

2D Script

! Created by Profiler APIIF dir THEN dir=-1 ELSE dir=1

MUL a/5.496027, b/5.576086, zzyzx/0.257124RESOL 36MATERIAL matmask=16begx=1.587353begy=0.000000endx=-0.001344endy=3.174706TUBE 9, 9, mask, 0.000000*dir, 0.251494, 2, 0.000000*dir, 0.000000, 2, -0.041290*dir, 0.000000, 2, -0.041290*dir, 0.163283, 2, -0.033783*dir, 0.170791, 2, -0.033783*dir, 0.225218, 2, -0.041290*dir, 0.230849, 2, -0.016891*dir, 0.257124, 2, 0.000000*dir, 0.251494, -1, begx, begy, 0, 0, 0.000000, 0.000000, 0, 0, -0.001344, 3.174706, 0, 0, 5.494683, 3.174706, 0, 0, 5.494683, -2.401380, 0, 0, 1.587353, -2.401380, 0, 0, 1.587353, 0.000000, 0, 0, 0.000000, 0.000000, 0, 0, endx, endy, 0, 0

This controls the user’schoice to ‘mirror’ the

profile – used by both2D and 3D scripts.

The usual MUL commands allow thetotal object to be stretchy; but stretching

using MUL will distort the profile.

The begx and begy and endx and endy arethe location of Phantom points. The Profilerusually takes the second and the penultimate

points as the phantom points.Status codes arenot documented

for TUBE, but avalue of 2 tells

thephotorenderers toput a clear break

at the joints.

There is no twist,and no ‘Z’ value

in the profiler. Butyou can use

profiler to generatea first script which

you can thenchange to suit yourneeds. Add a twist!

The plan view of theskirting is shown. the

Profiler then describes allthe hotspots that follow the

skirting, and provides aPOLY2 which can provide a

fill pattern that covered theskirting if the detail is to be

omitted.

The ‘dir’ value is used to mirror the section, if required. Ifyou were to change the 3D script significantly, you wouldhave to reduce the 2D Script to an essential minimum –removing the POLY2.

These are theparameterscreated byProfiler. ‘closed’is used by therevolutionsurface routine,and for theends of thetubular object.

The tubular object profiler always seems to close upthe pathway, but if you can get into the 3D script, youcan forcibly shorten it to allow doorways.

The tubular object part of Profiler is a good way toprototype shapes: with some intelligent tweaking by aGDL savvy user, the results can be far more 3-dimen-sional.

The Revolution Surface function of Profiler workswith REVOLVE, and can equally well be tweaked bycrafty GDL-smiths.

GRAPHISOFT have now released several APIcreated Add-Ons, some of which are avail-

able on the Web for free download.

An interesting one from the 3D point of view is theProfiler, in which you click-draw an outline. Whenyou double click or close the profile, the next clicksyou do will describe a pathway. An example of theuse is for skirtings and covings around rooms, for ar-chitraves and trims. This example using the Tubularobject profiler is to show you how it is done; Cook-book readers may be keen to analyse the script pro-duced as a result.

Look atthe APIs

PROJECT2 3, 270, 2FILL fllMUL2 a/5.496027, b/5.576086HOTSPOT2 5.494683, 3.174706HOTSPOT2 5.494683, -2.401380HOTSPOT2 -0.001344, 3.174706HOTSPOT2 -0.001344, -2.401380HOTSPOT2 2.746669, 0.386663HOTSPOT2 0.000000+dir*(0.041273), 0.000000+dir*(0.041290)HOTSPOT2 0.000000+dir*(0.000000), 0.000000+dir*(0.000000)HOTSPOT2 -0.001344+dir*(0.041308), 3.174706+dir*(-0.041290)HOTSPOT2 -0.001344+dir*(0.000000), 3.174706+dir*(0.000000)HOTSPOT2 5.494683+dir*(-0.041290), 3.174706+dir*(-0.041290)HOTSPOT2 5.494683+dir*(0.000000), 3.174706+dir*(0.000000)HOTSPOT2 5.494683+dir*(-0.041290), -2.401380+dir*(0.041290)HOTSPOT2 5.494683+dir*(0.000000), -2.401380+dir*(0.000000)HOTSPOT2 1.587353+dir*(0.041290), -2.401380+dir*(0.041290)HOTSPOT2 1.587353+dir*(0.000000), -2.401380+dir*(0.000000)HOTSPOT2 1.587353+dir*(0.041290), 0.000000+dir*(0.041290)HOTSPOT2 1.587353+dir*(0.000000), 0.000000+dir*(0.000000)HOTSPOT2 0.000000+dir*(0.041273), 0.000000+dir*(0.041290)HOTSPOT2 0.000000+dir*(0.000000), 0.000000+dir*(0.000000)POLY2 14, 6, 0.000000+dir*(0.041273), 0.000000+dir*(0.041290), -0.001344+dir*(0.041308), 3.174706+dir*(-0.041290), 5.494683+dir*(-0.041290), 3.174706+dir*(-0.041290), 5.494683+dir*(-0.041290), -2.401380+dir*(0.041290), 1.587353+dir*(0.041290), -2.401380+dir*(0.041290), 1.587353+dir*(0.041290), 0.000000+dir*(0.041290), 0.000000+dir*(0.041273), 0.000000+dir*(0.041290), 0.000000+dir*(0.000000), 0.000000+dir*(0.000000), 1.587353+dir*(0.000000), 0.000000+dir*(0.000000), 1.587353+dir*(0.000000), -2.401380+dir*(0.000000), 5.494683+dir*(0.000000), -2.401380+dir*(0.000000), 5.494683+dir*(0.000000), 3.174706+dir*(0.000000), -0.001344+dir*(0.000000), 3.174706+dir*(0.000000), 0.000000+dir*(0.000000), 0.000000+dir*(0.000000)

Page 308: Cookbook3_1

2.205

The GDL Cookbook 3 – Voyager

©Copyright Marmalade 1998, 1999, 2000, 2001

AppendixThings that didn’t quite make it into the main Cookbook

Page turning in the User InterfaceTHIS is a most interesting possibility for evolving theUser Interface. It is most anoying that the UI ‘page turn-ing’ with the UI_BUTTON is sequential, making youplough through pages you don’t want to get to the rightone. This routine uses the new Global Variable calledGLOB_MODPAR_NAME, the ‘most recently used pa-rameter’. It is especially useful when you want to setone or two parameters and have the others determinethemselves.

Another example of the use of GLOB_MODPAR_NAME could be Window sill height, actual height andhead height. If you set 2 parameters, the other is logi-cally calculated. So GDL remembers the first two youupdated and correctly calculates the third.

Robert Corona <[email protected]> writes:

When the pages are more than two, I don't like havingto pass through pages I don't need to arrive to the oneI want. So I'd like to share with other users a simpletrick I've made, programming a series of check-boxes(boolean parameters) to act like the Radio-buttons (notprovided by GDL), and using them to choose the ‘page’to edit.

!******* USER INTERFACE *******I_dialog "" , 310 , 266

UI_outFIELD "1. Settings for 2D", 25,12,120,14UI_outFIELD "2. Settings for 3D", 25,27,120,14UI_outFIELD "3. Colors+materials",25,42,120,14UI_outFIELD "4. Infos" , 25,57,120,14

UI_inFIELD "page1" , 5, 10, 15, 14 UI_inFIELD "page2" , 5, 25, 15, 14 UI_inFIELD "page3" , 5, 40, 15, 14 UI_inFIELD "page4" , 5, 55, 15, 14

Up to this point, this displays check boxes. After thispoint, the IF statements change the contents of thepage with a series of page routines: IF page1 THEN UI_outFIELD "This in the FIRST page", 15,150, 150, 20 !follow with page routines ENDIF

IF page2 THEN UI_outFIELD "This in the SECOND page", 15,150, 150, 20 !follow with page routines ENDIF

etc. to build the wanted "pages". Note that we don'tneed to use the UI_PAGE, UI_PREV or UI_NEXT, be-cause it is all a Page 1.

Parameters: createone for each page,make them booleanand hidden

******* PARAMETERS SCRIPT ******* IF GLOB_MODPAR_NAME = "page1" THEN PARAMETERS page1=1,page2=0,page3=0,page4=0 ENDIF

IF GLOB_MODPAR_NAME = "page2" THEN PARAMETERS page1=0,page2=1,page3=0,page4=0 ENDIF

IF GLOB_MODPAR_NAME = "page3" THEN PARAMETERS page1=0,page2=0,page3=1,page4=0 ENDIF

IF GLOB_MODPAR_NAME = "page4" THEN PARAMETERS page1=0,page2=0,page3=0,page4=1 ENDIF

Whichever button youclick, the others are

cancelled immediately

A use for MASTEREND_GDL

LAURENT Godel <[email protected]>provides us with aninsight into the use of MASTEREND_GDL. It’s on the

Cookbook CD, so have a look. Geoffroy Magnan had pro-posed a universal diary system so that software could keepa record of the hours spent on projects, to make easier thejob of billing.Laurent writes: Inside ArchiCAD, it is possible to keep arecord of what you do during the day. Using simple GDLscripts that perform automatically IN THE BACKGROUND,you are now able to keep a log of what files are openedand closed, and when, and how long they are used. This is‘background’ in the sense that it does not require any li-brary parts to be placed on the project files, just aMASTER_GDL and a MASTEREND_GDL script inside theloaded libraries.

It produces a nice database bearing date, file name,useage time, dongle code (so you know who on the teamwas working on what). This last option can be switched off,for countries where spying on staff is unethical.

The database can then be processed to display activitycurves for a specific file, or project, or user.

I would like this utility to store more information like us-er's mood, or no. of times the phone rings while the file is inuse, or how good the coffee was, but there are no REQUESTcommands for this in GDL. Yet.

The file is on your Cookbook CD. Check it out.

Each page is, in effect, a Page ONE, whose contentsare governed by an IF statement.

See Robert’s website for more examples of his work:http://www.archiradar.com/

Page 309: Cookbook3_1

Index:DiscoverySymbols2D Full View 42D Script 42D Scripting 292D Symbol 43D Cursor 53D Organisation 13D Script 43D View 4

AADD 7Alpha channels 66ARC 63ARC2 40Artlantis 82Atkinson 77

BBASIC 1Binary Hack 77BLOCK 6Boolean 84BPRISM_ 80bPRISM_ 48British Standards Institute 2

CCalculate Menu 54Chair 9, 13, 21, 23, 55, 79, 88CIRCLE 63CIRCLE2 40CircleGrid 74Comment 4, 62COMPONENT 54Computer Flooring 59CONE 12COOR 76cPRISM_ 32CSLAB_ 65cursor 64Curvature 11CUTEND 69Cutend 69CUTPLANE 70, 79Cutplane 69CUTPOLY 73CUTPOLYA 73CUTSHAPE 73CYLIND 6

DDEFINE FILL 44DEFINE MATERIAL 44DEFINE STYLE 44DEL, DEL TOP, DEL NTR() 8DESCRIPTOR 54DO WHILE 27

EELBOW 12ELLIPS 6END 12Executive Script 18

FFace Camera 67Fire Extinguisher 49For.. Next Loops 31FOR... NEXT loop 26, 34FRAGMENT2 81Framefill 40

GGDL 1GDL Alliance 38Ghost Storey 30GLOB_CSTORY 42GLOB_EYEPOS 42GLOB_FRAME_NR 41GLOB_HSTORY_ELEV 41GLOB_NORTH_DIR 42GLOB_SCALE 41GLOB_SCRIPT_TYPE 42GLOB_TARGPOS 42Global Variables 42, 75GOTO 25

HHandrail 14Holes in Prism 40HOTSPOT2 10

IIF... THEN... ELSE... ENDIF 20Imperial 14

LLabels 62Lamp 65Lattice Portal 58Level of Detail 3Library object 35LIBRARY organisation 82LIGHT 65, 66LIN_ 63Line numbering 12LINE2 10Location Awareness 67, 75, 76, 88Louvre 61

MMagnan 76Marquee 82Masking Values 45Master Script 4Metric 14MODEL 38MUL 7

NNTR() 8

PParameter Script 4Parameter Table 4PEN 17People 76PICTURE 67Picture Objects 66Planar 3D Elements 63PLANE 64PLANE_ 64POLY 63POLY_ 63POLY2 40

POLY2_ 40Polylines 46, 80Preview Picture 4, 62PRINT 22PRISM 32Prism masking 45, 55PRISM_ 32PROJECT2 9, 10Properties 54Property Script 4Pythagoras 83

RRADIUS 11, 14RASTER 82RECT2 10Rendering 82REPEAT...UNTIL 27REQUEST 41RESOL 11REVOLVE 48ROT 8ROTx 73

SSave as ARCHIVE 82SHADOW 38SLAB 27, 64SLAB_ 64Special Menu 74, 75SPHERE 6Status Values 45Stretchy Objects 34, 39, 59Storey 70Structured Programming 16Subroutines 18SYMB_MAT 41SYMB_MIRRORED 42SYMB_POS 42SYMB_ROTANGLE 42SYMB_VIEW_PEN 41

TTOLER 11TUBE 81

UUser Interface 4, 71, 84

VValue Lists 43VERT 76

WWALL_THICKNESS 41WALLHOLE 73Window 50, 52

Zzzyzx 34, 46

Index: Discovery

Page 310: Cookbook3_1

Index:VoyagerSymbols3D Text 61

AAcrobat 16, 75, 195Add-on 120, 127, 202Adobe Premiere 12Alpha Channel 9, 14, 141, 153Analgo Clock 108AngleRod 45Animated Flag 156Animation 12, 156Anti-aliasing 141API 202Arch Forms 42Arches 164ArchiCAD-Talk 177, 194, 195, 203ArchiForma 197, 202ArchiTerra 87ARMC 44ARME 44Arrays 35, 36, 158, 160, 171Artlantis 172Atkinson,D 150, 153Attribute Manager 168AutoCAD 14Autosizing text 90

BBackground 152, 163Barfield,J 198BASE 56Battered Walls 196Beam 169, 171BEAM 124Bendy Bar 158BINARY 38Binary maths 43Binary analysis 183Bobrow,E 194BODY 56, 149Boolean 40Boundary Survey Tool 118Bounding Boxes 12bPRISM_ 52, 88, 114British Airways 198bWALL 56

CCalculate Menu 189CALL 38, 147Campbell,S 153Catamaran 142Chair 88Channels 120Chin,F 109, 156CiGraph 202Circles 41Circular 178Circumference 42Clock 107, 108CLOSE 120Comments 196

Compression 11CONE 95COONS 24, 113, 142, 156, 157,

160, 175, 184COOR 56, 149, 151, 155, 157Coordinate Geometry 39CorelDraw 11Corona,R 205cROOF 56Curtains 110Curved Windows 114Curvy Roof 160CUTEND 65, 124CUTPLANE 95, 117, 193CUTPOLY 58, 124CUTPOLYA 58, 169, 187CUTSHAPE 58CWALL 56CYCLORAMA 150

DDate and Time 140DEFINE LINE_TYPE 119DEFINE MATERIAL 76,

92, 148, 155, 156DEFINE TEXTURE

111, 148, 155, 156DIALOG 121, 130Digital Architect 9Digital Cameras 196Doors 77DWG 10, 11, 14, 103, 113DWG/DXF 14, 103DXF conversion 103DXF Import 3D 15

EEDGE 56Ellipse 95Elliptical and Fillet arch 42, 164EPS 10Error correction 18Error message 16Errors 147EXPLODE 35EXTRUDE 27, 168

FFile input 118File naming 125File Output 139Filestamp/clock 107Fire Extinguisher 75, 76Flythroughs 12FormZ 9Fountain 109FPRISM 56FRAGMENT2 31, 35, 91,103, 196Frey,A 175FULLPATH 121, 130Furniture Legs 187

GGaudi,A 164GDL Alliance 17GDL Manual 9GDL-Talk 195, 203GET 18, 19Glazing 62GLOB_CH_STORY_DIST 119GLOB_DRAWING_BGD_PEN 163

GLOB_FRAME_NR 156GLOB_MODPAR_NAME 205GLOB_SCALE 126GLOB_SCRIPT_TYPE 134Global Variables 35Godel,L 120, 163, 197, 200, 205Gothic Arch 42, 165Gourd 184Grant,T 108Graphisoft 13, 17, 177, 202, 203

HHaidekker 171Handrail 48, 93, 112Helix 99Hider 163Hotspots 48, 133Hyperbola 95Hyperbolic Paraboloid 175Hypoteneuse 39

IIND( ) 92Internet 16, 193

JJava 17

KKingsbury,M 193

LLabels 53Lamp 83Lattices 134Layers 168Legs 187LIGHT 57, 83Line numbers 44Linetypes 8Load Libraries 16LOD 17LOFTER 25London Eye 198

MMacro 38, 77, 147Macromedia Director 9Magnan,G 155, 205Man,A 160, 200Manufacturers 103Marks,D 198Masking Values 27, 43, 163MASS 25, 118, 162, 180, 195MASTER_GDL 193, 205MASTER_END_GDL 205Mathematics 40, 164Maximilian,R 196Memory Management 14Memory Settings 15MESH 23Metrowerks Codewarrior 17MODE 120Modify Library Object 19, 21Module 176Multilingual 167

NNijs,B 163

Index: Voyager

Page 311: Cookbook3_1

Northpoint 91Nottingham 17NSP 19

OOMWAC 77Organizing your library 38OUTPUT 140

PParabola 95Parabolic 178Parabolic Arch 42, 164, 183Paraboloid 175Parameter script 197PARAMETERS 34Pascal 17Passing parameters 138Patches 98, 197Patel,S 203PEN 43, 92PGON 56Photoshop 9, 153PI 41, 42Pictorial Value List 34, 71Picture Object 8, 16Picture Symbol 196PICTURE2 196Pinero,E 199PIPG 56Plotmaker 8POLY2_A 33POLY2_B 33, 163Polygons 75Polylines 28PowerPoint 9Preview image 9Prism 27Professional Standards 17Profiler 204Property Object 191Protecting your Scripts 13PUT 18PYRAMID 26Pythagoras 39, 40

QQuickkeys 201

RRebuild each Frame 156Registry Editor 192Rendering 9, 11, 12, 100, 194REPEAT... UNTIL 118REQ 43, 92REQUEST

35, 92, 104, 107, 108, 124, 140RESEDIT 192RESOL 61REVOLVE 21, 83RhombiCubOctahedron 96Right Angle Triangle 39ROOM_DOORS_WID 132ROT2 113Round Arch 42RULED 26, 110

SSeating 49Section fill 49Section tool in 3D 192

Server 195Shadows 153Shmidt,O 25, 162SIN 156SIN Wave Arch 42Smoothing 100SOH CAH TOA 39Special Menu 154, 192Spiral 99SPLINE2 33SPLINE2_A 33SPLIT( ) 92, 108, 146, 158SPRISM 57Squiffle 8, 146Stair 47Staircase 52Status Values 43Steel Beam 169, 171Storey Sensitivity 119STR( ) 92Stretchiness 11Stretchy Edging Tool 117String Parsing 162String Wrapping 163Strings 92, 98STRLEN(‘hello’) 92STW(‘hello’) 92SWEEP 26, 187Swing the Cat! 42, 93, 99, 112, 164

173, 198Sydney Harbour 198Symmetry 88

TTeamwork 11, 58TEVE 56TEXT 37, 61TEXT and DATA GDL add-ons 120TEXT2 37Toolbar 30, 201Tree 85Trial and Error 1Trigonometry 136, 171TUBE 22, 45, 77, 93, 101,

134, 160, 165, 183TUBEA 23

UUI_BUTTON 69UI_DIALOG 69UI_GROUPBOX 69UI_INFIELD 70UI_OUTFIELD 70UI_PAGE 69UI_PICT 69UI_SEPARATOR 69UI_STYLE 69USE 18User Interface 17, 67, 111, 158

VValencia,D 195VALUE LIST 95Value Lists 167VALUES 167Vareika,D 201VERT 56, 149, 155Vertesi,L 189Virtual RAM 14Visual GDL 74

VR Authoring Studio 150VR Cameras 172VR Panorama 150VR Rendering 152

WWALLHOLE 58, 63, 77Web sites 147WHILE/ENDWHILE 122WIDO_ORIG_DIST 114Willmott,J 201Window 59, 63Window, Curved 65Winged Truss 134, 136, 198, 199Wrapping Textures 148www. objectsonline.com 16www.add-onstore.com 16www.cadobjects.com 16www.graphisoft.com 16www.the-object-factory.com 16

XXWALL 56

ZZone Stamp 132Zones 189zzyzx 13

Index: Voyager