Search the Community
Showing results for tags 'numbers'.
-
Put mass selected integers in ascending order starting from a given integer
tsotzo posted a topic in AutoLISP, Visual LISP & DCL
Hello, Let's say we have a group of integers as text in dwg. How would we put them in in ascending order by one(+1) starting from a given integer? Let me give an example to make it clear. Let's say we have the texts 1 2 5 5 5 8 9 11 11 15 and the given start integer is 6. We select them all together and the range in selection set is random. Let's say 5 2 8 15 1 5 5 11 9 11. Now, we want to put them in ascending order by one starting from number 6 replacing the "old" range with the new. In the end we must have this: 6 7 8 8 8 9 10 11 11 12. That is 6(in place of 1), 7(in place of 2), 8(5), 8(5), 8(5), 9(, 10(9), 11(11), 11(11), 12(15). I hope it is clear. How would we do that in an efficient way? Thank you in advance, Kostas -
I regularly use text to number objects for designating cut order. In the past, I have cobbled together some code that can quickly increment or decrement all selected numerical text in case I make a mistake and/or have to change something. This works marvelously, but often, I find that I need to go beyond that and completely reverse the order. Using this code as a starting point, I thought this would be super simple but the fact that I'm trying to do list manipulation to text objects is completely throwing me off. I'm still a bit new to this sort of thing. I was thinking I'd get a list of all selected text, sort it, then reverse that list before applying changes to the text. Highest number gets swapped with the lowest, second highest with second lowest, etc. ("1" "2") would become ("2" "1") ("2" "1" "4" "5" "3") would become ("4" "5" "2" "1" "3") ("2" "8" "17" "4") would become ("17" "4" "2" "8") ("3" "5" "-4") would become ("3" "-4" "5") I'm not sure where to start, nor what process to use. My main problem is that I can't figure out how to sort and edit the data without losing links to the correct text objects. Any help would be awesome. Here is the my quick increment/decrement routine that I'm trying to start with. ;Quick Increment/decrement ;Increments/decrements all selected text integers by 1 ;I hacked this code together with help from an "increment in range" routine. ;Original code can be found here https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/incriment-numbered-text/td-p/3614646?nobounce ;Quick Increment (defun C:qi (/ textselection textobject old) (vl-load-com) (setq textselection (ssget '((0 . "TEXT")))) (repeat (sslength textselection) (setq textobject (vlax-ename->vla-object (ssname textselection 0)) old (vla-get-TextString textobject); initial text content ); setq (if (and (= (strlen old) (strlen (itoa (atoi old)))); text represents integer ; Blocks e.g. "12A", "4.5", "C37", and completely non-numerical ; text [except for next test], but allows negative integers. ; Also disallows e.g. "06", "008", so if those should be included... (if (= (strlen old) 1) (wcmatch old "#") T) ; blocks single non-numerical character e.g. "A" [passes prior test] ); and (vla-put-TextString textobject (itoa (+ (atoi old) 1))); replace ); if (ssdel (ssname textselection 0) textselection) ); repeat (princ) (setq sel1 (ssget "P")) (sssetfirst nil sel1) ); defun ;Quick decrement (defun C:qd (/ textselection textobject old) (vl-load-com) (setq textselection (ssget '((0 . "TEXT")))) (repeat (sslength textselection) (setq textobject (vlax-ename->vla-object (ssname textselection 0)) old (vla-get-TextString textobject); initial text content ); setq (if (and (= (strlen old) (strlen (itoa (atoi old)))); text represents integer ; Blocks e.g. "12A", "4.5", "C37", and completely non-numerical ; text [except for next test], but allows negative integers. ; Also disallows e.g. "06", "008", so if those should be included... (if (= (strlen old) 1) (wcmatch old "#") T) ; blocks single non-numerical character e.g. "A" [passes prior test] ); and (vla-put-TextString textobject (itoa (- (atoi old) 1))); replace ); if (ssdel (ssname textselection 0) textselection) ); repeat (princ) (setq sel1 (ssget "P")) (sssetfirst nil sel1) ); defun
-
Help with changing a single number (attribute) in multiple blocks
MattJcooper posted a topic in AutoCAD General
Hi - New to auto cad & need help I'll explain as best i can. Version:AutoCAD Mechanical 2012. I have a number of CAD blocks i need to change an attribute in each of the blocks multiple times. The attribute DEVNAME - Varies* over multiple blocks. I need to change the number used in the attributes eg: Block 1 attribute DEVNAME = RR1 Block 2 attribute DEVNAME = LR1 Block 2 attribute DEVNAME = AR1 I would like to change the 1 in all the attributes to a 2 without having to manually change each attribute name individually. The result I'm after would be: Block 1 attribute DEVNAME = RR2 Block 2 attribute DEVNAME = LR2 Block 2 attribute DEVNAME = AR2 I have hundreds to change hopefully there is an easy way. Thanks in advance any help i receive.- 1 reply
-
- multiple blocks
- help me
-
(and 2 more)
Tagged with:
-
Hey forum, I'm an apprentice out of local two five Oooohh and when I annotate anything my numbers come out backwards. Does anyone have advice to get them lookin right?
-
I have a number of drawings with levels on (single line and multitext) which are currently set to a local datum and I need to amend all to ordnance datum. To help reduce the time involved to do this I am looking for lisp routine that can find levels which are to 3 decimal places and add a set figure to it. (ie add 0.57m to every level on the drawing. Thanks for your help in advance
-
Hi, i was wondering if there was away to add the following with a lisp rountine, i do a lot of material list with this format. 5'-3" 6'-4 11/16" 4'-3" the answer would be 15'-10 11/16", i would like to be able to select them and it would add them together. i would appreciate any help.
- 7 replies
-
- numbers
- ' " adding
-
(and 1 more)
Tagged with:
-
I have a topography drawing with lots of numbers in it. Plotting in A3 paper, doesn't show the numbers. I tried to change the height of numbers globally through the style command. The present height is 0.3. I change it to 6 but nothing happens in the monitor. However when I change the oblique angle, I can see the effect on the monitor. BTW the style name is "standard" and fonta name is: txt.shx Am I doing something wrong? How can I change the height for whole numbers in one step?