Message 1 of 12
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is there a lisp for this simple task?
Solved! Go to Solution.
Is there a lisp for this simple task?
Solved! Go to Solution.
See attachment video
Try this.
When you COPY, you are prompted to PASTE, but you don't have to select anything.
When you PASTE but haven't COPIED beforehand, you're prompted to COPY. Have fun!
(vl-load-com) (defun c:TXCopy ( / s) (princ "\nSelect texts COPY, ") (if (setq s (ssget '((0 . "*TEXT")))) (setq *tx-values* (mapcar '(lambda (x) (cdr (assoc 1 (entget x)))) (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))))) (c:TXPaste) (princ) ) (defun c:TXPaste ( / from s) (if (and (not from) (setq from T) (or *tx-values* (c:TXCopy)) (princ "\nSelect texts to PASTE, ") (setq s (ssget '((0 . "*TEXT")))) ) (mapcar '(lambda (e v) (entmod (subst (cons 1 v) (assoc 1 (entget e)) (entget e)))) (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) *tx-values*)) (princ) )
Works perfectly if I make one by one click selection, area selection is unreliable, at least out of four selections it flips 2nd and 3th during paste. But I would normally assume that its not fixable, since many tools seems to be unreliable in selection order during area selection. Yet with you in question it is safe to not assume anything.
Question: Is it possible to replace "Select objects: to "Select texts to copy" and "Select texts to PASTE" in drafting tool tip or whatever it is called, the text near cursor.
'since many tools seems to be unreliable in selection order"
The answer may be in the selection being in created order not visual order. If you pick pick pick should work, when picking by window can use sort on X Y sometimes helps.
It's "unreliable" because you don't know how it works. It's not obvious.
All window/cross/polygon type of selections creates a selection in the reversed order of object creation (within each window if multiple). From the newest to the oldest.
One-by-one selection or Fence respects the order/direction of selection.
Now, knowing that, again, it's your time to elaborate on what would you consider "reliable" enough for your task. Say, it could be automatically resorted by X coordinate...
Green is possible, red isn't changeable.
Sorting by X-value during are selection would be good. But would that mean that click by click selection would also have to be sorted by x or could it be by click order, like it is now?
In that case it would work even better than current versio. Yet I just got to use the current versio in real action and it is very fast and good as long I dont use area selection. With area selection sorted by x it would be even faster
Ok, here it is.
The first step of selection is decisive.
IF the first step of selection is an area type of selection, then all steps would be sorted together. Say, you've missed one or two texts by the initial window, so you just add them with a single click. All texts are sorted together then.
IF the first step is a single type selection or fence, each group is sorted separately. Say you do: pick, pick, window, pick, window. Then the result is: pick, pick, sorted-window-within-itself, pick, sorted-window-within-itself.
Hopefully, it's intuitive enough. In any case, added a visual control.
(vl-load-com) ;---- (defun c:TXCopy ( / *error* s) (defun *error* (msg) (if (not (wcmatch msg "Function cancelled,quit / exit abort,console break,end")) (princ (strcat "\nError: " msg))) (setvar 'nomutt 0) (princ)) (if (and (setvar 'nomutt 1) (princ "\nSelect texts to COPY: ") (setq s (ssget '((0 . "*TEXT")))) ) (setq *tx-values* (mapcar '(lambda (x) (cdr (assoc 1 (entget x)))) (:ListOfEnamesFromSSbyX s)))) (c:TXPaste) (setvar 'nomutt 0) (princ) ) ;----- (defun c:TXPaste ( / *error* from s) (defun *error* (msg) (if (not (wcmatch msg "Function cancelled,quit / exit abort,console break,end")) (princ (strcat "\nError: " msg))) (setvar 'nomutt 0) (princ)) (if (and (not from) (setq from T) (or *tx-values* (c:TXCopy)) (princ (strcat "Content: " (substr (apply 'strcat (mapcar '(lambda (x) (strcat "/" x)) *tx-values*)) 2))) (setvar 'nomutt 1) (princ "\nSelect texts to PASTE: ") (setq s (ssget '((0 . "*TEXT")))) ) (mapcar '(lambda (e v) (entmod (subst (cons 1 v) (assoc 1 (entget e)) (entget e)))) (:ListOfEnamesFromSSbyX s) *tx-values*)) (setvar 'nomutt 0) (princ) ) ;----- (defun :ListOfEnamesFromSSbyX (s / lst d) (if (vl-position (caar (setq lst (ssnamex s))) '(2 3)) ; IF first is window/cross/polygon (vl-sort (vl-remove-if 'listp (mapcar 'cadr lst)) ; THEN sort all together '(lambda (e f) (< (car (trans (cdr (assoc 10 (entget e))) 0 1)) (car (trans (cdr (assoc 10 (entget f))) 0 1))))) (apply 'append ; ELSE sort each selection step separatelly (vl-remove 'nil (mapcar '(lambda (x) (cond ((vl-position (car x) '(0 1 4)) (list (cadr x))) ((and (vl-position (car x) '(2 3)) (not (vl-position (cons (car x) (last x)) d)) (setq d (cons (cons (car x) (last x)) d))) (vl-sort (mapcar 'cadr (vl-remove-if-not '(lambda (y) (and (= (car x) (car y)) (= (last x) (last y)))) lst)) '(lambda (e f) (< (car (trans (cdr (assoc 10 (entget e))) 0 1)) (car (trans (cdr (assoc 10 (entget f))) 0 1)))))))) lst)))))