+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    May 2012
    Posts
    24

    Default selection sets- separate

    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!

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,089

    Default

    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.

  3. #3
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,932

    Default

    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

  4. #4
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    May 2012
    Posts
    24

    Default

    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)))

  5. #5
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,089

    Default

    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)))

  6. #6
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    2,986

    Default

    @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

  7. #7
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    May 2012
    Posts
    24

  8. #8
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    May 2012
    Posts
    24

    Default

    Nice, Pbe!

  9. #9
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,089

    Default

    Quote Originally Posted by brams View Post
    Nice, Pbe!
    You are welcome,

    IMO, intead of separating the slection into two, might as well process the entities inside the while/repeat loop.

    What is the code all about anyway? can you share it with us, maybe there's a more efficient way of accomplishing your goal.

  10. #10
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    May 2012
    Posts
    24

    Default

    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

Similar Threads

  1. Selection sets in vb.net
    By Jozi68 in forum .NET, ObjectARX & VBA
    Replies: 8
    Last Post: 14th Feb 2012, 07:33 pm
  2. VBA - Selection Sets
    By -KarL- in forum AutoLISP, Visual LISP & DCL
    Replies: 17
    Last Post: 3rd Mar 2009, 10:54 am
  3. VBA - Using IF and selection sets
    By wannabe in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 23rd Oct 2008, 02:09 pm
  4. Little help on selection sets please
    By Galingula in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 17th Apr 2006, 03:39 pm
  5. selection sets..........
    By rajanikrishna in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 14th Nov 2005, 11:32 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts