05. Basic 2D elements

Example files for this lesson can be downloaded here.

An architectural plan is the 2D projection or symbolic representation of building structures, doors, windows, objects, annotation elements. It is still one of the most important, and a very informative part of building design.
GDL objects are usually a very prominent part of a building documentation, just think about doors and windows. The representation of them has to meet certain standards (the representation standards of nations can be very different), and they have to be easy to handle from a user’s point of view as well (redraw speed, editing options, highlighting, etc.).

At GRAPHISOFT we have some additional recommendations regarding the 2D symbol of an object:

  • always use a fill in the symbol, even if it’s transparent. Highlighting the object will be a lot more easier.
  • The overall dimensions of the objects should match the “A” and “B” parameters (those are available on the infobox as well)
  • Use the object group’s specific parameters provided by the chosen subtype. Listing options, creating and using macros will be a lot more organized this way.

GDL’s 2D commands usually have a “2” after their name (to distinguish them from 3D versions).
Use the Master script and the 2D script to create a symbol for your object.

Planar transformations

All transformation types are available in 2D:

add2 xOffset, yOffset
rot2 alpha
mul2 xProportion, yProportion

The transformation affects all elements placed after it in the script, until deleted (del).
Related topics: GDL Manual – Chapter 3. Coordinate Transformations or this tutorial’s Coordinates and transformations chapter.

Attributes for 2D elements

There are some very simple commands to set the attributes of the 2D elements used in the script – see the Directives section of the GDL Manual. When an attribute command is placed in the code, all simple subsequent elements will be displayed with the set attributes, unless the element declares its own (complex commands may include attribute definition parameters as well). If the script has no attribute definitions, general attributes will take action.

Pen

Every 2D shape with lines following this command will be displayed with the pen of matching index according to template.

pen indexPen

The “indexPen” parameter is an integer. You can assign a pen type parameter from the object’s own parameters as well. This case, use the name of the pen type parameter instead of an index (without quotes).

Line type

Every 2D shape with lines following this command will be displayed with the line type of matching index according to template.

line_type indexLineType

The “indexLineType” parameter is an integer, or the name of the line type in quotes. You can assign a line type parameter from the object’s own parameters as well. This case, use the name of the line type parameter instead of an index (without quotes).

Fill type

Every 2D shape with fill definitions following this command will be displayed with the fill type of matching index according to template.

fill indexFill

The “indexFill” parameter is an integer, or the name of the fill type in quotes. You can assign a fill type parameter from the object’s own parameters as well. This case, use the name of the fill type parameter instead of an index (without quotes).

2D primitives

See the Drawing Elements section of the GDL Manual

Straight line

A line between 2 points, defined by the x, y coordinates of its starting and endpoints:

line2 xStartPoint, yStartPoint, xEndPoint, yEndPoint

Empty rectangle

It is defined by 2 points as well. The two points are on the diagonal of the rectangle, the sides are parallel to current X and Y axes (local coordinates).
No fill included in the command.

rect2 xStartDiagonalPoint, yStartDiagonalPoint, xEndDiagonalPoint, yEndDiagonalPoint

Empty circle

A simple circle defined by the coordinates of the centerpoint and the radius. No fill included in the command.

circle2 xCenterPoint, yCenterPoint, radius

Arc

Piece of circle defined by its centerpoint coordinates, radius, and the starting and end angles.

arc2 xCenterPoint, yCenterPoint, radius, angleStart, angleEnd

General polygon

This function is a bit more complex than the previous ones: not only the geometric outline is declared, but the edge visibility, and some attributes of the polygon itself can be customized using the various command forms available (differing only in parameter levels).
GDL’s polygon is not a mathematical function: some included edges can be arched, and the polygon can contain holes as well.
For starters, let’s check out this parameter level (edges can be omitted, fill pen colors are parametric):

poly2_b numControlPoints, frame_fill,
        fill_pen, fill_background_pen,
        x1, y1, s1,
        ...
        xn, yn, sn
  • numControlPoints: the number of the defined points must be set here. A defined point is not necessarily the starting or endpoint of an edge, but it can be a centerpoint defined for an arched part of the contour line as well. Sometimes there is an extra point defined to close the polygon.
  • frame_fill: the value of this parameter controls the following: show/hide contour line, show/hide fill, close the polygon automatically. All these options have an assigned bit value in decimal system, so the final parameter consists of: 1 (2^0 bit for contour) + 2 (2^1 bit for fill) + 4 (2^2 bit for closed polygon). If any of these are set to zero, the function is turned off.
  • fill_pen: index of attribute for the fill’s foreground pen. The fill type is previously set with the fill command.
  • fill_background_pen: index of attribute for the fill’s background pen. The fill type is previously set with the fill command.
  • x1 (xn), y1 (yn): coordinates of control points.
  • s1 (sn): status bit of corresponding control points.

The trio of xn, yn, sn usually defines a node of the polygon. If the edge is a straight line, x and y are the coordinates of the endpoint of the edge, while s only controls the visibility of the edge (1-visible, 0-omitted).
When the edge is a segment, sn is not just a simple visibility bit, but it defines the function of the xn, yn corresponding control point coordinates as well: they can be the centerpoint of an arch (s = 900), a tangent of an arch (s = 800), etc.
To see the whole collection of extra status point options, see the Status Codes section (Chapter 7.), or check out this tutorial’s section about Additional status codes.

There is an extra status code available: -1. This indicates the endpoint of an outer contour, or an inner hole definition.

Simple text

The easiest way to display simple texts on the floorplan is the text2 command of GDL. You can either use it to show something as part of the 2D symbol of the object, or just to check the value of a parameter or a variable when the 2D script is running (very helpful when debugging).

text2 xStartPosition, yStartPosition, expression

The content ofexpression can be:

  • a simple string between quotes (“Example text”)
  • a variable’s name (without quotes)
  • a parameter’s name (without quotes)

More information can be found in the GDL manual – Text Elements section.,
or the Text handling lesson of this tutorial.

Hotspots, hotlines, hotarcs

To give your object a “handle” for moving, or an outline for easier highlighting or snapping, use the hot-commands for status:

hotspot2 xPosition, yPosition, unID
hotline2 xStartPosition, yStartPosition, x2EndPosition, yEndPosition, unID
hotarc2 xCenterPoint, yCenterPoint, radius, angleStart, angleEnd, unID

These are usually defined next to their “regular” counterparts, and invisible, until the mouse moves over them, or the object gets highlighted.
Dimensioning works associatively, if you give your hots a unique ID every time (unID).

To get the full palette of 2D related GDL commands, please, read on: GDL Manual – 2D Shapes chapter.