Author Topic: Nentsel multiple  (Read 2137 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Swamp Rat
  • Posts: 812
Nentsel multiple
« on: November 01, 2016, 08:30:05 AM »
Window selection, like (ssget "_:L"), but also select the subentities "_:N" ... Is there such a thing?
The closest I got is to select everything nested which is within aperture:
Code: [Select]
(defun C:test ( / LM:flatten SS Str )

(defun LM:flatten ( l ); Flatten List  -  Lee Mac ; Transforms a nested list into a non-nested list
(if (atom l) (list l) (append (LM:flatten (car l)) (if (cdr l) (LM:flatten (cdr l)))))
)

(if
(and
(princ "\nSelect any \"TEXT\" objects, to change their content: ")
(setq SS (ssget "_:E:N"))
)
(progn
(setq Str "str")
(mapcar
(function (lambda (x) (princ "\n") (print (cdr (assoc 0 (entget x))))))
(vl-remove-if-not (function (lambda (x) (= 'ENAME (type x)))) (LM:flatten (ssnamex SS)))
)
(mapcar
(function (lambda (o) (if (vlax-property-available-p o 'TextString) (vl-catch-all-apply 'vla-put-TextString (list o str)))))
(mapcar 'vlax-ename->vla-object (vl-remove-if-not (function (lambda (x) (= 'ENAME (type x)))) (LM:flatten (ssnamex SS))))
)
)
); if
(princ)
);| defun |; (or vlax-get-acad-object (vl-load-com)) (princ)
Obviously I'm trying to select TEXT/MTEXT/ATTRIB objects (any: nested or not) to change their content.
But curiosity brought me here, to ask if its possible to implement window selection behaviour.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

Lee Mac

  • Seagull
  • Posts: 12923
  • London, England
Re: Nentsel multiple
« Reply #1 on: November 01, 2016, 09:12:55 AM »
Not natively, but I believe Tim pursued this to great depth - I'll see if I can find the thread.

EDIT: Found it: https://www.theswamp.org/index.php?topic=27786

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Nentsel multiple
« Reply #2 on: November 01, 2016, 09:24:53 AM »
Just a small update on my tests:
Code: [Select]
(setq SS (ssget "_:N" (list (cons 0 "INSERT,ATTRIB,TEXT,MTEXT"))))This seems to work, however when selecting the whole block ref (in my case its contained of lines and attribute entities) it does not change the subentities,
 but it works if I only "window select" the attributes, without any nested lines within the same block reference. Overall theres no problem with combination of non-nested entities.
Thanks Lee, I'll check Tim's thread right now.

EDIT: Okay I wrote something, using Tim's ssgetNested subr:
Code: [Select]
(defun C:test ( / LM:flatten *error* acDoc uFlg e o str Lst )

(defun LM:flatten ( l ); Flatten List  -  Lee Mac ; Transforms a nested list into a non-nested list
(if (atom l) (list l) (append (LM:flatten (car l)) (if (cdr l) (LM:flatten (cdr l)))))
)
(defun *error* ( msg )
(and uFlg (vla-EndUndoMark acDoc))
(princ)
)
(setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))

(setvar 'errno 0)
(while (/= 52 (getvar 'errno))
(setq e (car (nentsel "\nSelect source text/mtext/attrib:" )))
(cond
( (and e (setq o (vlax-ename->vla-object e)) (vlax-property-available-p o 'TextString) (setq str (vla-get-TextString o))) (setvar 'errno 52) )
( T nil )
)
)
(if (and str (princ "\nSelect any nested texts to populate: ") (setq Lst (ssgetNested 0)))
(progn
(vla-EndUndoMark acDoc)
(setq uFlg (not (vla-StartUndoMark acDoc)))
(mapcar
(function (lambda (x) (and (vlax-property-available-p x 'TextString) (vl-catch-all-apply 'vla-put-TextString (list x str)))))
(mapcar 'vlax-ename->vla-object (vl-remove-if-not (function (lambda (x) (= 'ENAME (type x)))) (LM:flatten Lst)))
)
(and uFlg (setq uFlg (vla-EndUndoMark acDoc)))
(vla-Regen acDoc acActiveViewport)
)
)

(princ)
);| defun |; (or vlax-get-acad-object (vl-load-com)) (princ)
It would be nice if he included atleast the SS Window's coords in that list, so one could recreate SS that will proceed the non-nested objects.  :roll:
« Last Edit: November 01, 2016, 02:50:25 PM by Grrr1337 »
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg