Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

GDL - Acquiring element attributes in custom labels

pedrocollares
Booster

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 24 / Windows 10 64
2 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

12 REPLIES 12

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

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 24 / 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

View solution in original post

pedrocollares
Booster

That worked just fine! Thank you 🙂

Architect / BIM Manager at Ideia1 - www.ideia1.com.br
Archicad 24 / 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
Booster

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 24 / 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
Booster

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 24 / 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
AC24 USA • iMac 27" 4.0GHz Quad-core i7 | 24 gb ram • MacBook Pro 2.8GHz | 16 gb ram • OSX10.14.6

Thanks David! I did change the 2nd parameter to 3 but it didn't alter the fill.

 

pedrocollares_0-1633007384683.png

 

Still hollow.. (The label is already at the top in the view order)

 

And thanks for the tip regarding the signature, I'll adjust it soon 🙂

 

Architect / BIM Manager at Ideia1 - www.ideia1.com.br
Archicad 24 / Windows 10 64

Have you SET the fill before the POLY2 command (SET FILL ...)?

You need to tell it what fill you intend to use.

If you have set an 'Empty' fill, the background pen will need to be coloured.

If you have set a 'Solid' fill, the foreground pen will determine the colour.

If you have set a 'Hatched' fill, you will need to set both foreground and background pens to the same colour.

 

Barry.


One of the forum moderators.
Versions 6.5 to 25
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision 3510 - i7 6820HQ @ 2.70GHz, 16GB RAM, AMD FirePro W5130M, Windows 10

I was missing that! 😅

 

Now it worked! Thanks

Architect / BIM Manager at Ideia1 - www.ideia1.com.br
Archicad 24 / Windows 10 64

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!