2022-08-11
01:52 AM
- last edited on
2022-09-26
10:41 PM
by
Daniel Kassai
Hi guys,
I've started making my way through learning GDL, using the Reference guides, and mostly via modifying existing scripts and checking various outcomes.
Current project is to restructure the 2D Dimension display of the Archicad 24 gs_dw_Marker
Specifically the Dimension Style = DIMSTYLE_1LINE
My query is how is the structure of the code dictates String Text before the Length Values : Ref Image Below
By replacing & switching the _lengthHeightValue with the _lengthWidthValue i can control the values, but how is the flow control statements, structuring the position order of the string text before the Length Values.
I understand its my lack of basic script knowledge, but i struggle to learn without direct application, so reading the reference guide is only helpful to an extent.
Refer to the Script Below, I've listed my values to be replaced in red, with there substitutes in pink.
! ==============================================================================
! Show Width/Height
! ==============================================================================
_nTrans = 0
if AC_WidHei_On then
textAngleWH = textAngle
if iDimensionStyle = DIMSTYLE_2LINES and (iDimensionsDir = DIRVALUES_ALIGNED) then
textAngleWH = textAngle + 90
if textAngle >= 360 then
textAngleWH = textAngle - 360
endif
endif
add2 markerOffsetModel, 0
rot2 90
_nTrans = _nTrans + 2
if iMarkerSizeUnit = 1 then
hotspot2 0, 0, unID, whDistM, 1+1024+128, whDistMm
hotspot2 -1, 0, unID+1, whDistM, 3+1024, whDistMm
hotspot2 whDistModel,0, unID+2, whDistM, 2+1024, whDistMm
endif
if iMarkerSizeUnit = 2 then
hotspot2 0, 0, unID, whDistM, 1+1024+128, whDistCm
hotspot2 -1, 0, unID+1, whDistM, 3+1024, whDistCm
hotspot2 whDistModel,0, unID+2, whDistM, 2+1024, whDistCm
endif
if iMarkerSizeUnit = 3 then
hotspot2 0, 0, unID, whDistM, 1+1024+128, whDistPoint
hotspot2 -1, 0, unID+1, whDistM, 3+1024, whDistPoint
hotspot2 whDistModel,0, unID+2, whDistM, 2+1024, whDistPoint
endif
define style{2} "extraStyle2" _textFont2, _textSize2, _textStyle2 + 32
define style{2} "extraStyle3" _textFont3, _textSize3, _textStyle3 + 32
if iDimensionStyle = DIMSTYLE_2LINES then
if bShowWidthHeight then
if textAngleWH > (gs_readable_angle + eps) & textAngleWH < (gs_readable_angle + 180 + eps) & AC_Readable then
bSwitchTexts = 1
else
bSwitchTexts = 0
endif
_textPen = _textPen3
_iUnitTypeByContent = 7 ! "Windor_Door_Dimension"
if GS_iCustomText_3 = CTXT_CUSTOMTEXT then
_horAlign = 3
note1 = AC_MarkerText_3
note2 = ""
note3 = ""
note4 = ""
else
_lengthValue = _lengthHeightValue
_horAlign = 3
_TextFont = _textFont3
_TextSize = _textSize3
_TextStyle = _textStyle3
_szPrefix = ""
gosub "call_quantity_formatter"
endif
if iDimensionsDir = DIRVALUES_ALIGNED then
posX = whDistModel / PAPER_TO_MODEL
if bSwitchTexts then
posY = _textSize3 / 2
else
posY = -1.5 * _textSize3
endif
else
del 1
_nTrans = _nTrans - 1
_posXPerpendicular = max (stw(AC_MarkerText_2), stw(AC_MarkerText_3)) / 2
posX = _posXPerpendicular
posY = whDistModel / PAPER_TO_MODEL - 1.5 * _textSize3
endif
style1 = "mtext3style"
style2 = "extraStyle3"
style3 = "mtext3style"
style4 = "mtext3style"
notesize = _textSize3
angle = textAngleWH
enabled = AC_Readable
iMarkerDir = DIRVALUES_PERPEND
_bWidHei = 1
gosub "Print_text_considering_readability"
if GS_iCustomText_2 = CTXT_CUSTOMTEXT then
_horAlign = 3
note1 = AC_MarkerText_2
note2 = ""
note3 = ""
note4 = ""
else
_lengthValue = _lengthWidthValue
_horAlign = 3
_TextFont = _textFont2
_TextSize = _textSize2
_TextStyle = _textStyle2
_szPrefix = ""
gosub "call_quantity_formatter"
endif
if iDimensionsDir = DIRVALUES_ALIGNED then
posX = whDistModel / PAPER_TO_MODEL
if bSwitchTexts then
posY = -1.5 * _textSize2
else
posY = _textSize2 / 2
endif
else
posX = _posXPerpendicular
posY = whDistModel / PAPER_TO_MODEL + _textSize2 / 2
endif
_textPen = _textPen2
style1 = "mtext2style"
style2 = "extraStyle2"
style3 = "mtext2style"
style4 = "mtext2style"
notesize = _textSize2
angle = textAngleWH
enabled = AC_Readable
iMarkerDir = DIRVALUES_PERPEND
_bWidHei = 1
gosub "Print_text_considering_readability"
endif
del 1
_nTrans = _nTrans - 1
else ! iDimensionStyle = DIMSTYLE_1LINE
del 1
_nTrans = _nTrans - 1
! --- Dimensions with separator ---
_iUnitTypeByContent = 7 ! "Windor_Door_Dimension"
if AC_WidHei_On then
_formattedWidth = ""
_formattedHeight = ""
_formattedWExtra = ""
_formattedHExtra = ""
_horAlign = 3
_TextFont = _textFont2
_TextSize = _textSize2
_TextStyle = _textStyle2
_szPrefix = ""
if GS_iCustomText_2 = CTXT_CUSTOMTEXT then
_formattedWidth = stWidHeiPrefix + AC_MarkerText_2
else
_lengthValue = _lengthWidthValue_lengthHeightValue
_szPrefix = stWidHeiPrefix
gosub "call_quantity_formatter"
! store returned formatted text
_formattedWidth = note1
_formattedWExtra = note2
endif
if GS_iCustomText_3 = CTXT_CUSTOMTEXT then
_formattedHeight = stWidHeiSep + AC_MarkerText_3
else
_lengthValue = _lengthHeightValue_lengthWidthValue
_szPrefix = stWidHeiSep
gosub "call_quantity_formatter"
! store returned formatted text
_formattedHeight = note1
_formattedHExtra = note2
endif
note1 = _formattedWidth
note2 = _formattedWExtra
note3 = _formattedHeight
note4 = _formattedHExtra
style1 = "mtext2style"
style2 = "extraStyle2"
style3 = "mtext2style"
style4 = "extraStyle2"
notesize = _textSize2 !+_textSize2/3
angle = textAngleWH
enabled = AC_Readable
iMarkerDir = iDimensionsDir
if _formattedHExtra <> "" or _formattedWExtra <> "" then
_increaseTextSize = 1
else
_increaseTextSize = -1
endif
posY = whDistModel / PAPER_TO_MODEL
if (angle > (gs_readable_angle + eps) & angle < (gs_readable_angle + 180 + eps) & enabled & iMarkerDir = DIRVALUES_PERPEND) | \
(angle > (gs_readable_angle - 90 + eps) & angle < (gs_readable_angle + 180 - 90 + eps) & enabled & iMarkerDir = DIRVALUES_ALIGNED) then
posX = stw (_formattedWidth) + stw (_formattedWExtra)*2/3*_increaseTextSize + stw (stWidHeiSep) / 2
else
posX = stw (_formattedHeight) + (stw (_formattedHExtra))*2/3*_increaseTextSize - stw (stWidHeiSep) / 2
endif
if iMarkerDir = DIRVALUES_ALIGNED then
add2 -notesize/3*PAPER_TO_MODEL, 0
endif
_bWidHei = 1
_textPen = _textPen2
gosub "Print_text_considering_readability"
if iMarkerDir = DIRVALUES_ALIGNED then
del 1
endif
endif
endif
else
! visible, movable and dimensionable hotspot is moved and locekd
hotspot2 markerOffsetModel, _yDoorCenterPoint, unID+2
endif
unID = unID + 3
del _nTrans
_nTrans = 0
Solved! Go to Solution.
2022-08-11 04:09 AM - edited 2022-08-11 04:10 AM
You have not included the portion of script that actually plots the text out. Should be a TEXT2 and probably a PARAGRAPH somewhere. Follow this sub: gosub "Print_text_considering_readability"
AC22-23 AUS 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win10 | R5 2600 | 16GB | GTX1660 |
2022-08-11
07:13 AM
- last edited on
2022-08-13
11:33 PM
by
Laszlo Nagy
Hi Lingwisyer, thanks for the reply!
I've copied the code in below, i was under the impression that the plotting script would have to reference the (_LengthHeightValue & _stWidHeiPrefix, ect. )? but i guess this isnt the case, still unsure as how to the data is being transfered.
! ==============================================================================
! Print text considering readability
! ==============================================================================
! works for anchor point 1 only! (top left corner)
! optional extra text in 2/3 size, elevated to 1/3 hight
!
! posX: text position X
! posY: text position Y
! note1: text
! note2: extra text
! style1: style of text
! style2: style of extra
! _horAlign:1-left, 2-center, 3-right
! angle: text angle
! enabled: may rotate
! ==============================================================================
"Print_text_considering_readability":
if note2 <> "" or _increaseTextSize then
_bextra = 1
else
_bextra = 0
endif
mul2 PAPER_TO_MODEL, PAPER_TO_MODEL
numTrans = 1
if iMarkerDir = DIRVALUES_ALIGNED and _bWidHei then
add2 -notesize / 2, posY
else
add2 0, posY + notesize / 2
endif
numTrans = numTrans + 1
rotdir_angle = 0 ! iMarkerDir = DIRVALUES_PERPEND
if iMarkerDir = DIRVALUES_ALIGNED then rotdir_angle = 90
if iMarkerDir = DIRVALUES_HORIZONTAL then rotdir_angle = -textAngle
if iMarkerDir = DIRVALUES_VERTICAL then rotdir_angle = -textAngle + 90
rot2 rotdir_angle
numTrans = numTrans + 1
style style1
_textStyle1 = style1
if abs(lengthOfNote1 < EPS) | \
abs(lengthOfNote2 < EPS) | \
abs(lengthOfNote3 < EPS) | \
abs(lengthOfNote4 < EPS) then
gosub "compute_note_lengths"
endif
if _horAlign = 2 then
add2 -(lengthOfNote1+lengthOfNote2+lengthOfNote3+lengthOfNote4)/2, 0
numTrans = numTrans + 1
endif
if _horAlign = 3 then
add2 -(lengthOfNote1+lengthOfNote2+lengthOfNote3+lengthOfNote4), 0
numTrans = numTrans + 1
endif
if (angle > (gs_readable_angle + eps) & angle < (gs_readable_angle + 180 + eps) & enabled & iMarkerDir = DIRVALUES_PERPEND) | \
(angle > (gs_readable_angle - 90 + eps) & angle < (gs_readable_angle + 180 - 90 + eps) & enabled & iMarkerDir = DIRVALUES_ALIGNED) then
add2 posX + lengthOfNote1 + lengthOfNote2 + lengthOfNote3 + lengthOfNote4, notesize/2 ! top right corner
rot2 180
numTrans = numTrans + 2
else
add2 posX, - notesize/2 ! bottom left corner
numTrans = numTrans + 1
endif
rrr = request("Height_of_style", style1, sy, descent, leading)
dl = (descent + leading)
if GLOB_FEEDBACK_MODE then
_drawRichText = 0
else
_drawRichText = 1
endif
paragraph "Paragraph1" 1, 0, 0, 0, 1, 0 !1
pen _textPen
style _textStyle1
note1
style style2
note2
style style3
note3
style style4
note4
endparagraph
textblock "Textblock1" 0, 7, 0, AC_TextCharWidthFactor_1, AC_TextCharSpaceFactor_1, 0, "Paragraph1"
rrr = REQUEST ("TEXTBLOCK_INFO", "Textblock1", _widthTB, _heightTB)
if _drawRichText then
richtext2 0, -dl, "Textblock1"
else
rect2 0, -dl, _widthTB, _heightTB-dl
endif
del numTrans
return
2022-08-11 07:18 AM
The goal is to restructure the stWidHeiPrefix to show at the end (as a suffix)
2022-08-11 11:03 AM
So this script is using Paragraph, Textblock and Richtext2. I have not used Paragraph as in input into a Textblock before but I would look at your note# parameters. Is stWidHeiPrefix one of your note# parameters? If it is, you could probably just reorder them within the Paragraph command.
Ling.
AC22-23 AUS 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win10 | R5 2600 | 16GB | GTX1660 |
2022-08-11 05:08 PM
I'm not on my pc with Archicad right now. But from ;
note1 = _formattedWidth
note2 = _formattedWExtra
note3 = _formattedHeight
note4 = _formattedHExtra
This mean that the "note1 to 4" has value assigned to each one. And then, in the "paragraph" ;
paragraph "Paragraph1" 1, 0, 0, 0, 1, 0 !1
pen _textPen
style _textStyle1
note1
style style2
note2
style style3
note3
style style4
note4
endparagraph
You can experiment by changing the order of "note1" to "note3" (without using the "" sign). Or you can ;
paragraph "Paragraph1" 1, 0, 0, 0, 1, 0 !1
pen _textPen
style _textStyle1
"asdf" + note1 + " - " + note3
!style style2
!note2
!style style3
!note3
!style style4
!note4
endparagraph
Notice the "!" used to comment out unused lines of code. Play around with the styles and order of the contents as you like.
BTW, I think this should be in the Dev forum, not Design forum.
2022-08-12 02:51 AM - edited 2022-08-12 02:54 AM
Hey guys, Thankyou for the responses!!
So i worked out that the note1 & note2 were obviously the sizes, but were combining the Prefix & Separator into each, back in the 2D Dimension text script that i originally posted. The note 3 & note4 seem to be variations of note 1 & note2, so restructuring the code with those notes wasnt ever going to achieve the intended purpose!
I solved it via removing the prefix & separator data that was being added into note1 & note2 in first section of script originally posted, then I Followed up with Palawats idea in cancelling out the remainder of the paragraph and adding the required code into the note1 Line!
And this was the Outcome!
So far seems to be working, just have to double check & stress test that cancelling the note3/note4 doesnt create issues!
Thanks for the help guys! Very Informative, and your effort is appreciated!
Kind Regards Samuel H
2022-08-12 03:20 AM - edited 2022-08-12 03:25 AM
Good to know. There is so much x=y=z=a in this object that it is hard to follow... Can the marker still show the window / door number? My guess would be that the other notes are Sill Height and Related Zone.
BTW, I think this should be in the Dev forum, not Design forum.
More like there should be a Library and / or GDL sub... I see the Dev sub being more to do with the API. They killed the GDL forum to streamline everyone into the GDL sub on the old forum, then they killed that too... Zzz...
Ling.
AC22-23 AUS 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win10 | R5 2600 | 16GB | GTX1660 |
2022-08-12 03:33 AM
Honestly its quite the labyrinth!
And that definitely is an issue, as now that those parameters have been added directly into that paragraph controlling the text plotting, all other additional parameters which had options to be added in with their own textblocks and hotspots, are now also combined with the prefix & separator from the dimensions code.
So for instance if the fire rating textblock is activated, it produces as follows:
To combat this i know i'll have to restructure the original note# within the window height & width script individually, rather then the paragraph controlling all of the text blocks. But i still count this as a minor win in learning the behavior of the paragraph in relation to the text block.
I have my goal for the weekend and at least a place to start!
2022-08-12 03:50 AM - edited 2022-08-12 03:52 AM
Following the "call_quantity_formatter" gosub, there is a note next to the parameters.
note1, !szPrefix + main
note2, !frac,
note3, !szUnit,
note4, !szUnitIndex
In the subsequent call there is:
note1 = szPrefix + main
If main is a tempt variable, and that is where the prefix is added, you might just be able to flip that line. Else if you can locate it happening elsewhere and comment it out, you could add it to the following line:
note1 = _formattedWidth + _formattedHeight
Ling.
Note: All of the GS objects are a nightmare to read through as there are millions of gosub, call and temp variables.
AC22-23 AUS 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win10 | R5 2600 | 16GB | GTX1660 |