Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

GDL - Acquiring element attributes in custom labels

pedrocollares
Enthusiast

Hi all!

 

I'm new to GDL and I'm attempting to do a custom label that is able to identify which type of element is being labeled and then is able to put out its surface information, according to the type identified.

 

For example: if the labeled element is a floor, it puts out the "Top surface" of the element (Following eventual surface overrides). If it is a ceiling, puts out the "Bottom surface". If it's a wall, it puts out the "Inside finish surface" or the "Outside".

 

------

 

My questions are the following:

 

1 - How to 'Request' those surface names of the labeled object to use in the label object.

 

2 - How to condition the surface name used according to the type of element. (I'll use the same label to label walls, slabs, beams, so on)

 

3 - How to add a parameter to the label to choose Internal/External finish (In case it is a wall, or a beam)

 

4 - Would it be possible to identify if the reference line of the wall is internal/external so I can "position" my label to the correct side of the wall? (Auto-adapt according to which side finish I chose to label)

 

---

 

I don't intend to use Archicad Properties for that, because I can't use "Hybrid" element types. It fails to return values if I use multiple element types at the same property. Also, the label symbol should have a custom shape depending on the type of element being labeled, so I'm heading to GDL to have that freedom.

 

That's it. If anyone can show me directions to solve any of those questions, I'd be very thankful 🙂

Architect / BIM Manager at IDEIA1 - www.ideia1.com.br
Archicad 26 / Windows 10 64
2 ACCEPTED SOLUTIONS

Accepted Solutions
Solution

Firstly, congratulations on delving into GDL! it is an endless source of opportunity.

 

There is a GDL parameter to determine the type of element: GLOB_ELEM_TYPE

You will find this parameter and the optional values in the GDL Reference Guide (via help menu). Typically we use it like this:

!=======================================================================================
! Elem Types
!=======================================================================================

! --- values for GLOB_ELEM_TYPE ---
ELEM_TYPE_LABEL		= 0
ELEM_TYPE_OBJECT	= 1
ELEM_TYPE_LAMP		= 2
ELEM_TYPE_WINDOW	= 3
ELEM_TYPE_DOOR		= 4
ELEM_TYPE_WALL		= 5
ELEM_TYPE_COLUMN	= 6
ELEM_TYPE_SLAB		= 7
ELEM_TYPE_ROOF		= 8
ELEM_TYPE_FILL		= 9
ELEM_TYPE_MESH		= 10
ELEM_TYPE_ZONE		= 11
ELEM_TYPE_BEAM		= 12
ELEM_TYPE_CW		= 13
ELEM_TYPE_CWFRAME	= 14
ELEM_TYPE_CWPANEL	= 15
ELEM_TYPE_CWJUNCT	= 16
ELEM_TYPE_CWACC		= 17
ELEM_TYPE_SHELL		= 18
ELEM_TYPE_SKYLIGHT	= 19
ELEM_TYPE_MORPH		= 20
ELEM_TYPE_STAIR		= 21
ELEM_TYPE_STAIRTREAD		= 22
ELEM_TYPE_STAIRRISER		= 23
ELEM_TYPE_STAIRSTRUCTURE	= 24
ELEM_TYPE_RAILING		= 25

! - Offered Tools: All except Independent Label
_isEnabledContent	= 1
bDefaultElem		= (GLOB_INTGUID = "" | GLOB_INTGUID = "{00000000-0000-0000-0000-000000000000}")
if GLOB_ELEM_TYPE = ELEM_TYPE_LABEL and not(bDefaultElem) then
	_isEnabledContent = 0
endif

!!===============================================================

 

this means you can then write your script using the local variables defined above (eg. ELEM_TYPE_WALL) instead of having to remember what the numbers refer.

eg.

if GLOB_ELEM_TYPE = ELEM_TYPE_WALL

is easier to understand than

if GLOB_ELEM_TYPE = 5

 

With the element type determined you can then apply the other GDL parameters that are available to get the information you want. These parameters are all listed in the GDL Reference Guide in the same chapter as you find the GLOB_ELEM_TYPE parameter.

 

WALL_MAT_A , WALL_MAT_B, WALL_MAT_EDGE will give you the surfaces but you may also want to use WALL_SKINS_PARAMS and WALL_SKINS_BMAT_NAMES

 

so for your questions;

  1. requests are done with the parameters listed in the GDL Reference Guide as described above
  2. GLOB_ELEM_TYPE as described above
  3. create a parameter (eg. pickSurface) set it as a string type then in the master/parameter script provide two variables (eg. values "pickSurface", "Outside", "Inside") then in you parameter that returns the response (eg iSurface (becasue the result will be the surface ID)) do (if pickSurface = "Outside" then iSurface = WALL_MAT_A)
  4. I cant actually remember the answer to this, I think you use the WALL_DIRECTION parameter. Or maybe it was one of the "request" functions
Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists

View solution in original post

Solution

Because it is a "label" so it assumes you have the "Pointer" line on.

To get the text to move to the origin when the pointer line is off you need this piece of code placed before your text2 command:

if LABEL_CUSTOM_ARROW then
	add2 	LABEL_POSITION [2][1]	+LABEL_POSITION [3][1],
		LABEL_POSITION [2][2]	+LABEL_POSITION [3][2]
endif

 

Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists

View solution in original post

14 REPLIES 14
Solution

Firstly, congratulations on delving into GDL! it is an endless source of opportunity.

 

There is a GDL parameter to determine the type of element: GLOB_ELEM_TYPE

You will find this parameter and the optional values in the GDL Reference Guide (via help menu). Typically we use it like this:

!=======================================================================================
! Elem Types
!=======================================================================================

! --- values for GLOB_ELEM_TYPE ---
ELEM_TYPE_LABEL		= 0
ELEM_TYPE_OBJECT	= 1
ELEM_TYPE_LAMP		= 2
ELEM_TYPE_WINDOW	= 3
ELEM_TYPE_DOOR		= 4
ELEM_TYPE_WALL		= 5
ELEM_TYPE_COLUMN	= 6
ELEM_TYPE_SLAB		= 7
ELEM_TYPE_ROOF		= 8
ELEM_TYPE_FILL		= 9
ELEM_TYPE_MESH		= 10
ELEM_TYPE_ZONE		= 11
ELEM_TYPE_BEAM		= 12
ELEM_TYPE_CW		= 13
ELEM_TYPE_CWFRAME	= 14
ELEM_TYPE_CWPANEL	= 15
ELEM_TYPE_CWJUNCT	= 16
ELEM_TYPE_CWACC		= 17
ELEM_TYPE_SHELL		= 18
ELEM_TYPE_SKYLIGHT	= 19
ELEM_TYPE_MORPH		= 20
ELEM_TYPE_STAIR		= 21
ELEM_TYPE_STAIRTREAD		= 22
ELEM_TYPE_STAIRRISER		= 23
ELEM_TYPE_STAIRSTRUCTURE	= 24
ELEM_TYPE_RAILING		= 25

! - Offered Tools: All except Independent Label
_isEnabledContent	= 1
bDefaultElem		= (GLOB_INTGUID = "" | GLOB_INTGUID = "{00000000-0000-0000-0000-000000000000}")
if GLOB_ELEM_TYPE = ELEM_TYPE_LABEL and not(bDefaultElem) then
	_isEnabledContent = 0
endif

!!===============================================================

 

this means you can then write your script using the local variables defined above (eg. ELEM_TYPE_WALL) instead of having to remember what the numbers refer.

eg.

if GLOB_ELEM_TYPE = ELEM_TYPE_WALL

is easier to understand than

if GLOB_ELEM_TYPE = 5

 

With the element type determined you can then apply the other GDL parameters that are available to get the information you want. These parameters are all listed in the GDL Reference Guide in the same chapter as you find the GLOB_ELEM_TYPE parameter.

 

WALL_MAT_A , WALL_MAT_B, WALL_MAT_EDGE will give you the surfaces but you may also want to use WALL_SKINS_PARAMS and WALL_SKINS_BMAT_NAMES

 

so for your questions;

  1. requests are done with the parameters listed in the GDL Reference Guide as described above
  2. GLOB_ELEM_TYPE as described above
  3. create a parameter (eg. pickSurface) set it as a string type then in the master/parameter script provide two variables (eg. values "pickSurface", "Outside", "Inside") then in you parameter that returns the response (eg iSurface (becasue the result will be the surface ID)) do (if pickSurface = "Outside" then iSurface = WALL_MAT_A)
  4. I cant actually remember the answer to this, I think you use the WALL_DIRECTION parameter. Or maybe it was one of the "request" functions
Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists

Thank you Kristian! That pretty much solves the issue with the info. My labels are getting the Surface name, and using a small substring of it, which is the ID.

 

I can't really understand though how the origin of the label works..

 

pedrocollares_0-1632709758684.png

 

I placed my label at the point marked in red, but it flies away to the side.

 

pedrocollares_1-1632709803371.png

 

This is how it is coded so far. I'd like it's "zero" to be at the zero where I clicked. Then I can move and rotate depending on the category of label that was placed. The label doesn't use a pointer, and I built it from the ground up, so it doesn't have the "anchor" parameter.

 

Is that able to fix through the code itself?

 

Architect / BIM Manager at IDEIA1 - www.ideia1.com.br
Archicad 26 / Windows 10 64
Solution

Because it is a "label" so it assumes you have the "Pointer" line on.

To get the text to move to the origin when the pointer line is off you need this piece of code placed before your text2 command:

if LABEL_CUSTOM_ARROW then
	add2 	LABEL_POSITION [2][1]	+LABEL_POSITION [3][1],
		LABEL_POSITION [2][2]	+LABEL_POSITION [3][2]
endif

 

Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists
pedrocollares
Enthusiast

That worked just fine! Thank you 🙂

Architect / BIM Manager at IDEIA1 - www.ideia1.com.br
Archicad 26 / Windows 10 64

you are welcome

Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists
pedrocollares
Enthusiast

I'm still having an issue handling an 'Option' parameter in my label object.

 

Basically, I intend to have this parameter called "par_ref" which indicates which surface of the walls should appear at the label. (Code is in portuguese so my colleagues are able to collaborate)

 

pedrocollares_0-1632750872116.png

 

To define it, I attempted to mimic another parameter I saw:

 

pedrocollares_1-1632751208931.png

 

But I can't use it at the Master Script, it gives me errors at this location:

 

pedrocollares_2-1632751258495.png

 

Anything I'm missing? Thanks in advance!

 

 

 

Architect / BIM Manager at IDEIA1 - www.ideia1.com.br
Archicad 26 / Windows 10 64

couple of small mistakes.

basically you are attempting to do is use an "integer" type parameter which applies a "text" dropdown menu.

 

paramTypes.png

 

your first mistake is you have this parameter set to a "length" type instead of an "integer" type.

 

your second mistake is you are trying to reference the "text" value applied to the "integer" value. This "text" value is purely for display; it is not the actual value of the parameter hence you cannot reference it in your last bit of code.

 

Your last bit of code should read like this: if par_ref = 1 then

or like this: if par_ref = _parRefPoint[1]

 

However, in general the way you are setting up this parameter is overly complex unless you plan on creating language variations (same object in multiple languages). The dropdown menu text references can change language but still refer to the same integer.

 

Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists
pedrocollares
Enthusiast

The label worked just fine! Still only one question. I can't make my labels have a filled background.

 

Here I'm using the POLY2 command, which is hollow:

pedrocollares_0-1632966515321.png

When I switch to the POLY2_B, it glitches, even if I follow the instructions in the reference guide, inputting the correct parameters.

 

pedrocollares_1-1632966577521.png

 

Any directions on how to turn those POLY2 into filled polygons (with white background, which could be pen number 19)?

 

Thanks!

Architect / BIM Manager at IDEIA1 - www.ideia1.com.br
Archicad 26 / Windows 10 64

pedrocollares:

 

The second parameter in the Poly2 command is "frame_fill" which has 3 options. You are using 1, which is Draw Contour. Change this to 1+2 (or 3) to add Draw Fill to the options. See the Poly2 command in the GDL Reference Guide. If you want to use the Poly2_ command, you need to add a Status Value to each node.

 

You should add a Signature to your Profile (click the Profile button near the top of this page) with your Archicad version and operating system (see mine for an example) for more accurate help in this forum.

 

David

David Maudlin / Architect
www.davidmaudlin.com
Digital Architecture
AC27 USA • iMac 27" 4.0GHz Quad-core i7 OSX11 | 24 gb ram • MacBook Pro M3 Pro | 36 gb ram OSX14