if and conditional help to compare (apply 'max of a list to a (car pt of inters

if and conditional help to compare (apply 'max of a list to a (car pt of inters

Anonymous
Not applicable
2,426 Views
24 Replies
Message 1 of 25

if and conditional help to compare (apply 'max of a list to a (car pt of inters

Anonymous
Not applicable

Hello, 

    I'm trying to compare the results of

        a minimum or maximum apply

with

        the fisrt position of a list that is the (car of a coordinate given by inters command)

 

the values are the same but the results are always nil for both expressions

      (if (= xMax1 (car pts1234)) (progn (setq x1(/ (+ xMin1 (car pts1234)) 2.00)) ))
      (if (= xMin1 (car pts1234)) (progn (setq x1(/ (+ xMax1 (car pts1234)) 2.00)) ))

 

what is wrong?

 

the important part of the code and the results

_$ (setq pt1 (cdr (assoc 10 (entget ocd_line)))) ; 1

(-184.619 265.883 0.0)


_$ (setq pt2 (cdr (assoc 11 (entget ocd_line))))

(-145.645 265.883 0.0)


_$ (setq xl1 (list (car pt1) (car pt2)))

(-184.619 -145.645)


_$ (setq xMax1 (apply 'max xl1))

-145.645


_$ (setq xMin1 (apply 'min xl1))

-184.619


_$ (setq yl1 (list (cadr pt1) (cadr pt2)))

(265.883 265.883)


_$ (setq yMax1 (apply 'max yl1))

265.883


_$ (setq yMin1 (apply 'min yl1))

265.883


_$ (setq pt3 (cdr (assoc 10 (entget obc_line))))

(-184.619 294.473 0.0)


_$ (setq pt4 (cdr (assoc 11 (entget obc_line))))

(-184.619 265.883 0.0)


_$ (setq xl2 (list (car pt3) (car pt4)))

(-184.619 -184.619)


_$ (setq xMax2 (apply 'max xl2))

-184.619


_$ (setq xMin2 (apply 'min xl2))

-184.619


_$ (setq yl2 (list (cadr pt3) (cadr pt4)))

(294.473 265.883)


_$ (setq yMax2 (apply 'max yl2))

294.473


_$ (setq yMin2 (apply 'min yl2))

265.883


_$ (setq pts1234 (inters pt1 pt2 pt3 pt4))

(-184.619 265.883 0.0)


_$ (if (= xMax1 (car pts1234)) (progn (setq x1(/ (+ xMin1 (car pts1234)) 2.00)) ))

nil


_$ (if (= xMin1 (car pts1234)) (progn (setq x1(/ (+ xMax1 (car pts1234)) 2.00)) ))

nil

 

xMin1 and (car pts1234) has the same value as follow

 

_$ (car pts1234)
-184.619

 

_$ xMin1
-184.619

  

should be something like that: (if (= -184.619 -184.619) (progn (setq x1(/ (+ xMax1 (car pts1234)) 2.00)) ))

 

 

Why is not returning TRUE to the sentence to execute the x1 calculation??? (if (= xMin1 (car pts1234)) (progn

 

Because the x1 remains ZERO as set before

_$ x1
0

 

Thanks in advance,

Luis

0 Likes
Accepted solutions (2)
2,427 Views
24 Replies
Replies (24)
Message 21 of 25

Anonymous
Not applicable

It seems work out well. I need to test in a larger drawing code.

0 Likes
Message 22 of 25

Anonymous
Not applicable

Hi Kent,

 

_$ (if (= flag 1) (progn (setq mPt12(list x1 y1)) )) ; ocd_line
_$ (if (= flag 1) (progn (setq mPt34(list x2 y2)) )) ; obc_line


_$ (if (= flag 1) (progn (command "line" mpt12 mpt34 "" "") )) ; new line
_$ (if (= flag 1) (progn (setq mpts (entlast)) )) ; new line
_$ (if (= flag 1) (progn (COMMAND "ZOOM" "OBJECT" mpts "") )) ; new line
_$ (if (= flag 1) (progn (entdel mpts) )) ; new line


_$ (if (= flag 1) (progn (command "._fillet" (osnap mPt12 "nea") (osnap mPt34 "nea") ) ))

 

It seems work out well. I need to test in a larger drawing code. I'll probably need to use ZOOM EXTENT in some point after the ZOOM OBJECT mpts.

0 Likes
Message 23 of 25

Anonymous
Not applicable

Hi Kent,

 

_$ (if (= flag 1) (progn (setq mPt12(list x1 y1)) )) ; ocd_line
_$ (if (= flag 1) (progn (setq mPt34(list x2 y2)) )) ; obc_line

 

_$ (if (= flag 1) (progn (command "line" mpt12 mpt34 "" "") )) ; new line
_$ (if (= flag 1) (progn (setq mpts (entlast)) )) ; new line
_$ (if (= flag 1) (progn (COMMAND "ZOOM" "OBJECT" mpts "") )) ; new line
_$ (if (= flag 1) (progn (entdel mpts) )) ; new line


_$ (if (= flag 1) (progn (command "._fillet" (osnap mPt12 "nea") (osnap mPt34 "nea") ) ))

 

It seems work out well.

 

But maybe I'll need to insert a ZOOM EXTENT in some point after the ZOOM OBJECT

(command "ZOOM" "E")

 

I need to test in a larger drawing code.

 

Thanks!

0 Likes
Message 24 of 25

Anonymous
Not applicable

It seems work out. I need to test in a larger drawing code.

0 Likes
Message 25 of 25

Anonymous
Not applicable

Thanks a lot Kent.

 

It finally work out with the addition of these code lines.

 

_$ (if (= flag 1) (progn (command "line" mpt12 mpt34 "" "") ))
_$ (if (= flag 1) (progn (setq mpts (entlast)) ))
_$ (if (= flag 1) (progn (COMMAND "ZOOM" "OBJECT" mpts "") ))
_$ (if (= flag 1) (progn (entdel mpts) ))


_$ (if (= flag 1) (progn (command "._fillet" (osnap mPt12 "nea") (osnap mPt34 "nea") ) )) ; same line that was unstable before now it's working/

 

_$ (if (= flag 1) (progn (COMMAND "PLAN" "" "") ))

 

0 Likes