GDL
About building parametric objects with GDL.

HELP - GDL Script for Wall Tag

drewcaddy
Participant

Hi Team,

 

I am trying to create a tag for our Wall Types for our office. We have an existing tag, but are looking to overhaul our template, and are now including some extra information in the title of our wall types. As a result, the label now pulls the extra ' : ', which we are hoping to avoid, only showing the text string previous to the ':'.

LABEL.jpg

 

I have limited knowledge of GDL, only really extending to copying what already exists! I've done some research, and had a play with that I've learnt, but still can't get the label to show correctly. 

Can someone point me in the right direction (code attached below)?

 

Thanks!

 

 

 

If UseFillasTag or AutoId then
	TempName = WALL_COMPS_NAME
	len = strlen(TempName)
	tex1num = strstr(TempName, " ")
	if tex1num > 0 then
		tex1a = strsub (TempName, 1 , 1)
		tex2 = strsub (TempName, 1 ,tex1num)
		tex1 =  strsub (TempName, tex1num+1,len-tex1num)
		if strstr(tex1a, "1") > 0 then Tex2 = tex1
		if strstr(tex1a, "2") > 0 then Tex2 = tex1
		if strstr(tex1a, "3") > 0 then Tex2 = tex1
		if strstr(tex1a, "4") > 0 then Tex2 = tex1
		if strstr(tex1a, "7") > 0 then Tex2 = tex1
		len = strlen(Tex2)
		if strstr(tex2, "PRIMARY") > 0 then Tex2 = strsub (Tex2, strstr(tex2, "PRIMARY")+8,len-strstr(tex2, "PRIMARY")-8)
		len = strlen(Tex2)
		if strstr(tex2, "WALLS") > 0 then Tex2 = strsub (Tex2, strstr(tex2, "WALLS")+5,len-strstr(tex2, "WALLS")-5)
		len = strlen(Tex2)
		if strstr(tex2, "WALL") > 0 then Tex2 = strsub (Tex2, strstr(tex2, "WALL")+4,len-strstr(tex2, "WALL")-4)
	else
		tex2 = TempName
	endif
	tex2num = strstr(tex2, " ")
	if tex2num > 0 then Tex2 = strsub (Tex2, 1,tex2num-1)
	tex2num = strstr(tex2, "-")
	if tex2num > 0 then Tex2 = strsub (Tex2, 1,tex2num-1)
	tex2num = strstr(tex2, "/")
	if tex2num > 0 then Tex2 = strsub (Tex2, 1,tex2num-1)
	tex2num = strstr(tex2, "(")
	if tex2num > 0 then Tex2 = strsub (Tex2, 1,tex2num-1)
	if AutoID = 1 and WALL_COMPS_NAME = "" then
	else
		TX = Tex2
	endif
endif

 



EDIT: Using AC22 on Windows.

AC 22
Windows 10
4 REPLIES 4
Barry Kelly
Moderator

I am assuming your wall composite name is something like...  P1: extra_description_here

 

I think it is because you are doing the string search (STRSTR) for a space " " after the colon instead of the colon ":" itself.

So the number of characters you are returning to tex1num is one more than the colon.

You are then using that string position number to get the substrings (STRSUB) from the composite name.

 

So search for the colon and/or adjust the number of characters you are using in the STRSUBs

 

I may be wrong, but that is my hunch.

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

Thanks Barry! That worked a treat!

This may be a stretch, but would it be the same for a surface label too? Hoping to do the same with the standard AC Surface Label, but can't see a similar code to what we had in the Wall Tag to make the update. Hoping to achieve this:

DESIRED LABEL.PNG

 

Rather than this:

 

AC22 LABEL.PNG

! ==============================================================================
! Functions:
! - Offered Tools: Wall, Slab, Roof, Shell, Column, Beam, Mesh, Morph Door, Window, Skylight, CWFrame, CWPanel
! - Content: Material of Surfaces
! - Size: paper size
! ==============================================================================
_isPreview = (GLOB_CONTEXT = 5)
_paperToModel = GLOB_SCALE/1000

! resizing paper size parameters values to model length
widthTextBoxContent_mm		= widthTextBoxContent_mm * _paperToModel
widthHead_mm				= widthHead_mm * _paperToModel
heightHead_mm				= heightHead_mm * _paperToModel


gosub "install_label_position"

if not(_isEnabledContent) then
	! - Offered Tools: Wall, Column, Slab, Roof, Beam, Shell, Skylight, Mesh, Morph
	call "label_placeholder" parameters all bitAvailableTool 	= 32+64+128+256+1024+4096+262144+1048576
	end
endif

gosub "collect_content"

gosub "position_and_draw_label"

! ==============================================================================
END	!END	!END	!END	!END	!END	!END	!END	!END	!END	!END
! ==============================================================================

! ==============================================================================
"install_label_position":
! ------------------------------------------------------------------------------
! Label positioning - global behavior for Marker form Labels
! - origin is where AC gives, the table begins with top left anchor 
! - orientation is rotated with the parent structure by default
! - without AC Arrow
!		- drawing the full symbol marker form
! 		- the origin is at the arrow peak
! 		- rotating with parent elem direction
! 		- Reference Point is cordinated by user
! - with AC Arrow
!		- drawing only the head text
!		- the origin is at the boundary
!		- handling of rotation is belongs to AC (AC_CustomReadabilty OFF)
!		- Reference Point is cordinated at Pointer tabpage
!
! LABEL_POSITION 	- position of the label
! 					- array[3][2] containing the coordinates of the 3 points defining the label position 
!
! - the other transformations live in the label_marker_macro
! ==============================================================================

	nTrans = 0

	if not(LABEL_HAS_POINTER) then
	
		add2 	LABEL_POSITION [2][1]	+	LABEL_POSITION [3][1],
				LABEL_POSITION [2][2]	+	LABEL_POSITION [3][2]

	endif

return

! ==============================================================================
"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
return

! ==============================================================================
"position_and_draw_label":
! ------------------------------------------------------------------------------
! Text Style tabpage:
! LABEL_HAS_POINTER 		- built-in pointer ON/OFF
!								- on/off 1 if the Use symbol arrow checkbox is checked, 0 otherwise
! AC_LabelPointerLineType 		- line type of the line of the arrow
! AC_LabelPointerPen 			- pen of the arrow
! AC_TextFont_1 			- font name
! AC_TextSize_1			- text size
! AC_TextPen_1 			- pen of the text
! AC_LabelTextBgrPen			- text box background pen
! 								- 0 if opaque is off, the background pen otherwise
! AC_TextStyle_1 		- font style in the settings dialog box
!								- 0 - normal, otherwise j1 + 2*j2 + 4*j3 + 32*j6 + 64*j7 + 128*j8, j1 - bold, j2 - italic, j3 - underline, j6 - superscript, j7 - subscript, j8 - strikethrough 
!								- there is strikethrough and this global works well with define style{2} !
! AC_bLabelFrame			- label frame on/off 1 if the label frame is checked, 0 otherwise
! LABEL_ROTANGLE 			- rotation angle using by AC (this rotation is not from GDL)
! AC_TextAlignment_1			- text alignment for full table
!								- 1 - left aligned, 2 - center aligned, 3 - right aligned, 4 - full justified
! AC_TextLeading_1 		- line spacing factor
! AC_TextCharWidthFactor_1 	- width factor
! AC_TextCharSpaceFactor_1 - spacing factor
! ==============================================================================

	_angleParentDirection = 0
	if not(_isPreview) then
		_angleParentDirection = LABEL_ASSOC_ELEM_ORIENTATION
	endif

	call "label_marker_form" parameters AC_CustomReadability = AC_CustomReadability,
		bAlwaysReadable				= AC_bLabelAlwaysReadable,

		! Position
		iReferencePoint				= iReferencePoint,
		AC_LabelOrientation 		= AC_LabelOrientation,
		angleParentPosition			= _angleParentDirection,

		! Paragraph Format
		bEnablePrefixColumn			= 0,
		bUsePrefixColumn			= 0,
		bWrapText					= AC_bLabelTextWrap,
		widthTextBoxContent_mm		= widthTextBoxContent_mm,
		xFirstIndentParagraph		= 0,
		xLeftIndentParagraph		= 0,
		xRightIndentParagraph		= 0,
		xTabPositionParagraph		= 0,
		widthFactorTextBlock		= AC_TextCharWidthFactor_1,
		charspaceFactorTextBlock	= AC_TextCharSpaceFactor_1,
		iFixedHeightTextBlock		= 0,		! fixed_height 	1: the placed TEXTBLOCK will be scale-independent and all specified length type parameters will mean millimeters, !
										!0: the placed TEXTBLOCK will be scale-dependent and all specified length type parameters will mean meters in model space

		! Head apperance
		sContentStringsHead			= _sContentStringsHead,
		bEnableCustomHeaderStyle 	= 0,
		penTextHeader				= AC_TextPen_1,
		fontTypeHeader				= AC_TextFont_1,
		sizeFontHeader_mm			= AC_TextSize_1,
		iTextStyle					= AC_TextStyle_1,
		iAlignmentHeader			= AC_TextAlignment_1,	! 1: left aligned, 2: center aligned, 3: right aligned, 4: full justified
		sizeLeadingHeader			= AC_TextLeading_1,
		widthTextBoxOffset			= AC_LabelFrameOffset * _paperToModel,


		! Body skin list appearance
		bUseTextBoxOnLine				= 0,

		! Label Head Representation
		bEnableHeadSwitch			= 0,							! Enable to switch the Show Label Head ON-OFF
		bShowHead					= 1,
		iShapeHead					= iShapeHead,
		bFitFrameToText	= bFitFrameToText,
		widthHead_mm				= widthHead_mm,
		heightHead_mm				= heightHead_mm,
		bLinkSizes					= bLinkSizes,
		bShowHeadContour			= AC_bLabelFrame,
		penHead						= AC_LabelPointerPen,
		lineTypeHead				= AC_LabelPointerLineType,
		bShowFill					= 1,
		penForeground				= _AC_LabelTextBgrPen,
		penBackground				= _AC_LabelTextBgrPen,

		! Label Line Representation
		distanceLabelHead_mm		= 0,
		bEnableLeaderLine			= 0,

		bDebug						= 0

	del nTrans : nTrans = 0

return

! ==============================================================================
"call_general_label_macro":
! ------------------------------------------------------------------------------
! input: 
!	bShowCompositeID
!	iIDPlacing
!	sSeparator
!	iIDText
!	
! input variable
!	totalRotate
!	_drawContent - 0 - calculating only, 1 - draw text
!
! output variable:
!	_widthTextBlock, _heightTextBlock
! ==============================================================================
	_nRowLabel = 0
	dim tempsRowsOfLabel[]
		tempsRowsOfLabel[1] = ""

	call "label_content_macro" parameters iSelectedContent = _iSelectedContent,
			iUnitLocal				= _iUnitLocal,
			bUseInSingleRank		= 0,
			bUsePrefixColumn		= 0,
			bShow2D = 0,
			iSurfaceToDisplay		= iSurfaceToDisplay,
			sPrefixSurface			= sPrefixSurface,
			sSuffixSurface			= sSuffixSurface,
			sCustomSurface			= sCustomSurface,

		returned_parameters  _nRowLabel, tempsRowsOfLabel

		! making from one dimensioned array to two dimensioned
		idx = 0
		dim _sRowsOfLabel[][]
			_sRowsOfLabel[1][1] = ""
		for i = 1 to _nRowLabel
			for j = 1 to 48
				_sRowsOfLabel[i][j] = tempsRowsOfLabel[idx + j]
			next j
			idx = idx + 48
		next i
return


Thanks for the help - really appreciate it!

AC 22
Windows 10

 

 


@drewcaddy wrote:

This may be a stretch, but would it be the same for a surface label too? Hoping to do the same with the standard AC Surface Label, but can't see a similar code to what we had in the Wall Tag to make the update. Hoping to achieve this:

I really don't know for sure.

It looks like the surface label CALLs macros to gather and arrange the information.

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

Hi, I don't recommend modifying the AC Surface Label, it's too general for your task,

if you are only labelling wall composites.

Use WALL_COMPS_NAME to get the composite name, then use the STR functions to take it apart.

Péter Baksa
Software Engineer, Library
Graphisoft SE, Budapest