ALTEXT

Replace texts, change multiple numbers by adding or multiplying, add texts as prefix, suffix or in the middle of the string and get sum of figures in selected Texts, Mtexts, Block Attributes, MultiLeaders, and attribute in MultiLeader blocks.

INTRODUCTION

With ALTEXT, you can complete the following time-consuming tasks in just 2 seconds.

It can intellectually find the numbers in selected texts and change them accordingly.

Command: ALTEXT
Select objects:

You can select Texts, Mtexts, Blocks with Attribute(s), and MultiLeaders.

If there is one attribute in all selected blocks, it prompts:

Search by tag name? [Yes/No] <N>:

Enter Yes to enter a tag name or a search pattern, same as steps below.

If there are blocks in the selection, and some of the blocks have more than one attribute, it prompts:

Which attribute to be changed (Enter 0 to search attribute tag name): Attribute No.<1>:

The attribute number refer to the sequence of the editable attributes in the block definition. No.1 is the first row of attribute appears in the ATTEDIT dialogue box. Constant attributes are not editable.
If the number of editable attribute in any block is less than the input attribute number, this block is skipped and no change is made to it.

You can enter 0 to input the tag name or search with a certain pattern.

Enter an attribute tag name or a search pattern:

You can use "Wildcard" in your search pattern. For example: Enter "Chin*" will match "China", "Chinese" "Chinese Hero" etc. If you attribute tag name contains some special characters and you don't want it is recognized as a wildcard pattern, you need enter symbol "`" in front of these special characters. These characters include [#@.*?`,~].
For more information about "Wildcard", please refer to here.
In search pattern mode, it doesn't allow "Sort selection" or use "Relative" to change numbers in a sequence.

If none of the objects has the selected attribute No., it prompts as following and exits:

Selected attribute No. exceeds total editable attribute number.

Otherwise, a "Change text content" dialogue box appears as below: 

Options:

You can choose one of these two options to replace selected contents with modified content individually or with a brand-new content globally.

This option is enabled when the "Insert at" slider below points to "(Middle)".
Use this option to define whether the insert position of new text is counted from left-hand side or right-hand side of selected text / number.

Examples:

1. When count from left, position 1 in text "ABCDE" is "A", new text will be inserted to the right side of this position. So with new text dash symbol "-" inserted, the result will be "A-BCDE".

2. When count from right, position 1 in text "ABCDE" is "E", new text will be inserted to the left side of this position. So with new text dash symbol "-" inserted, the result will be "ABCD-E".

Move the indicator of the slider to switch among these three options. It defines the location of the inserted new text in selected text string.
When the indicator points to "(Middle)", the "Position" option below and "Count from" option above are available.

This option is enabled when "Insert at" slider points to "(Middle)". Input positions where you want to insert new text in the text string / number.
Position could be 0 and any integers. It accepts multiple position inputs to insert same new text in different positions.
Separate positions with space or comma, eg. "0 1 2 5 10", or "2,4, 7, 9" are all valid position inputs.
Repeated positions are ignored. eg. "1, 2, 2, 5, 5," equals "1, 2, 5".
When "Change to Number" is selected, the positon is counted based on the whole text string.
Any position beyond the last position of the text string will be ignored. eg. position "6" is ignored in text "ABCD" because its last position is 4.
When "Count from Left" is selected, position 0 equals insert prefix to the text string.
When "Count from Right" is selected, position 0 equals insert suffix to the text string.

Examples:

1. "Count from Left" and insert "-" to position "0, 3, 8" of text string "LEVEL12345A", "Change to String" will get "-LEV-EL123-45A", while "Change to Number" will get "LEVEL-123-45A"

2. "Count from Right" and insert "-" to position "0, 3, 8" of text string "LEVEL12345A", "Change to String" will get "LEV-EL123-45A-", while "Change to Number" will get "LEV-EL12-345-A"

This option has different meanings bechantween "Replace with Modified" and "Replace with New".
When the option "Replace with Modified" is selected, new text will be inserted to certain positions of selected text strings.
When the option "Replace with New" is selected, new text will replace selected contents entirely.

This option enable user to filter out certain texts which matches a search pattern and only apply changes to them, skipping other texts.
Leave the input box blank or set it to * if no filter needed and apply changes to all texts.
Enter text search pattern with wildcard characters. The usage of wildcard is same as in AutoCAD FIND command. 
Search pattern is capital sensitive.
Also see Note 13 below.
When "Replace with modified" and "Change to number" are selected, if there is any number included in selected texts, all the options in "Number" column are enabled.  

Example:

Enter "PB*" here to set up a search pattern so changes only apply to texts start with "PB", all other texts in the selection remain unchanged. 

These two options define from which side should ALTEXT search number from in each text.
For instance, if the text string is "A 3 level building 9.3m high", select "Left" gets number 3, select "Right" gets number 9.3

These two options define the increment is applied universally or only relative to the last changed figure.
For instance, when Relative is selected, selected 5 copies of text 1A, and set the increment as 1, the result will be 1A, 2A, 3A, 4A, and 5A.
The first number is going to remain.
When Absolute is selected in such case, the result will be 5 copies of 2A.
The picking order is important to the result if "Relative" is used to generate a number sequence.

Select one of these options to apply addition/substraction or multiply/division to figures with the Increment.
If you want to do subtraction, put negative symbol in front of the Increment value;
If you want to do division, convert denominator to its reciprocal, put it in the Increment, then select "x Multiply".
"+ Plus" is the default option and is selected automatically when you select "Relative", and "Absolute" is selected automatically when you select "x Multiply"

It can be a positive or negative real or fraction such as "-11.4/3.08". The default is 0.0.
Input leading zeros here and select "Use Increment precision" below can add leading zeros to number. For example, input "00000" here and select "Use Increment precision" can add leading zeros to numbers to make a 5-digit format, such as "01234" and "00008". Refer to "Use Increment precision" below for more details.

Only numbers equal or greater than the figure definied in "Start from" will be affected. It can be a positive or negative real. The default value is the smallest number contained in all selected texts and found by the "Search from" option.
It is not avaiable when "Relative" is selected.
This option is also avaiable when "Replace with new" and "Change to number" are selected.

Only numbers equal or smaller than the figure definied in "End at" will be affected. It can be a positive or negative real. The default value is the greatest number contained in all selected texts and found by the "Search from" option.
Default "Start from" and "End at" will be changed automatically when different options selected among "Left", "Right", and "Dash as negative symbol".
It is not avaiable when "Relative" is selected.
This option is also avaiable when "Replace with new" and "Change to number" are selected.

If selected, the character dash "-" will be recognized as a negative symbol.
For instance, if the text string is "Level -5 Car Park P-3a", when this option is selected and search from left, it will get number -5; deselect this opton will get number 5.

If selected, the character dot "." will be recognized as the decimal point.
Otherwise, it will not be recoginzed as a part of figure.
For instance, if the text string is "DOOR1.23", when this option is selected, it will find the figure 1.23, otherwise two figures 1 and 23 will be find separately when searching from Left and Right.

A brief summary of the sum of all figures in selected objects, it might changes according to different settings of "Search from", "Dash as negative symbol" and "Dot as decimal point". The result will be shown in the command line as well so you can copy it from there for further use.

By default, this option is not selected and the change to numbers will use the precision of the original number.
If this option is selected, the precision of the result will use the precision of the number input in "Increment" eidt box.
This option is only avaiable when "Modified" and "Number" are selected.
This option has no effect on the result if "Increment" is a fraction.
This option can also be used to add leading zeros to numbers. For example, to change 1, 2, 3, ... to 0001, 0002, 0003, ...etc, just select this option and input "0000" in "Increment" above.
When adding leading zeros, keep in mind the precision of Increment (the decimal part) also affect precision of the result.
For example, Input "0000.000" in "Increment" will change number 1 to 0001.000, 23.3 to 0023.300.
Input "0000" in "Increment" without decimal part will remove all decimal parts in selected number. For instance, 23.3 will be 0023 instead of 0023.3.

With additional formula, ALTEXT has nearly unlimited potential ability to handel text strings or numbers.
If selected, it prompts users to select an lisp file which will be used as a formula. The filename of the lisp file and path is recorded and used as the default in next time.
When this option is selected, "Replace mode" is set to "New" and "Change to" is set to "String" automatically. "Sort selection" is still valid. All other options are disabled.
Refer to the theme "Usage of Formula" below for more details.

Inputs in "Increment", "Start from" and "End at" must be valid numbers, otherwise an alarm box will appears when you press OK button:

If input in "Increment" is a fraction and then "Use Increment precision" is selected, a similar alarm box will appears to remind "Use Increment precision" will have no effect on the result and it will de-select "Use Increment precision" automatically.

TIPS

NOTES

USAGE OF ALONG PATHS

Along Path example

"Along paths" is one of the options in "Sort selection" menu.  

Before using ALTEXT, you need define the paths. Paths include lines and plines. Valid pline can only contain line segments, without arcs, without Fit or Spline justification, without overlapped segments or nodes. Plines can be closed and/or self-intersected (like a number "8").

Paths do not necessarily need touch the texts. ALTEXT projects the texts to the paths and sorts the projection points along every path from its start point to its end point.

Because a text is projected to the nearest segment/node, sometimes the position of the path segment/node is critical as it affects the sorting result. In the following example, the top line of a closed pline is in different positions thus the text in red is projected to different segment and the final results are different.

Altext Sample 1 Figure 1

A circle of text number 1.

Altext Example 1 Figure 2

The top-left number is close to the last segment of the path which is on the left. It becomes the last in the sequence.

Altext Example 1 Figure 3

The top-left number is close to the first segment of the path which is on the top. It becomes the first in the sequence.

A Comprehensive text sorting rule about "Along paths" option is available upon request.

Options "Number", "Relative", and "Increment" are selected automatically when any option in sort selection menu is selected other than the default "As selected". 

After the settings dialogue box is closed by pressing OK button, it prompts user to select paths:

Select lines / plines as paths:

If no path selected, it prompts:

No paths selected. Entities are sorted as selected.

When a line or a valid pline is selected, ALTEXT highlights the path and shows a red arrow on the path indicating its direction and prompts with 3 options:

1 path selected, [Reverse/Next/eXit] <Next>:

Select this option to reverse the path, the red arrow is reversed as well to indicate the new direction. When reversed, the start point of a line or an open pline becomes the end point, but the start point is remained in a closed pline, only its direction is reversed.
This prompt is repeated when Reverse option is selected again until Next or eXit option is selected.

Select this option to select the next path, it repeats previous prompt:

Select lines / plines as paths:

If nothing selected or Enter is pressed at the prompt, the path selection procedure ends and the texts are modified. It equals to selecting option eXit.

This option ends the path selection procedure and shows the final result.

See Example 1 below regarding the usage of different sort selection options.
See Example 2 below regarding the usage of sort selection option - Along path.

Example 1

Usage of different sort selection options

The following illustratoins show the results from different sort selection options. Other settings are the same as below:

Text- Change to = Number
Number- Changes = Relative
Number- Imcrement = 1

4x4 array of text number 1.

Created with command ARRAY from bottom-left to top-right. 

Sort selection: As selected 

Sort selection: Reversed 

Sort selection: Left-right/Up-down 

Sort selection: Along paths 

Sort selection: Along paths, reversed. 

Example 2

Usage of sort selection option - Along paths (Please click the image to enlarge it)

A floor plan with door number blocks inserted which have the same initial number 1. 

A red pline is drawn and selected as the path used in ALTEXT "Along paths" option. ALTEXT shows the pline direction and then changes the block attributes in a sequence along the path and adds prefix "D" at the same time.   

USAGE OF FORMULA

Formula provides great flexibility in handling datas especially attribute in blocks.

Requirements of the formula lisp file:

Example 1

This example uses condition statements to change attribute value. It is impossible use condition statements in field objects, but with ALTEXT formula, it becomes practical.

The block we are going to change has two attributes. Attribute No.1 represents number of fixture units, can be any value from 0.5 to 10000, which is inside a pair of brackets; Attribute No.2 is the size of the pipe, in a sequence of ½, ¾, 1, 1¼, ...

What we need to do is automatically assign relative pipe size to Attribute No.2 base on the number of fixture units in Attribute No.1.

The relationship between Attribute No.1 and Attribute No.2 is as in the list at right side:

Example 2

This example is similar as Example 1, refer to Autodesk Discussion Group post "Simple if or condition code".

The block we are going to change has two attributes. Attribute No.1 represents types, includes 50x50, 100x100, & 150x150; Attribute No.2 is a number ranging from 0-750.

What we need to do is automatically assign relative type to Attribute No.1 base on the number of Attribute No.2.

The relationship between Attribute No.1 and Attribute No.2 is as below:

Example 3

This example shows how to set the attribute as the Z value of the block insertion point.

Example 4 

This example shows how to set the attribute as the X value of the block insertion point, in a field format.

Example 5

This example multiplies a certain factor in the second attribute to selected attributes.
Note: You can also use build-in multiply function in ALTEXT

Example 6

This example rounds up selected numbers to the next nearest round number

For instance, change number 456, 789, 2000, & 2234 to next nearest 500. The result will be 500, 1000, 2000, & 2500.

Example 7

There are 2 types of blocks in this example. Block Type A is a series of blocks to be inserted. Block Type B is a block with some attributes and the third attribute represents the block name of Block Type A. The formula zooms to every Block Type B and select line objects on left-hand side of it, then find out the center point of these line objects, then get the name of Block Type A from the third attribute, and then insert Block Type A with this name at the center point.

 Result

 Block Type A 

 Block Type B and line objects 

Example 8

This example converts decimal numbers to architectural form (feet and inch).

For instance, change number 60.52 to 5'-0 1/2. The result will be 500, 1000, 2000, & 2500.

Example 9

This example insert a block 'HOUSE' at the insertion point of select text and rotate the block to match the text orientation.

Discussion Group post: Replace text with blocks.

Example 10

This example combines values in multiple attributes into current attribute.
Discussion Group post: Script for Block with Multiple Attribute into Single Attribute Retaining Data.

Example 11

This example search the text nearby a block insert, and add its value to selected attribute, then delete the text object.
Discussion Group post:  Convert text into an attribute and import it to a block via a LISP routine.

Example 12

This example convert a number into a format with mixed letter and number, in a 24 number term.

1, 2, ... 24 become A-1, A-2, ... A-24, and 25, 26, ... 48 become B-1, B-2, ... B-24, and so on.

Discussion Group post: Looking For An Automatic Numbering Solution 

Example 13

This example is to retrieve the original number converted by formula in Example 12. It is useful when you need add or delete a text in a serial of "A-1" format texts.

A-1, A-2, ... A-24 become 1, 2, ... 24, and B-1, B-2, ... B-24 become 25, 26, ... 48 and so on.

Example 14

This example selects POINT and LINE nearby TEXT objects and change their z value to the number value of the text object.

Discussion Group post: Apply elevation text to points/lines automatic from text 

Example 15

This example adds sequenced numbers to the first attribute of selected blocks.

If current block has the same attribute values as any other block in the sequence, then keep the same number in the first attribute but add an alphabet sequence in the second attribute.

It also add leading 0 in front of numbers in the first attribute.

For example, if there are 6 blocks, 3 of them have the same attribute values, then their first + second attribute value become : 01, 02A, 03, 02B, 04 and 02C.
You can use "Left-Right/Up-Down", or "Along paths" to make a selection sequence.

Discussion Group post: Apply elevation text to points/lines automatic from text 

Example 16

This example check elected tag value first. If the value is empty, it will draw a circle at the block insertion point and pop up an alert message box to summarize the checking result.

You can replace the checking scenario with your own, or change the circle diameter.

Discussion Group post: Count and place circles at block insertion by checking attributes tag value 

Example 17

This example is simliar as Example 14. It uses the Top Elevation and pit depth value in selected block attributes and calculate the bottom of pit elevation. Then assign the pit elevation to endpoints of nearby lines.

Discussion Group post: Change line vertex Z by applying block attribute depth 

Please contact 3wood.CADKITS@gmail.com if you have any questions or need other fomula lisp files to perform other type of tasks.

NOTE

You need change settings such as Dash "-"as negative symbol before selecting "Formula".

DISCUSSION

TRIAL VERSION LIMITS

Trial Version is limited to 5 objects only. After registration, all restrictions and registration dialogue boxes dispear.

Please contact liugesen@126.com to get the free Registration Code.

UPDATES

17 July 2022 Use MS Edge to open webpage when pressing help button.
08 May 2022 Fix a bug when  searching by tag.
05  Jan 2022 Add variables of ALTEXT_SORTSEL in   in formula usage.
26 Dec 2021 Add Formula 15.
25 Dec 2021, Add variables of ALTEXT_NB in   in formula usage.
28  Sep 2021, Add variables of ALTEXT_N4  and  ALTEXT_TOTAL  in formula usage.
10 Sep 2021, Fix a bug when the numbering sequence ignored the Matching Rule.
24 Apr 2021, Fix a bug when using formula. Now it swithes to "New" "String" when a formula selected.

15 Mar 2021, Added Formula Example 11.

12 Mar 2019, Fix a bug when searching by tag name and change their value in a sequence.

                     Allow search a tag name or a pattern when type 0 at "Attribute No.:" prompt.

28 Sep 2018, Added Formula Example 7.

14 Oct 2016, Compatible with ZWCAD.

20 Feb 2016, Able to use a search pattern to filter out certain texts in the selection to apply the changes.

05 Dec 2014, Variable ALTEXT_BLK_ENT added.

10 Feb 2014, Allow edit attribute on Layer 0 even if Layer 0 is turned off, frozen, or locked.

Allow select objects before using ALTEXT

02 Aug 2013, Fixed a problem when using Along Path function

10 Jan 2013, New option - Able to use lisp file as formula

Able to format the result to match the number of leading zero in Increment when "Use Increment precision" is selected.

15 Mar 2012, Filter out MLeaders with None Content or with Block Content which doesn't has attributes from the selection.

Constant attributes are excluded from editable attributes.

21 Feb 2012, Fixed a bug in option "Along paths".

20 Feb 2012, Sort selection added 1 option - "Along paths";

"Left-Right/Up-Down" uses UCS instead of WCS;

Resolve an issue when changing multilined Mtext with numbers only.

No changes to the first number when "Relative" option is selected. 

08 Feb 2012, Sort selection added 3 options - "As selected", "Reverse selection", and "Left-Right/Up-Down"

22 Nov 2011, Resolve an issue in AutoCAD 2008 and lower version when editing MLeaders with an attribute block.

If some selected entities are on locked layers, it still shows the sum of numbers but won't make changes to them.

26 Jul 2011, Partially true-colored Mtext number such as "123456" now is recognized as one number

09 Jul 2011, Able to change attribute of block content in MLeaders; 

Resolve an issue when attribute is on a locked layer.

Now it prompts: "Some Attributes are on a locked/freez/off layer and haven't been changed."

01 Jul 2011, Allow fraction in Increment, Option "Use Increment precision" added.

10 Jun 2011,  Bugs fixed with multiply operation; Fixed a bug which removes trailing zeros in decimal part.

28 Apr 2011, Operator option added.

23 Dec 2010, Updated

01 Dec 2010, Updated

01 Oct 2010, Updated

11 Jun 2009, Updated