GDL
About building parametric objects with GDL.

Efficient way to crop text by length in cm

Anonymous
Not applicable
Hi,

i hope I haven’t missed a function, but I’m looking for a efficient way to crop text by a given length and not by the number of characters, like “strsub”.

Maybe somebody have a better solution.
My actual solution is:

while stw(txt1) >100 do !** 100 is the max lenght of the text
txt1=strsub(txt1,0,_loop)
_loop=_loop-1
endwhile
10 REPLIES 10
Joachim Suehlo
Advisor
With Richtext2 this should work.
Drag and drop a multine 2D Text into a 2D Script window
and define Parameters for Text content and text length and replace the
hard coded values by the parameters in the script.
Joachim Suehlo . AC12-27 . MAC OSX 13.5 . WIN11
GDL object creation: b-prisma.de
Anonymous
Not applicable
Hi Joachim,

i think with Richtext2 i only have the option to get a linebreak after the given lenght, so that i get a new line when the text didn't fit, what i want to avoid.
Barry Kelly
Moderator
So just to be clear.
You don't want the text to wrap to a new line.
You just want to cut the text off at a certain width and not after a certain number of characters?

Barry.
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Anonymous
Not applicable
Yes exactly
runxel
Legend
Not really sure why that would be useful, but it's certainly an edge case. There is no built-in function for that.

What you've done there is already quite good.
The only way there might be to improve the execution time, would be some kind of "divide & conquer" algorithm.
Lucas Becker | AC 27 on Mac | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»
Anonymous
Not applicable
You're right, an edge case, that's why i haven't asked some years ago.

F.E. when you have an object, which shows the change history of an layout, like the Graphisoft Object already does. The content of the name is limited to 255 char., when you want to limit the column width you have to use linebreaks, which may cause to many lines.
runxel
Legend
Okay, this might be an legitimate example, which I can totally understand.
Still an edge case, tho.

Also: Would you really want to split a word at an arbitrary position?
This will look weird to anybody who reads it, for sure.
I guess you're the BIM manager of your office (or a similar position). Maybe you can introduce a special char as a delimiter (like ";") in your office. And everything after that char gets cut off.
Or you just split by space (" "). This might be the easiest and best looking solution. It will also perform slightly faster than looping through every character, I assume.
Maybe even leave enough room for an ellipsis ("…") to append to the string, so it doesn't look as bad.
Lucas Becker | AC 27 on Mac | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»
Anonymous
Not applicable
The idea was, to have it as option. Maybe sometimes it's better to crop one name of a change, than to push others out of the table. You're idea with the ellipsis is nice.

I've started in investigate, if a simplified object for the change management makes sense.

I'm no a BIM Manager, i'm ArchiCAD Trainer, Consultat, Instructor at Graphisoft Berlin.
Maybe i should revise my signature
runxel
Legend
Hello there fellow Berliner!
FST_Berlin wrote:
I've started in investigate, if a simplified object for the change management makes sense.
Ah, like... for distribution in the D(ACH) space with the next release?

Offtopic:
Archicad 4-40
Well I certainly got the joke
Lucas Becker | AC 27 on Mac | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!