Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Text Component Editor - How to count A, B, C not 1, 2, 3

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
9693 Views, 5 Replies

Text Component Editor - How to count A, B, C not 1, 2, 3

Hello,

 

I am trying to figure out how to change the labeling of my sample line style from (<[Sample Line Number(Sn)]> which out puts a count of 1,2,3,4 etc to output A,B,C,D etc

 

What would be the approperate code to make this happen?

 

Thanks guys,

5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

If you want to change the sample line numbers into the letters in your sample line style
description you can do it by creating your own sample line style that enables that operation.

 

Using this method you can easily create a letter description instead of a numerical/digital description.

 

This method is useful in every alphabetical system so you don’t need any additional software to create:

-        Letters in your native language alphabet,

-        Letters without certain and specific letters (if you want).

If they are not used by design for any particular reason (e.g. some national alphabet letters),

-        Your own letter system e.g. A, A’, A’’ or any other combination of an alphabetic system.

 

You will get all the needed information about this method to use it in the English alphabet.
You can also easily use it in any other alphabet system because it describes the universal rules which you can easily adopt to your unique situation. 

 

In spite of the differences in the alphabets like:

-        Additional national letters,

-        Changes in the letter sequences in the national alphabets,

-        Amount of letters (e.g. the English alphabet consists of 26 letters).

 

For most cases the sample lines can be described by the English alphabet letters without the national letters.

But even if you want to use them in your language you can do it anyway.

 

THE BASICS OF THE METHOD

You can make the sample line labels of the letter description for your sample lines.
You can assign a number to each letter and an extra number 0 equals null (empty).

1. Letters table.png

 

 

When you use the English alphabet you have 26 letters so you can describe it as:

2. Digits illustration.png

-        Using only one digit you have 26x260=26 so you can describe 26 sample lines,

-        Using only two digits you have 26x261+26x260= 702 so you can describe 702 sample lines,

-        Using only three digits you have 26x262+26x261+26x260 = 18 278 so you can describe 18278 sample lines, this should be sufficient enough for most cases.

 

Note that you will get the sequence of the letters among others:

A,B,C,…,Z,AA,AB,AC,…AZ,BA,BB,BC,…,BZ,…,…,ZZ,AAA,AAB,AAC,…AAZ,BAA,…,…,…,ZZZ

 

 

Generally you can convert any numerical/digital value into a letter marking.

You can use for this a simple method based on dividing and using the modulo operations.

This mechanism works as shown below:

 

8. Method illustration 1.png

Using these simple calculations you can create your expressions for your sample lines.
However in some cases you should also make some extra logic operations to get the correct
letter notation e.g. from the value = 680 you get the letters:  _, Z, D not:  A, _, D.

It is a consequence of using the 0 value to represent an empty space.

 

9. Method illustration 2.png

Therefore you should use an extra mechanism that will control the correct values of the letters, remembering that the letters have their own values from the range:  1 - 26.

 

In other words you cannot use the 0 value after a non-0 value.

You should change that 0 value into the preceding value which will be the value = 26

in your sample lines description.

 

So you should build some logic auxiliary expressions that will control the move mechanism

when it is necessary and calculate the proper values. You can use basic math and logic

operations and build such expressions in your sample lines.

 

1.Choose the Sample Line node from Settings in your Toolspace,

 

2. First of all, choose Label Styles and then add a new expression and give it a meaningful name e.g. NumChr which is equal to the amount of the letters in the English alphabet NumChr = 26 

   

3. Next create new truncated expressions for every digit which you should numbering
somehow but in the same manner e.g. the first digit = 1, the second digit = 2, the third digit = 3

 

4. You can choose some math functions by selecting the button with the f(x)+   icon.

 

5. Give your expressions some meaningful names e.g. Trunc1, Trunc2, Trunc3

and choose also Format result as Double,

 

Trunc1:

TRUNC((({Sample Line Number}/NumChr)/NumChr))

 

4. Trunc1 expression.png

Trunc2:

TRUNC((FMOD(({Sample Line Number}/NumChr),NumChr)))

 

Trunc3:

TRUNC((FMOD({Sample Line Number},NumChr)))

 

6. Create the auxiliary value expressions and give them some meaningful names e.g.
AuxVal1, AuxVal2, AuxVal3 and choose also Format result as Double,

 

AuxVal1:

IF((Trunc1+NumChr)<=NumChr,Trunc1+NumChr,Trunc1)

 

10. AuxVal1 expression.png

 

 

AuxVal2:

 

IF((Trunc2+NumChr)<=NumChr,Trunc2+NumChr,Trunc2)

 

 

AuxVal3:

IF((Trunc3+NumChr)<=NumChr,Trunc3+NumChr,Trunc3)

 

7. Create the digit value expressions which will calculate the final values of the letters and give them some meaningful names e.g. DigitVal1, DigitVal2, DigitVal3 and choose also Format result as Double,

 

DigitVal1:

IF((LOG10({Sample Line Number})/LOG10(NumChr))<=2,0,
IF(((Trunc2<=1)&((Trunc3!=AuxVal3)|(Trunc2!=AuxVal2))),

AuxVal1-1,AuxVal1))

 

 

13. DigitVal1 expression.png

 

DigitVal2:

IF((LOG10({Sample Line Number})/LOG10(NumChr))<=1,0,

IF((Trunc3!=AuxVal3),IF((AuxVal2-1=0),NumChr,AuxVal2-1),AuxVal2))

 

DigitVal3:

AuxVal3

 

 

You have the mechanism which calculates the proper values for each sample line.
Now you can build your expressions which will control the visibility by changing the height of every digit.

 

When the calculated letter corresponding to its position should be visible then the height of this letter changes into the height which is visible now and

if the letter shouldn’t be visible then the height of the letter changes into the invisible height equals almost zero. Thus you will see only the correct letters.

 

8. Create the expressions which will control globally the height of the letters:

 

MajusculeHeight = 0.005

MinusculeHeight = 0.0000000001

 

9. Create the expressions which will control the height of every letter,

 

The letter A expressions for 1, 2, 3 digit:

viA1 where A=1→IF(DigitVal1=1,MajusculeHeight,MinusculeHeight)

 

16. viA1 expression.png

 

 

viA2→IF(DigitVal2=1,MajusculeHeight,MinusculeHeight)

viA3→IF(DigitVal3=1,MajusculeHeight,MinusculeHeight)

 

The letter B expressions for 1, 2, 3 digit:

 

viB1 where B=2→IF(DigitVal1=2,MajusculeHeight,MinusculeHeight)

viB2→IF(DigitVal2=2,MajusculeHeight,MinusculeHeight)

viB3→IF(DigitVal3=2,MajusculeHeight,MinusculeHeight)

 

Getting the values from the letter table, create the expression for each letter until the letter Z:

 

The letter expressions Z for 1, 2, 3 digit:

viZ1 where Z=26→IF(DigitVal1=26,MajusculeHeight,MinusculeHeight)

viZ2→IF(DigitVal2=26,MajusculeHeight,MinusculeHeight)

viZ3→IF(DigitVal3=26,MajusculeHeight,MinusculeHeight)

 

10.Create the offset expressions which will control globally the distance between the letters,

 

For the first digit:

IF((LOG10({Sample Line Number})/LOG10(NumChr))<=2,0,0.015)

 

21. Offset1 expression.png

 

For the second digit:

IF((LOG10({Sample Line Number})/LOG10(NumChr))<=1,0,0.01)

 

For the third digit:

0.005

 

11. Create your own letter sample line style and name it e.g. myLetterSection,

 

12. Build the text elements for the sample line label letters,

 

13. Add a new text element for the first A digit and name it A1:

 

- Set Name = A1
- Anchor Point = End
- Contents = A
- Text Height = viA1
- X Offset = OffsetChr1

 

24. Label A1 properties.png

14. Add a new text element for the second A digit and name it A2:

 

- Set Name = A2
- Anchor Point = End
- Contents = A
- Text Height = viA2
- X Offset = OffsetChr2

 

15. Add a new text label for the third A digit and name it A3:

 

- Set Name= A3
- Anchor Point = End
- Contents = A
- Text Height = viA3
- X Offset = OffsetChr3

16.Add the text elements for each successive letter in the same manner,

 

17. Select the sample lines and choose the created sample line style description
and click the Add button,

 

18. Next click the OK button and finally you will see the result.

 

27. Letter labels finished.png

 

 

 

UNICODE IMPROVEMENT

 

If you know how the standard method works for the sample line letter style you can note how to improve it to get a much faster and a more effective method.


The standard 26-elements method uses 26 letters for every three positions that gives 26x3=78 elements.

 

You can reduce this number of elements and get a better method for a large amount of

sample lines because the more elements the greater losses.

 

28. Methods comparison.png

 

If you want to know how to expand this method by the Unicode improvement you can read the full story here http://goo.gl/rPvjD

 

 

Message 3 of 6
mathewkol
in reply to: Anonymous

Couldn't be simpler 😮 !!!!
Matt Kolberg
SolidCAD Professional Services
http://www.solidcad.ca /
Message 4 of 6
Anonymous
in reply to: mathewkol

Holy in-depth explanation Cadman!! Smiley Happy

Message 5 of 6
Anonymous
in reply to: Anonymous

The previous link is disabled


If you want to know how to expand this method by the Unicode improvement you can read the full story here http://goo.gl/rPvjD 


 

to read "Alphabetical instead of numerical Sample Line Labels" article

follow this link http://civilfastforward.com

 

Alphabetical instead of numerical Sample Line Labels.jpg

 

Message 6 of 6
hawstom
in reply to: Anonymous

Communication is not easy. Let's try to desconstruct this.

 

The strategy shared by CivilFF above is to create a single Label style that has text elements for all 26 letters on top of each other in each anticipated digit position, however many positions you expect to need.

 

Each of their heights is set to an individual corresponding height control expression. A height control expression must be defined for each letter in each digit position. Each height control expression evaluates to a tiny height for all but its particular letter and position.

 

The strategy also employs the programming Don't Repeat Yourself principle by using expressions for the following constants:
-NumChr: The number of characters in the alphabet
-MajusculeHeight: Visible height
-MinisculeHeight: Invisible height

 

Anyway, I'm not that desperate, I think.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report