Tharwat 发表于 2022-7-5 23:15:57

 
Logically it should be but in reality it's NOT , cause I did not put them in order while gathering the needed information ( coordinates ) .

Tharwat 发表于 2022-7-5 23:22:24

 
You are welcome hosyn

marko_ribar 发表于 2022-7-5 23:23:57

Yes, you're right Tharwat... Your mapcar is looking in first sequence first items from both lists, and then second ones... Thanks, you corrected me, I overlooked...

Tharwat 发表于 2022-7-5 23:28:59

You're welcome Marko , it is my pleasure .

Lee Mac 发表于 2022-7-5 23:31:37

Here's another way to write it:

(defun c:test ( / a b i m n s )   (if (setq s (ssget "_:L" '((-4 . ""))))       (progn         (repeat (setq i (sslength s))               (vla-getboundingbox (vlax-ename->vla-object (ssname s (setq i (1- i)))) 'a 'b)               (setq m (cond ((mapcar 'min m (setq a (vlax-safearray->list a)))) ( a ))                     n (cond ((mapcar 'max n (setq b (vlax-safearray->list b)))) ( b ))               )         )         (command "_.move" s "" "_non" (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) m n) "_non" '(10 10 0))       )   )   (princ))(vl-load-com) (princ)

Tharwat 发表于 2022-7-5 23:36:18

It is good to know that mapcar with either of min and max functions work on LISTS and return the predicate list if matched the criteria of course .
Thanks for the variation .
页: 1 [2]
查看完整版本: 修改以下内容是否有帮助