2024-08-07 04:26 AM - last edited on 2024-09-24 10:10 AM by Doreena Deng
I would like to edit the Surface Label 25 to show the text of a surface before a delimiter. For example:
Surface Name is TC:Timber Cladding
Label to shown only TC
This is the code I have used to get this working on a wall label i wrote a while ago:
!======split
len = STRLEN (string)
iDotPos = STRSTR (string, sep)!sep is the seperator
code = STRSUB (string, 1, iDotPos - 1)
mat = STRSUB (string, iDotPos+1, len-iDotPos)!material
if display_txt = 'code' and code<>"" then
string=code
endif
if display_txt = 'mat' then
string=mat
endif
But I cant figure out where to catch the surface name and split it in this object. I think it might be happening in the macro label_content_macro. Any wizards out there that can figure this out??? @Barry Kelly ?
Of course this would not be required if GS would give us an ID field for surfaces the same as building materials.
Operating system used: Mac Intel-based 12
2024-08-07 05:22 AM - edited 2024-08-07 05:56 AM
Yes, that is the correct place where the suface is gathered from.
from gdl
(they are just using a parameter with SURFACE_ in front of the desired gdl code in this list...
from the macro
which then gets the id of the surface
_iAvailableMaterialContent
that then convert's into a name
_nameSurface
which gets assigned to:
_sSegmentLocal
which gets assigned to
_sSegmentGlobal
which gets assigned to
sRowsOfLabel
which gets assigned to
tempsRowsOfLabel
Which gets returned from the macro using the "end returned_parameters" command...
I love the way Graphisoft make this easy to find...
P.S.
it looks like the typed prefex is in array point 1
and the material is in array point 5
using the following in a copy of the surface label
text2 0,1,_sContentStringsHead[1][1]
text2 0,2,_sContentStringsHead[1][5]
2024-08-07 05:22 AM
Having a quick look at that surface label, it seems it calls a subroutine to "collect_content".
This returns the information for the surface that is stored in the parameter array ... _sContentStringsHead
So I am assuming you would need to perform your SPLIT routine on that parameter value to get the part of the name that you want.
There are 2 GOSUBs in the label, one to get the information and one to display it.
Your split routine needs to be done between those two GOSUBs.
The thing is that _sContentStringsHead parameter is an array, so you will have to figure out what part of that array the information is in for the surface name.
You then need to SPLIT that name and then replace it back in the array so it is then used in the 'position_and_draw_label' sub-routine.
At the moment I don't have the time to investigate further.
But hopefully that will give you a start.
Barry.
2024-08-07 05:36 AM
Well I dont feel so silly not being able to trace that, now Ive seen how serpentine the structure is. Thankyou for your detective work @AllanP
2024-08-07 05:44 AM
I will give this a shot @Barry Kelly, thanks for your time looking into this. I'll post the hacked label if I'm able to get it to work.
2024-08-07 10:27 AM - last edited on 2024-08-15 12:46 AM by Laszlo Nagy
Thanks for your PS @AllanP
I got it to work with this. It will be a very useful label now 🙂
I just need to
! ==============================================================================
"collect_content":
! ------------------------------------------------------------------------------
! ==============================================================================
nTrans = 0
_nRowLabel = 0
dim _sRowsOfLabel[][]
_sRowsOfLabel[1][1] = ""
dim _sContentStringsHead[][]
_sContentStringsHead[1][1] = ""
gosub "call_general_label_macro"! returned text array, _nRowLabel, _sRowsOfLabel
_sContentStringsHead = _sRowsOfLabel
!split surface to code
string = _sContentStringsHead[1][5]
iDotPos = STRSTR (string, ":")
code = STRSUB (string, 1, iDotPos - 1)
_sContentStringsHead[1][5] = code
return
include an IF statement to check if there is a ":" in there and it will be good to go!
2024-08-08 04:40 AM - last edited on 2024-08-15 12:47 AM by Laszlo Nagy
Im struggling with the CONTAINS syntax, this is returning an error that "missing THEN statement". Driving me nuts!
! ==============================================================================
"collect_content":
! ------------------------------------------------------------------------------
! ==============================================================================
nTrans = 0
_nRowLabel = 0
dim _sRowsOfLabel[][]
_sRowsOfLabel[1][1] = ""
dim _sContentStringsHead[][]
_sContentStringsHead[1][1] = ""
gosub "call_general_label_macro"! returned text array, _nRowLabel, _sRowsOfLabel
_sContentStringsHead = _sRowsOfLabel
!split surface to code
IF CONTAINS (sep,_sContentStringsHead[1][5]) THEN
string = _sContentStringsHead[1][5]
iDotPos = STRSTR (string, sep)
code = STRSUB (string, 1, iDotPos - 1)
_sContentStringsHead[1][5] = code
ENDIF
return
2024-08-08 04:48 AM - edited 2024-08-08 04:55 AM
i cant find the "CONTAINS " command in the GDL manual
if you use:
if STRSTR(_sContentStringsHead[1][5]),sep) > 0 then
!!!BODY HERE
endif
2024-08-08 04:59 AM
There is no CONTAINS command in GDL (that I am aware of).
STRSTR is what you need to determine if a character is a part of a string.
Barry.
2024-08-08 05:03 AM
found CONTAINS here https://helpcenter.graphisoft.com/user-guide/137394/
will give STRSTR a try. thanks guys