ArchiCAD's GDL Primitive Elements - The Untold Examples
Standford Bunny. from Wikimedia Commons

ArchiCAD's GDL Primitive Elements - The Untold Examples

Hello everyone. Before we get to the core of this article, I would like to point few things:

  • I′m sorry if I was late in writing this article. I had an #archicad #gdl job at hands that needed my full attention, since it had to exceed client's expectations. Long story short, and by the client's own words, it did, on all fronts.
  • #linkedinarticle settings lacks the directness and the easiness of a user interface system that are & were available in other #socialnetworks; whether it was, for writing articles, including links (to appear where you want them to appear), renumbering of lists, or retrieval of already published articles that their system quirks caused you to delete an #article by accident, or the fact that "#" symbol forces you to get out the code snippet. Which resulted that I had to rewrite the 3 parts as 1 .. This one.

  • This #article as those which presided it, are written for those who already have a basic knowledge of #graphisoft #archicad #gdl , but even if you're not one of those, feel free to contact me.
  • The #article was intended to explain #graphisoft #archicad #gdl Primitive Element functions, in a clearer, simpler and more direct way that even a novice can quickly understand it.
  • As I have repeatedly said before, and as a sane #graphisoft #archicad #gdl programmer/coder/scripter, Primitive Element functions must always be your last resort for creating #graphisoft #archicad #gdl library parts (i.e.: #BIM objects), for the following reasons:

  1. They are verbose (i.e.: they need a lot of script).
  2. If you are not careful, you can mess things quiet easily. Hence, they tend to be difficult to maintain and/or to debug.
  3. #graphisoft #archicad #gdl has more than enough modeling functions that are capable of providing more than 95%, of your 2D & 3D library parts (i.e.: #BIM objects) needs.

Basics

No alt text provided for this image
Mesh overview

Most computer 3D graphics are based on the mathematical field theory of Meshes; long story short, you use a number of Vertices (plural of vertex, which're points in 2D or 3D space - see first diagram from the left), to define Edges (second diagram from the left), that will be used to define Faces (third diagram from the left), and hence you can obtain 2D or 3D polygons, or surfaces; or even a solid body (see the 3 right diagrams). For more information please visit Polygon mesh & Wire-frame model.

No alt text provided for this image
Figure 01.01 - The poligonal surface example

From Basics to application

Part 1 - Create your first polygon

So now, you will create this single squared polygonal surface (Fig 01.01), and set its size to 1x1 m.

In layman's term, your first step is to define vertices (i.e.: a 3D point). So, we're going to use the VERT function, as defined in "GDL Reference Manual":

vert x-coordinate, y-coordinate, z-coordinate        
No alt text provided for this image
Figure 01.02 - The polygonal surface vertices, index and their 3D coordinates

Let's start by opening the 3D script window in the GDL Editor in #archicad (you can also use the "Master" script window).


So, taking into consideration the polygonal surface coordinates location (as seen in Fig 01.02), the #gdl code should look like this:


vert 0.00,? 0.00,? 0.00?? ?!1
vert 1.00,? 0.00,? 0.00?? ?!2
vert 1.00,? 0.00,? 1.00?? ?!3
vert 0.00,? 0.00,? 1.00?? ?!4        

Notice that the script includes the vertex order (a.k.a. index) number as a comment. It's utility will explained later.

No alt text provided for this image
Figure 01.03 - View of the scripted vertices from the GDL Editor 3D Window

After writing this code, go open the 3D Window from within the GDL Editor (Fig 01.03), you will see nothing.

Don't worry. You did not do anything wrong. It's just that vertices are not visible in 2D or 3D views in #graphisoft #archicad (there are other methods to achieve it).

Now it the turn to define the polygon's edges. For that, we're going to use the EDGE function, as defined in "GDL Reference Manual":


edge vertex 1, vertex 2, polygon 1, polygon 2, status code        

vertex 1, vertex 2: are the indexes order of mentioning/setting up (i.e.: index) we have previously defined (that is why you added Vert indexes as a comment, besides, it makes debugging easier).

polygon 1, polygon 2: geometrically speaking, any continuous lines have a maximum of 2 adjacent surfaces, but since in this case we're using only 1, we will set polygon 1 as 1 (and polygon 2 as 0 (non-existent))

status code: we will set it as 0 (for other conditions check #graphisoft GDL Reference Manual).

So your code should be like this:


edge 1, 2, 1, 0, 0?? ?!1        
No alt text provided for this image
Figure 01.04 - Poligonal edges's location and indexes and their relation to vertexes




Very good ... So now it time to write the other edges (as in Fig 01.04), so your code would be (see PS 1 footnote):


vert 0.00,? 0.00,? 0.00    !1
vert 1.00,? 0.00,? 0.00?? ?!2
vert 1.00,? 0.00,? 1.00?? ?!3
vert 0.00,? 0.00,? 1.00?? ?!4

edge 1, 2, 1, 0, 0?? ?!1
edge 2, 3, 1, 0, 0?? ?!2
edge 3, 4, 1, 0, 0?? ?!3
edge 1, 4, 1, 0, 0?? ?!4        

Now for this step, you will define the normal vector of the poligonal surface. For that, we're going to use the VECT function, as defined in "GDL Reference Manual":


vect X-component, Y-component, Z-Component        

Although VERT and VECT do appear very similar to one another, and their requirements are almost identical, they are quite different in nature since that ...

VERT: defines a point in 3D space

VECT: defines a vector, a direction (as in vector math you took in school).


VECT function is used to tell the different processors (the CPU and GPU) if light should reflect on a specific surface (i.e: if the surface should be visible or invisible from your view point), and how should that reflection appears on screen. For this particular example is not that important, but it's good to know.


So for your code should look like this:


vert 0.00,? 0.00,? 0.00    !1
vert 1.00,? 0.00,? 0.00?? ?!2
vert 1.00,? 0.00,? 1.00?? ?!3
vert 0.00,? 0.00,? 1.00?? ?!4

edge 1, 2, 1, 0, 0?? ?!1
edge 2, 3, 1, 0, 0?? ?!2
edge 3, 4, 1, 0, 0?? ?!3
edge 1, 4, 1, 0, 0?? ?!4

vert 0.00, -1.00, 0.00    !1        

Now it's time to define the polygon surface as specified in the "GDL Reference Manual":


pgon number of edges, vect index, status code, edge 1 .... n        

number of edges: it's the number of edges that conforms your polygonal surface, and in our case it's 4 (you can go from 3 edges to n number of edges).

vect index: it's the index number of the normal surface on the polygonal surface, and since we only have one surface, then it's a 1.

status code: we will set it as 0 (for other conditions check #graphisoft GDL Reference Manual).

edge 1 ... n: it's the indexes of all the edges that conform the poligonal surface

So your code right now should be like this


vert 0.00,? 0.00,? 0.00    !1
vert 1.00,? 0.00,? 0.00?? ?!2
vert 1.00,? 0.00,? 1.00?? ?!3
vert 0.00,? 0.00,? 1.00?? ?!4

edge 1, 2, 1, 0, 0?? ?!1
edge 2, 3, 1, 0, 0?? ?!2
edge 3, 4, 1, 0, 0?? ?!3
edge 1, 4, 1, 0, 0?? ?!4

vert 0.00, -1.00, 0.00    !1

pgon 4, 1, 0, 1, 2, 3, 4   !1        
No alt text provided for this image
Figure 01.05 - The polygonal surface have not be rendered

If you have already written down that code you will get the result that appear in figure 01.05.

So what went wrong?

PGON function needs order. For every surface you will script, it either have to go clock-wise or counter clock-wise; there is no middle grounds.

So the right thing to do now, is to start to debug (find the error and correct it) starting from the end, or in our case from the polygonal surface definition:


pgon 4, 1, 0, 1, 2, 3, 4   !1        
No alt text provided for this image
Figure 01.06 - Edges' order based on the pgon definition

As you can see from the code snippet (above and depecticed in figure 01.06), the edges definitions have gone from 1 -> 2 -> 3 -> 4, or counter clock-wise; which also means that the error lies in another place of the script.

So next logical place to revise is were edges are defined, as seen in the following snippet:


edge 1, 2, 1, 0, 0?? ?!1
edge 2, 3, 1, 0, 0?? ?!2
edge 3, 4, 1, 0, 0?? ?!3
edge 1, 4, 1, 0, 0?? ?!4        
No alt text provided for this image
Figure 01.07 - Edges' flow direction in relation to the order of the used vertices

On first sight everything appears in order, but if you took a closer to how each edge was defined in relation to the order of vertices, you would find that edge num 4 is going in the opposite direction to the rest of the edges (see figure 01.07); which also means that in order to show the polygonal surfaces correctly, you must also make sure that the edges were set in the correct order.

So you correct this issue by simple redefining edge number 4 , as shown in the following snippet:


edge 1, 2, 1, 0, 0?? ?!1
edge 2, 3, 1, 0, 0?? ?!2
edge 3, 4, 1, 0, 0?? ?!3
edge 4, 1, 1, 0, 0?? ?!4        

So the final script for this example should be like:


vert 0.00,? 0.00,? 0.00    !1
vert 1.00,? 0.00,? 0.00?? ?!2
vert 1.00,? 0.00,? 1.00?? ?!3
vert 0.00,? 0.00,? 1.00?? ?!4

edge 1, 2, 1, 0, 0?? ?!1
edge 2, 3, 1, 0, 0?? ?!2
edge 3, 4, 1, 0, 0?? ?!3
edge 4, 1, 1, 0, 0?? ?!4

vert 0.00, -1.00, 0.00    !1

pgon 4, 1, 0, 1, 2, 3, 4   !1        

No alt text provided for this image
Figure 02.01 - An element composed of teo poligonal surfaces

Part 2 - Create your a multi-poligonal shape

In this example, you will create the shape shown in Figure 02.01, which is compose by two 1x1 m squared polygonal surfaces, that share an edge.



No alt text provided for this image
Figure 02.02 - The polygonal surfaces' vertices, indexes and coordinates



So from the previous example we will copy the vertices script block and put it in a new object file "3D" Script window ... and you will modify the 2nd and 3rd Verts to adjust their coordinate to Figure 02.02, as shown below:


vert 0.00,? 0.00,? 0.00    !1
vert 1.00,?-1.00,? 0.00?? ?!2
vert 1.00,?-1.00,? 1.00?? ?!3
vert 0.00,? 0.00,? 1.00?? ?!4        

Now, you inclue vertices number 5 & 6, since we are going to reuse vertices 2 & 3 for the right poligon definition, as shown in the snippet below:


vert 0.00,? 0.00,? 0.00    !1
vert 1.00,?-1.00,? 0.00?? ?!2
vert 1.00,?-1.00,? 1.00?? ?!3
vert 0.00,? 0.00,? 1.00?? ?!4
vert 2.00,  0.00,  0.00    !5
vert 2.00,  0.00,  1.00    !6        

Now its the turn to write down the EDGEs, so just copy the the edges' definition from the previous example (since their defition and vertices relation is almost similar) to look like the following script:


vert 0.00,? 0.00,? 0.00    !1
vert 1.00,?-1.00,? 0.00?? ?!2
vert 1.00,?-1.00,? 1.00?? ?!3
vert 0.00,? 0.00,? 1.00?? ?!4
vert 2.00,  0.00,  0.00    !5
vert 2.00,  0.00,  1.00    !6

edge 1, 2, 1, 0, 0?? ?!1
edge 2, 3, 1, 0, 0?? ?!2
edge 3, 4, 1, 0, 0?? ?!3
edge 4, 1, 1, 0, 0?? ?!4        
No alt text provided for this image
Figure 02.03 - Poligonal edges's location and indeces




Now add the EDGEs of the right polygon to have the appearance of Figure 02.03, as shown in the following snippet:


vert 0.00,? 0.00,? 0.00    !1
vert 1.00,?-1.00,? 0.00?? ?!2
vert 1.00,?-1.00,? 1.00?? ?!3
vert 0.00,? 0.00,? 1.00?? ?!4
vert 2.00,  0.00,  0.00    !5
vert 2.00,  0.00,  1.00    !6

edge 1, 2, 1, 0, 0?? ?!1
edge 2, 3, 1, 0, 0?? ?!2
edge 3, 4, 1, 0, 0?? ?!3
edge 4, 1, 1, 0, 0?? ?!4

edge 2, 5, 2, 0, 0    !5
edge 5, 6, 2, 0, 0    !6
edge 6, 3, 2, 0, 0    !7
edge 3, 2, 2, 0, 0    !8        

And now, it's the turn to add the VECTs and PGONs definitions:


vert 0.00,? 0.00,? 0.00    !1
vert 1.00,?-1.00,? 0.00?? ?!2
vert 1.00,?-1.00,? 1.00?? ?!3
vert 0.00,? 0.00,? 1.00?? ?!4
vert 2.00,  0.00,  0.00    !5
vert 2.00,  0.00,  1.00    !6

edge 1, 2, 1, 0, 0?? ?!1
edge 2, 3, 1, 0, 0?? ?!2
edge 3, 4, 1, 0, 0?? ?!3
edge 4, 1, 1, 0, 0?? ?!4

edge 2, 5, 2, 0, 0    !5
edge 5, 6, 2, 0, 0    !6
edge 6, 3, 2, 0, 0    !7
edge 3, 2, 2, 0, 0    !8

vect -1.00, -1.00, 0.00    !1
vect  1.00, -1.00, 0.00    !2

pgon 4, 1, 0, 1, 2, 3, 4   !1
pgon 4, 2, 0, 5, 6, 7, 8   !2        

Very well, if you revised the previous snippet and Figure 02.03, you will observe that edges number 2 & 8 are the same, so you will proceed to eliminate edge 8 and make modification to polygon as as follows:


vert 0.00,? 0.00,? 0.00    !1
vert 1.00,?-1.00,? 0.00?? ?!2
vert 1.00,?-1.00,? 1.00?? ?!3
vert 0.00,? 0.00,? 1.00?? ?!4
vert 2.00,  0.00,  0.00    !5
vert 2.00,  0.00,  1.00    !6

edge 1, 2, 1, 0, 0?? ?!1
edge 2, 3, 1, 0, 0?? ?!2
edge 3, 4, 1, 0, 0?? ?!3
edge 4, 1, 1, 0, 0?? ?!4

edge 2, 5, 2, 0, 0    !5
edge 5, 6, 2, 0, 0    !6
edge 6, 3, 2, 0, 0    !7

vect -1.00, -1.00, 0.00    !1
vect  1.00, -1.00, 0.00    !2

pgon 4, 1, 0, 1, 2, 3, 4   !1
pgon 4, 2, 0, 5, 6, 7, 2   !2        
No alt text provided for this image
Figure 02.04 - View of the scripted vertices from the GDL Editor 3D Window


But if you have already done so, you will see nothing in the GDL Editor's 3D View, because edge number 2, although it's flowing the flow order of the left polygon, it is not doing so the same with the right polygon (see figure 02.05).

No alt text provided for this image
Figure 02.05 - Edges' flow direction in relation to the order of the used vertices


So to overcome this issue, without the need to to rewrite an additional edge, you will treat the edge as a vector, and give it an opposit direction flow to what was originally specified by setting its index with a negative value in the PGON surface definition (see pgon number 2), as shown in the following code (see PS 2 footnote):


vert 0.00,? 0.00,? 0.00    !1
vert 1.00,?-1.00,? 0.00?? ?!2
vert 1.00,?-1.00,? 1.00?? ?!3
vert 0.00,? 0.00,? 1.00?? ?!4
vert 2.00,  0.00,  0.00    !5
vert 2.00,  0.00,  1.00    !6

edge 1, 2, 1, 0, 0?? ?!1
edge 2, 3, 1, 2, 0?? ?!2    <--Don't forget to set adjacent pgon surfaces
edge 3, 4, 1, 0, 0?? ?!3
edge 4, 1, 1, 0, 0?? ?!4
edge 2, 5, 2, 0, 0    !5
edge 5, 6, 2, 0, 0    !6
edge 6, 3, 2, 0, 0    !7

vect -1.00, -1.00, 0.00    !1
vect  1.00, -1.00, 0.00    !2

pgon 4, 1, 0, 1, 2, 3,  4  !1

pgon 4, 2, 0, 5, 6, 7, -2  !2        

No alt text provided for this image
Figure 03.01 - A curved surface example

Part 3 - Create a curved shape

So now, it's time for you to make quarter skewed cone surface with a radius of 1m and the hieght of 1 m (Fig 03.01).

Your first step will be to open #archicad GDL Editor's 3D View and set its 3D Style to "White Model with Shadows" (if you don't know how to do it, please check ArchiCAD 26 Help - 3D Styles). And the reason are:

  1. Shadows do convay 3D modelling information.
  2. 3D "White Model" is a great setting to visually detect modelling errors that are usually hidden when a texture is applied to a 3D model.

Then you will read PS 3 (down below in the footnotes).

No alt text provided for this image
Figure 03.02 - The curved polygonal surface vertices, indexes and coordinates


As usual, you will start by writing down the curved surface vertices, but this time you will have to manually create the curve base edge segmentation, and to keep it simple, you will put a vertex every 30o (i.e: at 270o, 300o, 330o & 360o) with an anditional one at 315o (see figure 03.02) ... so you code snippet should be as follows:


vert 1.00,? 0.00,? 0.00?? ?!1
vert 0.87, -0.50,? 0.00?? ?!2
vert 0.71, -0.71,? 0.00?? ?!3
vert 0.50, -0.87,? 0.00?? ?!4
vert 0.00, -1.00,? 0.00?? ?!5
vert 0.00, -1.00,? 2.00?? ?!6        
No alt text provided for this image
Figure 03.03 - Poligonal edges's location and indeces





Now its the turn to write down the EDGEs, and we will start with edge number 1, 2 & 3 (see figure 03.03):


vert 1.00,? 0.00,? 0.00?? ?!1
vert 0.87, -0.50,? 0.00?? ?!2
vert 0.71, -0.71,? 0.00?? ?!3
vert 0.50, -0.87,? 0.00?? ?!4
vert 0.00, -1.00,? 0.00?? ?!5
vert 0.00, -1.00,? 2.00?? ?!6

edge 1, 2, 0, 0, 0    !1
edge 2, 3, 0, 0, 0    !2
edge 3, 1, 0, 0, 0    !3        

Since, edges 2 is common to two adjacent polygons (to be scripted), you will not repeat writing them down, so you will only write the edges of 4 and 5 as follows:


vert 1.00,? 0.00,? 0.00?? ?!1
vert 0.87, -0.50,? 0.00?? ?!2
vert 0.71, -0.71,? 0.00?? ?!3
vert 0.50, -0.87,? 0.00?? ?!4
vert 0.00, -1.00,? 0.00?? ?!5
vert 0.00, -1.00,? 2.00?? ?!6

edge 1, 2, 0, 0, 0    !1
edge 2, 3, 0, 0, 0    !2
edge 3, 1, 0, 0, 0    !3

edge 2, 3, 0, 0, 0    !4
edge 3, 6, 0, 0, 0    !5        

And you will repeat the previous step with the rest of the edges:


vert 1.00,? 0.00,? 0.00?? ?!1
vert 0.87, -0.50,? 0.00?? ?!2
vert 0.71, -0.71,? 0.00?? ?!3
vert 0.50, -0.87,? 0.00?? ?!4
vert 0.00, -1.00,? 0.00?? ?!5
vert 0.00, -1.00,? 2.00?? ?!6

edge 1, 2, 0, 0, 0    !1
edge 2, 3, 0, 0, 0    !2
edge 3, 1, 0, 0, 0    !3

edge 2, 3, 0, 0, 0    !4
edge 3, 6, 0, 0, 0    !5

edge 3, 4, 0, 0, 0    !6
edge 4, 6, 0, 0, 0    !7

edge 4, 5, 0, 0, 0    !8
edge 5, 6, 0, 0, 0    !9        

At this point I would usually say lets try to write now the normal vectors, but let's omit it this time for the sake of simplicity and let the program do it automatically.

Now its turn to script the first polygon ....


vert 1.00,? 0.00,? 0.00?? ?!1
vert 0.87, -0.50,? 0.00?? ?!2
vert 0.71, -0.71,? 0.00?? ?!3
vert 0.50, -0.87,? 0.00?? ?!4
vert 0.00, -1.00,? 0.00?? ?!5
vert 0.00, -1.00,? 2.00?? ?!6

edge 1, 2, 0, 0, 0    !1
edge 2, 3, 0, 0, 0    !2
edge 3, 1, 0, 0, 0    !3

edge 2, 3, 0, 0, 0    !4
edge 3, 6, 0, 0, 0    !5

edge 3, 4, 0, 0, 0    !6
edge 4, 6, 0, 0, 0    !7

edge 4, 5, 0, 0, 0    !8
edge 5, 6, 0, 0, 0    !9

pgon 3, 0, 0, 01, 02,  03    !1        
No alt text provided for this image
Figure 03.04 - First poligonal surface of the curved surface

If you opened #archicad GDL Editor's 3D View, it should show the model that appear in figure 03.04.

Taking into considerations that edges number 2, 5 and 7 are common edges of every 2 adjacent surfaces, and for every PGON these they have to switch their flow direction, we will use the trick of writing their indices as a negative value, like in the following script:


vert 1.00,? 0.00,? 0.00?? ?!1
vert 0.87, -0.50,? 0.00?? ?!2
vert 0.71, -0.71,? 0.00?? ?!3
vert 0.50, -0.87,? 0.00?? ?!4
vert 0.00, -1.00,? 0.00?? ?!5
vert 0.00, -1.00,? 2.00?? ?!6

edge 1, 2, 0, 0, 0    !1
edge 2, 3, 0, 0, 0    !2
edge 3, 1, 0, 0, 0    !3

edge 2, 3, 0, 0, 0    !4
edge 3, 6, 0, 0, 0    !5

edge 3, 4, 0, 0, 0    !6
edge 4, 6, 0, 0, 0    !7

edge 4, 5, 0, 0, 0    !8
edge 5, 6, 0, 0, 0    !9

pgon 3, 0, 0, 01, 02,  03    !1
pgon 3, 0, 0, 04, 05, -02    !2
pgon 3, 0, 0, 06, 07, -05    !3
pgon 3, 0, 0, 08, 09, -07    !4        
No alt text provided for this image
Figure 03.05 - The segmented view of the curve surface

Open #archicad GDL Editor's 3D View, and see if the script have generated a model similar to Figure 03.05, if not, revise your code.

Now it's time to debug the code, and the first thing we're going to do is modify PGONs to imply that the surfaces they define are curved surfaces by setting their status code with the value of 2 ...


vert 1.00,? 0.00,? 0.00?? ?!1
vert 0.87, -0.50,? 0.00?? ?!2
vert 0.71, -0.71,? 0.00?? ?!3
vert 0.50, -0.87,? 0.00?? ?!4
vert 0.00, -1.00,? 0.00?? ?!5
vert 0.00, -1.00,? 2.00?? ?!6

edge 1, 2, 0, 0, 0    !1
edge 2, 3, 0, 0, 0    !2
edge 3, 1, 0, 0, 0    !3

edge 2, 3, 0, 0, 0    !4
edge 3, 6, 0, 0, 0    !5

edge 3, 4, 0, 0, 0    !6
edge 4, 6, 0, 0, 0    !7

edge 4, 5, 0, 0, 0    !8
edge 5, 6, 0, 0, 0    !9

pgon 3, 0, 2, 01, 02,  03    !1
pgon 3, 0, 2, 04, 05, -02    !2
pgon 3, 0, 2, 06, 07, -05    !3
pgon 3, 0, 2, 08, 09, -07    !4        
No alt text provided for this image
Figure 03.06 - The 3D surface after setting their PGONs as curved surface

Now open the GDL Editor's 3D View, and set its 3D Style as Simple Shading. Your script should generate the model with the aspect that appears in Figure 03.06, but if you switched back the 3D View to White Model with Shadows, you would still see your model as in Figure 03.05. So, there are still work to do.

Now its the turn to tell #archicad GDL Editor that all our EDGEs do belong to a curved surface, by setting the their Status Code by the value of 2:


vert 1.00,? 0.00,? 0.00?? ?!1
vert 0.87, -0.50,? 0.00?? ?!2
vert 0.71, -0.71,? 0.00?? ?!3
vert 0.50, -0.87,? 0.00?? ?!4
vert 0.00, -1.00,? 0.00?? ?!5
vert 0.00, -1.00,? 2.00?? ?!6

edge 1, 2, 0, 0, 2    !1
edge 2, 3, 0, 0, 2    !2
edge 3, 1, 0, 0, 2    !3

edge 2, 3, 0, 0, 2    !4
edge 3, 6, 0, 0, 2    !5

edge 3, 4, 0, 0, 2    !6
edge 4, 6, 0, 0, 2    !7

edge 4, 5, 0, 0, 2    !8
edge 5, 6, 0, 0, 2    !9

pgon 3, 0, 2, 01, 02,  03    !1
pgon 3, 0, 2, 04, 05, -02    !2
pgon 3, 0, 2, 06, 07, -05    !3
pgon 3, 0, 2, 08, 09, -07    !4        


No alt text provided for this image
Figure 03.07 - The 3D surface after setting its EDGEs as curved parts of a curved surface

Now open the GDL Editor's 3D View, and set its 3D Style a White Model with Shadows, and you should see a model similar to Figure 03.07 (see PS 4).


Recap

So What you have learned with this article?

  1. How to use #graphisoft #archicad #gdl Primitive Elements.
  2. How to create curved surfaces (which also opens up creating/debuging more complex shapes).
  3. That, code comments are important.
  4. How to write your #gdl scripts following the "GDL Style Guide" (see GDL Reference Guide).
  5. You have to be aware of code interdependcies (return Part 2 to figure 02.04).
  6. You should always avoid using Primitive Elements functions and only use it when there is no other way around, for the reasons that I have already explained.
  7. That the "GDL Reference Manual" is a was made for referencing, not for explainations. But if you need help, feel free to send me a private message, and I will see how can I help you.

Ladies and Gents ... enjoy your coding.

PS 1

If you have written the following snippet, or if in anytime have commented the PGON definition(s), then you will not be able to see the edges in the 2D or 3D views ..


vert 0.00,? 0.00,? 0.00    !1
vert 1.00,? 0.00,? 0.00?? ?!2
vert 1.00,? 0.00,? 1.00?? ?!3
vert 0.00,? 0.00,? 1.00?? ?!4

edge 1, 2, 1, 0, 0?? ?!1
edge 2, 3, 1, 0, 0?? ?!2
edge 3, 4, 1, 0, 0?? ?!3
edge 1, 4, 1, 0, 0?? ?!4        

The reason is that the EDGE function will search for the adjacent PGON surface that you have specified by index number 1, which in this case is yet to be defined. To by pass this issue you have to set your EDGEs as independent (i.e.: 0 instead of 1):


vert 0.00,?0.00,?0.00???!1
vert 1.00,?0.00,?0.00???!2
vert 1.00,?0.00,?1.00???!3
vert 0.00,?0.00,?1.00???!4

edge 1, 2, 0, 0, 0???!1
edge 2, 3, 0, 0, 0???!2
edge 3, 4, 0, 0, 0???!3
edge 1, 4, 0, 0, 0???!4        

PS 2

Defining the adjacent polygons to the an EDGE function is always manageable, as long as the number of PGONs is small, but if you set the the indexes of the polygonal surfaces with a negative number (let's say by -1), #archicad will automatically find them for you.

Of course this method has the advantage of making the scripting task easier, but its comes with a processing cost, specially if the shape is complex or composed of a huge number of PGONs.

For more information, please return to the "GDL Reference Manual".

PS 3

No alt text provided for this image
Figure PS 03.01 - Cone shaped curved base segmentation shown in distinct colours

In the #bim programs that I have used and tested (#archicad & #revit), they show curves as a chain of straight lines segments (see figure PS 03.01).

#archicad #gdl modelling functions do handle this issue quiet nicely without the need of the programmer/scriptor direct intervention (see "3D Shapes" in the GDL Reference Manual), but for #archicad #gdl Primitive Elements functions, you have to manually define any curved line segmentation.

I know that it's a bummer for some of you, but this is the price to pay for absolute, total and granular control for modelling #libraryparts using Primitive Elements functions.

PS 4

I′m aware that Figure 03.07 have the same issue of curved edges segmentation that was explained in PS 2, but the aim of this article was to use simple example for a simple step by step tutorial that everyone can find it simple and clear to follow, even for novice in #gdl programming/scripting.

References

Nader Belal

Archicad / GDL, BIM Modeling / Certified BIM Coordinator (*headline being edited)

2 年

Lucas Becker as promised

要查看或添加评论,请登录

Nader Belal的更多文章

社区洞察

其他会员也浏览了