AFAIK, you're second option is the only way you can do such a task. at any rate. it would be better to process the objects while inside the repeat loop using IF/COND to eliminate the need to create another selection set.
Registered forum members do not see this ad.
I use 2 methods:
1. (setq ss1 (ssget '((0 . "point")))) and (setq ss2 (ssget '((0 . "TEXT")))) to create 2 separate selection sets
2. (setq ss1 (ssget '((0 . "point,text")))) , and then i use repeat... to make 2 lists, 1 for texts and one for points.
Is it possible to make 2 selection sets only by using 1 time ssget function?
My question seems stupid...sorry...
Thanks!
AFAIK, you're second option is the only way you can do such a task. at any rate. it would be better to process the objects while inside the repeat loop using IF/COND to eliminate the need to create another selection set.
Code:(defun _GetSelPoints (/ *error*) (defun *error* (msg) (and oldNomutt (setvar 'nomutt oldNomutt)) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) ((princ (strcat "\n** Error: " msg " ** ")))) ; Fatal error, display it (if result result (princ))) ((lambda (oldNomutt / startPoint endPoint result) (if (and (not (prompt "\nSelect objects: ")) (setvar 'nomutt 1) (not (initget 1024)) (setq startPoint (getpoint)) (not (initget 1056)) (setq endPoint (getcorner startPoint))) (progn (setq result (list startPoint endPoint)) (*error* nil)) (*error* "Nothing selected"))) (getvar 'nomutt)))
Linky: http://www.theswamp.org/index.php?to...9927#msg469927
Last edited by BlackBox; 8th Jun 2012 at 11:57 am.
"Potential has a shelf life." - Margaret Atwood
A little help, please... for a new autolisp user
Seems to be what i'm searching for. Please, an example how to use your function together with ssget... to make 2 selection sets of points and texts, selecting objects only one time - i mean, a single "rectangle".
Code:<li style="">(defun _GetSelPoints (/ *error*) <li style=""> <li style=""> (defun *error* (msg) <li style=""> (and oldNomutt (setvar 'nomutt oldNomutt)) <li style=""> (cond ((not msg)) ; Normal exit <li style=""> ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) <li style=""> ((princ (strcat "\n** Error: " msg " ** ")))) ; Fatal error, display it <li style=""> (if result result (princ))) <li style=""> <li style=""> ((lambda (oldNomutt / startPoint endPoint result) <li style=""> (if (and (not (prompt "\nSelect objects: ")) <li style=""> (setvar 'nomutt 1) <li style=""> (not (initget 1024)) <li style=""> (setq startPoint (getpoint)) <li style=""> (not (initget 1056)) <li style=""> (setq endPoint (getcorner startPoint))) <li style=""> (progn (setq result (list startPoint endPoint)) (*error* nil)) <li style=""> (*error* "Nothing selected"))) <li style=""> (getvar 'nomutt)))
FWIW
Code:(defun c:sepsel () (setq textsel (ssadd) PointSel (ssadd) ss (ssget '((0 . "POINT,TEXT")))) (while (setq e (ssname ss 0)) (if (eq (cdr (assoc 0 (entget e))) "POINT") (ssadd e PointSel)(ssadd e textsel)) (ssdel e ss)))
@brams: What editor are you using? Seems that you pasted some control tags along AutoLISP code.
Or did you tried to number the lines?!?
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
I copied from here http://www.theswamp.org/index.php?to...9927#msg469927
Nice, Pbe!![]()
Registered forum members do not see this ad.
I can share my "masterpiece" , no problem...
This code have to move points and texts at the correct elevation. I select points and texts - texts that have the same x and y with point ... should be pairs .If the text is 209.324, then i will move the point at this elevation, and also i will move the point - that has the same x value and y value-at this elevation. Is about land surveyor "masterpiece" - wrong elevation for points. My code seems to work ok if i select points and texts that are pairs (same x and y), but when i select texts and points that are not pairs, some errors...i don't know why - please help if possible. Sorry for the code, looks bad - still in work....
Code:(defun c:pz (/ ldata layer punct) (princ "\nSELECTEAZA PUNCTELE SI TEXTELE") (setq ss (ssget '((0 . "POINT,TEXT")))) (setq i 0) (repeat (sslength ss) (setq ename (ssname ss i)) (setq data (entget ename)) (setq entName (cdr (assoc -1 data))) (setq Nume (cdr (assoc 0 data))) (setq ldata (cons data ldata)) (setq i (1+ i)) ) ;_ end of repeat (setq ltest ldata) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq i 0) (setq listat nil) (repeat (length ldata) (setq entName (cdr (assoc -1 (nth i ldata)))) (setq Nume (cdr (assoc 0 (nth i ldata)))) (if (= Nume "TEXT") (progn (setq pct (cdr (assoc 10 (nth i ldata)))) (setq z (atof (cdr (assoc 1 (nth i ldata))))) (setq ztext (caddr pct)) (setq listat (cons (list pct z ztext entName) listat)) ) ;_ end of progn ) ;_ end of if (setq i (1+ i)) ) ;_ end of repeat ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq i 0) (setq listap nil) (repeat (length ldata) (setq entName (cdr (assoc -1 (nth i ldata)))) (setq Nume (cdr (assoc 0 (nth i ldata)))) (if (= Nume "POINT") (progn (setq punct (cdr (assoc 10 (nth i ldata)))) (setq layer (cdr (assoc 8 (nth i ldata)))) (setq culoare (cdr (assoc 62 (nth i ldata)))) (setq listap (cons (list punct layer culoare entName) listap)) ) ;_ end of progn ) ;_ end of if (setq i (1+ i)) ) ;_ end of repeat ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq listam nil) (setq listaep nil) (setq listaet nil) (setq i 0) (repeat (length listap) (setq text (nth i listat)) (foreach punct listap (if (and (= (car (car text)) (car (car punct))) (= (cadr (car text)) (cadr (car punct))) ) ;_ end of and (setq p (list (list (car (car punct)) (cadr (car punct)) (cadr text) ) ;_ end of list (setq la (cadr punct)) (setq cul (caddr punct)) (setq entitatep (cadddr punct)) (setq entitatet (cadddr text)) (setq pt (car text)) ) ;_ end of list ) ;_ end of setq ) ;_ end of if ) ;_ end of foreach (setq listam (cons p listam)) (setq listaep (cons entitatep listaep)) (setq listaet (cons entitatet listaet)) (setq i (1+ i)) ) ;_ end of repeat ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq i 0) (repeat (length listam) (entmake (list (cons 0 "POINT") (cons 8 (cadr (nth i listam))) (if (/= (caddr (nth i listam)) nil) (cons 62 (caddr (nth i listam))) (cons 62 256) ) ;_ end of if (cons 10 (car (nth i listam))) ) ;_ end of list ) ;_ end of entmake ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (command "_.move" (cadddr (cdr (nth i listam))) "" (setq pti (cadddr (cdr (cdr (nth i listam))))) (setq ptf (car (nth i listam))) (list (car (car (nth i listat))) (cadr (car (nth i listat))) (cadr (nth i listat)) ) ;_ end of list ) ;_ end of command (setq i (1+ i)) ) ;_ end of repeat ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq sse (ssadd)) (foreach ent listaep (ssadd ent sse)) (command "erase" sse "") (princ) ) ;_ end of defun
Bookmarks