Search the Community
Showing results for tags 'reverse'.
-
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
-
Hello all I am developing a parametric model of a precast stair using Inventor 2013. I have set a parameter call "rake" to define the rake distance of the stair (the distance the nosing of each tread protrudes over the tread below - usually about 25 mm) This is initially set to 25 mm in the sketch. If there is no rake, I set this to 0 mm, and this gives a perfectly horizontal & vertical stair profile. If I then set this back to 25 mm, Inventor flips (reverses) the direction and the profile produced is incorrect (it is like a negative rake angle). I guess it is because when I set the rake to 0, the two points are directly in line vertically, and when I set it to 25 mm again it pushes them 25 mm apart horizontally, but in the wrong direction. Is there any way to constrain these parameters or points such the distance is measured only in the desired direction, or to stop one point from going beyond the vertical position of another point. Any help on this matter would be very much appreciated. Many thanks in advance.
- 1 reply
-
- parameters
- inventor
-
(and 2 more)
Tagged with: