lisp selection set problem

lisp selection set problem

107199
Enthusiast Enthusiast
969 Views
4 Replies
Message 1 of 5

lisp selection set problem

107199
Enthusiast
Enthusiast

what's the problem with this selection set:

 

(PROMPT "\n THIS PROGRAM FOR SPRINKLER DISTRIBUTION ")
(PROMPT "\n START COMMAND by :  SSP:PENDENT  SSU:UPRIGHT ")
(DEFUN C:SSP ()
(SETVAR "CMDECHO" 0)
(initget "Select"); allows S as input to (getpoint) function, instead of point pick
(SETQ P1 (GETPOINT "\n ENTER FIRST POINT or [Select]: "))
(if (= P1 "Select"); chose that option
  ((setq ssold (ssget "_X"))
(setq ssar (ssget))
(setq k -1)
(repeat (sslength ssar)
(setq k (+ k 1))
(setq ssrem (ssdel (ssname ssar k) ssold))
)
(setq ; then
    rect (car ssar)
    P1 (vlax-curve-getPointAtParam rect 0); starting vertex
    P3 (vlax-curve-getPointAtParam rect 2); third vertex [opposite corner]
  )); setq
  (SETQ P3 (GETPOINT "\n ENTER SECOND POINT: ")); else [picked a point]
); if
(setq BB1 "M-FFSP-PE02-P")
   (setq x1 (car p1))
   (setq y1 (car (cdr p1)))
   (setq x3 (car p3))
   (setq y3 (car (cdr p3)))
   (setq p2 (list x1 y3))
   (setq p4 (list x3 y1))
   (setq disx (distance p1 p4))
   (setq disy (distance p1 p2))
   (setq disxx (abs (- x3 x1)))
   (setq disyy (abs (- y3 y1)))
(SETQ NX (+ (fix (/ disxx 4600)) 1))
(SETQ XXN (/ disx (* NX 2)))
(SETQ DS1 (* XXN 2))
(SETQ NY (+ (fix (/ disyy 4600)) 1))
(SETQ YYN (/ disy (* NY 2)))
(SETQ DS2 (* YYN 2))
   (setq xx1 (+ (car p1) XXN))
   (setq yy1 (+ (car (cdr p1)) YYN))
   (setq pp2 (list xx1 yy1))
(COMMAND "-layer" "m" "M-FIRE-SYMB-P" "c" "2" "" "")
(COMMAND "INSERT" BB1 pp2 "" "" "")
;(COMMAND "ARRAY" "L" "" "R" NY NX DS2 DS1)
    (if (eq NX 1) (COMMAND "ARRAY" "L" "" "R" NY NX DS2))
    (if (eq NY 1) (COMMAND "ARRAY" "L" "" "R" NY NX DS1))
    (if (AND (/= NX 1) (/= NY 1))(COMMAND "ARRAY" "L" "" "R" NY NX DS2 DS1))
(setq ssall (ssget "_X"))
(if (= (sslength ssrem) 0) (setq sss ssall)
(progn
(setq k -1)
(repeat (sslength ssrem)
(setq k (+ k 1))
(setq sss (ssdel (ssname ssrem k) ssall))
)
))
(sssetfirst sss sss)
(PRIN1)
(PRIN1)
(PROMPT "\n")
(PROMPT "\n CREATED by :")
(PROMPT "\n                  ********* M.SAIED. ********* ")
(PROMPT "\n MODIFIED by :")
(PROMPT "\n                  ********* Saber Elkassas. ********* ")
(PRINC)
);DEFUN
0 Likes
970 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

@107199 wrote:

what's the problem with this selection set:

 

....
(initget "Select"); allows S as input to (getpoint) function, instead of point pick
(SETQ P1 (GETPOINT "\n ENTER FIRST POINT or [Select]: "))
(if (= P1 "Select"); chose that option
  ((setq ssold (ssget "_X")); everything in the drawing?
;; Missing (progn) function name to group following into one 'then' argument?
;; or possibly missing (and) function name?
(setq ssar (ssget)); User selection of any kind(s) of thing(s)? (setq k -1) (repeat (sslength ssar); remove everything in ssar from ssold? (setq k (+ k 1)) (setq ssrem (ssdel (ssname ssar k) ssold))
); repeat
;; Missing closing ) for red one above?
(setq ; then rect (car ssar); ssar is a selection set - (car) wants a list P1 (vlax-curve-getPointAtParam rect 0); starting vertex P3 (vlax-curve-getPointAtParam rect 2); third vertex [opposite corner] )); setq and progn? (SETQ P3 (GETPOINT "\n ENTER SECOND POINT: ")); else [picked a point] ); if ....

I don't think I understand what you're trying to do.  See comments above.  It looks like you're grabbing everything in the drawing, asking the User to make a selection [without limiting it even to Polylines, much less to rectangles], and then removing all the things they selected from the everything-in-the-drawing set.  No further use is made of 'ssold', so what's it for?  Similarly with the 'ssall' variable later.

 

If you can describe what you want the User to do, maybe we can figure out what to suggest.  Are you trying to do multiple rectangular areas as on your other thread?

Kent Cooper, AIA
0 Likes
Message 3 of 5

107199
Enthusiast
Enthusiast

this lisp is used to select one rect. i am trying to convert it to make multi. selection and process the lisp onetime

 

(PROMPT "\n THIS PROGRAM FOR SPRINKLER DISTRIBUTION ")
(PROMPT "\n START COMMAND by :  SSP:PENDENT  SSU:UPRIGHT ")
(DEFUN C:SSP ()
(SETVAR "CMDECHO" 0)
(initget "Select"); allows S as input to (getpoint) function, instead of point pick
(SETQ P1 (GETPOINT "\n ENTER FIRST POINT or [Select]: "))
(if (= P1 "Select"); chose that option
  (setq ; then
    rect (car (entsel "\nSelect rectangle: "))
    P1 (vlax-curve-getPointAtParam rect 0); starting vertex
    P3 (vlax-curve-getPointAtParam rect 2); third vertex [opposite corner]
  ); setq
  (SETQ P3 (GETPOINT "\n ENTER SECOND POINT: ")); else [picked a point]
); if
(setq BB1 "M-FFSP-PE02-P")
   (setq x1 (car p1))
   (setq y1 (car (cdr p1)))
   (setq x3 (car p3))
   (setq y3 (car (cdr p3)))
   (setq p2 (list x1 y3))
   (setq p4 (list x3 y1))
   (setq disx (distance p1 p4))
   (setq disy (distance p1 p2))
   (setq disxx (abs (- x3 x1)))
   (setq disyy (abs (- y3 y1)))
(SETQ NX (+ (fix (/ disxx 4600)) 1))
(SETQ XXN (/ disx (* NX 2)))
(SETQ DS1 (* XXN 2))
(SETQ NY (+ (fix (/ disyy 4600)) 1))
(SETQ YYN (/ disy (* NY 2)))
(SETQ DS2 (* YYN 2))
   (setq xx1 (+ (car p1) XXN))
   (setq yy1 (+ (car (cdr p1)) YYN))
   (setq pp2 (list xx1 yy1))
(COMMAND "-layer" "m" "M-FIRE-SYMB-P" "c" "2" "" "")
(COMMAND "INSERT" BB1 pp2 "" "" "")
;(COMMAND "ARRAY" "L" "" "R" NY NX DS2 DS1)
    (if (eq NX 1) (COMMAND "ARRAY" "L" "" "R" NY NX DS2))
    (if (eq NY 1) (COMMAND "ARRAY" "L" "" "R" NY NX DS1))
    (if (AND (/= NX 1) (/= NY 1))(COMMAND "ARRAY" "L" "" "R" NY NX DS2 DS1))
(PRIN1)
(PRIN1)
(PROMPT "\n")
(PROMPT "\n CREATED by :")
(PROMPT "\n                  ********* M.SAIED. ********* ")
(PROMPT "\n MODIFIED by :")
(PROMPT "\n                  ********* Saber Elkassas. ********* ")
(PRINC)
);DEFUN

(DEFUN C:SSU ()
(SETVAR "CMDECHO" 0)
(initget "Select"); allows S as input to (getpoint) function, instead of point pick
(SETQ P1 (GETPOINT "\n ENTER FIRST POINT or [Select]: "))
(if (= P1 "Select"); chose that option
  (setq ; then
    rect (car (entsel "\nSelect rectangle: "))
    P1 (vlax-curve-getPointAtParam rect 0); starting vertex
    P3 (vlax-curve-getPointAtParam rect 2); third vertex [opposite corner]
  ); setq
  (SETQ P3 (GETPOINT "\n ENTER SECOND POINT: ")); else [picked a point]
); if
(setq BB1 "M-FFSP-UP01-P")
   (setq x1 (car p1))
   (setq y1 (car (cdr p1)))
   (setq x3 (car p3))
   (setq y3 (car (cdr p3)))
   (setq p2 (list x1 y3))
   (setq p4 (list x3 y1))
   (setq disx (distance p1 p4))
   (setq disy (distance p1 p2))
   (setq disxx (abs (- x3 x1)))
   (setq disyy (abs (- y3 y1)))
(SETQ NX (+ (fix (/ disxx 4600)) 1))
(SETQ XXN (/ disx (* NX 2)))
(SETQ DS1 (* XXN 2))
(SETQ NY (+ (fix (/ disyy 4600)) 1))
(SETQ YYN (/ disy (* NY 2)))
(SETQ DS2 (* YYN 2))
   (setq xx1 (+ (car p1) XXN))
   (setq yy1 (+ (car (cdr p1)) YYN))
   (setq pp2 (list xx1 yy1))
(COMMAND "-layer" "m" "M-FIRE-SYMB-P" "c" "2" "" "")
(COMMAND "INSERT" BB1 pp2 "" "" "")
;(COMMAND "ARRAY" "L" "" "R" NY NX DS2 DS1)
    (if (eq NX 1) (COMMAND "ARRAY" "L" "" "R" NY NX DS2))
    (if (eq NY 1) (COMMAND "ARRAY" "L" "" "R" NY NX DS1))
    (if (AND (/= NX 1) (/= NY 1))(COMMAND "ARRAY" "L" "" "R" NY NX DS2 DS1))
(PRIN1)
(PRIN1)
(PROMPT "\n")
(PROMPT "\n CREATED by :")
(PROMPT "\n                  ********* M.SAIED. ********* ")
(PROMPT "\n MODIFIED by :")
(PROMPT "\n                  ********* Saber Elkassas. ********* ")
(PRINC)
);DEFUN
0 Likes
Message 4 of 5

john.uhden
Mentor
Mentor

The main thing I see is that your code is trusting that with (entsel) your user will have actually picked a polyline with multiple vertices.  Try including checks, like:

Was an object selected?

Try using (vlax-method-applicable-p ...) on the rect to make sure it is a curve object, or even check the objectname to see if it is a polyline.

Then maybe your ifs for the various array calls should be part of a (cond ...) test rather than possibly running all 3 array commands.

 

I'm sorry, but I didn't really study what you are trying to do.

John F. Uhden

0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant

@107199 wrote:

this lisp is used to select one rect. i am trying to convert it to make multi. selection and process the lisp onetime


Answered on the other thread about this.

Kent Cooper, AIA
0 Likes