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:
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.
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
1. Selected all texts you want to add up to get the sum of them.
2. You can created a series of numbers by toggle on "Relative" option and select texts in order.
3. To change texts with different content to a new number sequence, you can select them in order and change them to a same content first (eg. 00), then use ALTEXT again, select "p"(previous selection), use "Relavtive" and "Number" option and assign an "Increment".
4. You can remove certain characters in a certain position of selected texts.
For example, if you want to remove the second dash "-" in texts in a format of "(02)-12-34-5678", it is impossible with the standard FIND command in AutoCAD. But by using ALTEXT, you can insert a special character (eg. "*") at position 8 in all text strings first to change it to "(02)-12-*34-5678". Then use FIND command to replace "-*" with nothing to remove "-*" from all text strings. The final result will be "(02)-1234-5678". 5. To change precision of selected numbers to a certain decimal digits or round up to a integer, please input 0 with extra 0 as the decimal part in the "Increment" box to define how many digits you prefer. For example, to format numbers 4, 5.6, and 7.898 to 2 digits precision, you can input "0.00" in "Increment" box, then select "Use Increment precision", the result will be 4.00, 5.60, and 7.90.
6. To reverse number sequence, for instance, reverse 1, 2, 3, ... 100 to 100, 99, 98, ... 1, simply multiple them by -1, then add 101 to all of them (remember to tick "Dash as negative symbol" option). 7. To find and replace a same number, just set "Start from" and "End at" to the same value. 8. For texts not in Left-Right/Up-Down order, you can mirror them and make them in correct order before using TEXT2CSV, then mirror them back. 9. To update title blocks in different layouts, you can select these blocks with command FILTER first, then use ALTEXT to replace the value of certain attribute such as revision in one go.
NOTES
1. The original text format is remained in selected Mtext and MultiLeader objects, except for any format changes inside the target numbers.
Example: Add Prefix A, Suffix s, Increment -8.3 to Mtext PPLE3.64b will get APPLE-4.66bs Example: Add 2.34567 to texts E3.65, F4.3756893a, M3s will get E5.00, F6.7213593a, M5s
3. The leading 0 in the positive integer part will be remained to keep the same number digits.
Example: Add 1 to text eX001, eX002, eX009, eX09, will get eX002, eX003, eX010, eX10
4. Zero will be added to end of the decimal part to keep the original decimal digits, unless "Use Increment precision" is selected.
Example: Add 1.12 to text D6.000 will get D7.120
5. The maximum decimal precision is 10 digits after the decimal point, redundant digits will be changed to 0.
Example: Add 1.1 to text Ps0.345678901234567ud wil get Ps1.445678901200000ud.
6. Stacked text in Mtext is recognized as a character, not a figure. All figures in stacked text are not going to be changed.
7. It doesn't support table objects.
8. If the number in the text string is changed and new string is inserted to it in the same operation, the new string will be inserted to the changed figures, not the original figures. Example: Add 1000 to number 234 in text AB234CD and also insert dash "-" to position "0, 2" counting from left will get result AB-12-34CD 9. Nothing changes if Increment = 0, no matter "+ Plus" or "x Multiply" is selected, unless "Use Increment precision" is selected.
10. Numbers in locked entities are valid to be added up, but cannot be modified. It prompts "Some Texts/Attributes are on a locked/freez/off layer and haven't been changed." if there are entities on a locked/turned-off layer.
11. MLeaders with "None" as Content or with "Block" as Content but without any editable attributes are not valid for modification.
12. There is a known bug in AutoCAD, when trying to change the layer status of an annotative attribute in MLeader block, AutoCAD crushes.
So please avoid using such MLeader styles in your drawing. When AutoCAD crushes in this case, it has nothing to do with ALTEXT. 13. The sum of numbers doesn't affected by "Only apply to" setting. 14. "Sort selection" and "Relative" are disabled when using a search pattern for attribute tags.
USAGE OF ALONG PATHS
"Along paths" is one of 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. 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>: - Reverse 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. - Next 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. - 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
Example 2
Usage of sort selection option - Along paths (Please click the image to enlarge it)
USAGE OF FORMULA Formula provides great flexibility in handling datas especially attribute in blocks. Requirements of the formula lisp file: - The main function name defined in the lisp file must be "ALTEXT_FORMULA"; For example, (defun ALTEXT_FORMULA () .....) - There are some predefined variables which you can use in the lisp file as below: "ALTEXT_STR_ORG" presents the original text string in selected texts/attribute; "ALTEXT_ATT_n" presents the value of the block attributes, n indicates the sequence number of attribute in the block definition. "ALTEXT_BLK_ENT" presents the definition data of selected block itself, same format as the result by using entget. For example, ALTEXT_ATT_1 means the first attribute in the block, ALTEXT_ATT_2 means the second,... etc. - If the formula lisp returns nil, then no change is made to the original text string. - When ALTEXT prompts "Which attribute to be changed: Attribute No.<1>:", enter the order number of the attribute you need to change. 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 below:
The formula lisp file is as below: ;;; This is an example formula for ALTEXT.vlx (defun ALTEXT_FORMULA (/ nb1 cd_pair) (if Altext_att_1 (progn (setq nb1 (atof (vl-string-right-trim ")" (vl-string-left-trim "(" Altext_att_1)))) (cond ((<= nb1 1) "\U+00BD") ((<= nb1 7) "\U+00BE") ((<= nb1 17) "1") ((<= nb1 36) "1\U+00BC") (T nil) ) ) ) ) Save the content above as a lisp file, and select it as the formula used in ALTEXT. 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:
The formula lisp file is as below: ;;; This is an example formula for ALTEXT.vlx (defun ALTEXT_FORMULA (/ nb1) (if Altext_att_2 (progn (setq nb1 (atof Altext_att_2)) (cond ((<= nb1 200) "50x50") ((<= nb1 500) "100x100") ((<= nb1 750) "150x150") (T nil) ) ) ) ) Save the content above as a lisp file, and select it as the formula used in ALTEXT. Example 3 This example shows how to set the attribute as the Z value of the block insertion point. ;;; This is an example formula for ALTEXT.vlx (defun ALTEXT_FORMULA () (if ALTEXT_BLK_ENT (rtos (cadddr (assoc 10 ALTEXT_BLK_ENT)) 2 3) ;Refer to rtos usage to change unit mode & precision. ) ) Example 4 This example shows how to set the attribute as the X value of the block insertion point, in a field format. ;;; Add X coordinate of block insertion point to attribute as a field. (defun ALTEXT_FORMULA () (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-objectid (vlax-ename->vla-object (cdr (assoc -1 ALTEXT_BLK_ENT))))) ">%).InsertionPoint \\f \"%lu2%pt1%pr2\">%" "") ) Example 5 This example multiplies a certain factor to an attribute. ;;; It multiplies "factor" to selected attribute. ;;; It uses current system units and precision for the result. ;;; Change factor, units, and precision to suit your usage. ;;; Change Altext_att_2 to Altext_att_n if the attribute to be updated is No. n attribute in the block. (defun ALTEXT_FORMULA (/ C_lunits C_luprec factor) (setq factor 1.5) (setq C_lunits (getvar "lunits")) (setq C_luprec (getvar "luprec")) (rtos (* (atof Altext_att_2) factor) C_lunits C_luprec) ) Example 6 This example rounds up selected numbers to next nearest round number For instance, change number 456, 789, 2000, & 2234 to next nearest 500. The result will be 500, 1000, 2000, & 2500. ;;; This is an example formula for ALTEXT.vlx ;;; Round up selected numbers to nearest markers. ;;; Change value of RoundUp to suit (defun ALTEXT_FORMULA (/ RoundUp f1 f2) (setq RoundUp 500 f1 (/ (atof ALTEXT_STR_ORG) RoundUp) f2 (fix f1) ) (itoa (if (= f1 f2) (* f2 RoundUp) (* (1+ f2) RoundUp) ) ) ) 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. ;;; This is an example formula for ALTEXT.vlx ;;; Zoom to the attribute block, select lines on its left, find out their centre point. ;;; Get the content of the third attribute as a block name, and insert this block at centre point. (defun ALTEXT_FORMULA (/ fc1 i1 ins Lx Ly MinPoint MaxPoint old-osnaps1 sc1 vc1 vh2 vs1 vw2 vx1 vy1 vobj) (setq old-osnap (getvar "OSMODE")) (setvar "OSMODE" 0) (setq vobj (vlax-ename->vla-object (cdar ALTEXT_BLK_ENT))) (vla-getboundingbox vobj 'MinPoint 'MaxPoint) (setq MinPoint (trans (vlax-safearray->list MinPoint) 0 1) MaxPoint (trans (vlax-safearray->list MaxPoint) 0 1) ) (vl-cmdf "._zoom" MinPoint MaxPoint) (setq vc1 (getvar "viewctr") vx1 (car vc1) vy1 (cadr vc1) vs1 (getvar "viewsize") sc1 (getvar "screensize") fc1 (/ (car sc1)(cadr sc1)) vh2 (/ vs1 2.0) vw2 (* vh2 fc1) ) (setq s1 (ssget "W" (list (- vx1 vw2) (- vy1 vh2)) (list vx1 (+ vy1 vh2)) '((0 . "LINE")(8 . "S-_COLN----_E")))) (if s1 (progn (repeat (setq i1 (sslength s1)) (setq i1 (1- i1)) (setq Lx (cons (cadr (assoc 11 (entget (ssname s1 i1)))) (cons (cadr (assoc 10 (entget (ssname s1 i1)))) Lx) ) ) (setq Ly (cons (caddr (assoc 11 (entget (ssname s1 i1)))) (cons (caddr (assoc 10 (entget (ssname s1 i1)))) Ly) ) ) ) (setq Lx (vl-sort Lx '<)) (setq Ly (vl-sort Ly '<)) (setq ins (list (/ (+ (car Lx) (last Lx)) 2.0) (/ (+ (car Ly) (last Ly)) 2.0))) (vl-cmdf "._insert" ALTEXT_ATT_3 ins 1.0 1.0 0.0) (setvar "OSMODE" old-osnap) ) ) nil ) 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. ;;; This is an example formula for ALTEXT.vlx ;;; Round up selected numbers to nearest markers. ;;; Change value of RoundUp to suit (defun ALTEXT_FORMULA (/ RoundUp f1 f2) (setq RoundUp 500 f1 (/ (atof ALTEXT_STR_ORG) RoundUp) f2 (fix f1) ) (itoa (if (= f1 f2) (* f2 RoundUp) (* (1+ f2) RoundUp) ) ) ) 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". DISCUSSIONS
TRIAL VERSION LIMITS
Trial Version is limited to 5 objects only. After registration, all restrictions and registration dialogue boxes dispear.
Please contact 3wood.CADKITS@gmail.com to get the FREE Registration Code.
UPDATES
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
|
HOME >