2021-09-26 04:39 PM - last edited on 2024-09-09 11:24 AM by Doreena Deng
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 🙂
Solved! Go to Solution.
2021-09-27 02:29 AM
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;
2021-09-27 04:23 AM
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
2021-09-27 02:29 AM
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;
2021-09-27 04:16 AM - edited 2021-09-27 04:32 AM
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..
I placed my label at the point marked in red, but it flies away to the side.
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?
2021-09-27 04:23 AM
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
2021-09-27 04:34 AM
That worked just fine! Thank you 🙂
2021-09-27 04:56 AM
2021-09-27 04:01 PM
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)
To define it, I attempted to mimic another parameter I saw:
But I can't use it at the Master Script, it gives me errors at this location:
Anything I'm missing? Thanks in advance!
2021-09-27 11:59 PM
couple of small mistakes.
basically you are attempting to do is use an "integer" type parameter which applies a "text" dropdown menu.
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.
2021-09-30 03:51 AM - edited 2021-09-30 12:37 PM
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:
When I switch to the POLY2_B, it glitches, even if I follow the instructions in the reference guide, inputting the correct parameters.
Any directions on how to turn those POLY2 into filled polygons (with white background, which could be pen number 19)?
Thanks!
2021-09-30 02:43 PM
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