Lee Mac 发表于 2022-7-6 15:22:29

Its a bit complicated, but maybe this is what you are trying to achieve?
 

(defun c:RowA3(/ jsx test dxf_ent jsx_ename new_xx total areaobj cLst big_Area rad ListRowDia FinalList) (vl-load-com) (if (setq jsx (ssget "_X" '((0 . "CIRCLE"))))   (progn   (while (not (zerop (sslength jsx)))       (setq dxf_ent(entget (setq jsx_ename (ssname jsx 0)))             new_xx   (ssget "_X"                           (list '(0 . "CIRCLE")                                 '(-4 . "*,=,*")                                 (assoc 10 dxf_ent)))             total    0.0             big_Area nil)       (foreach ent(setq new_xxlst (mapcar 'cadr (ssnamex new_xx)))         (setq areaobj (vla-get-area                         (vlax-ename->vla-object ent))               total   (+ total areaobj)))       (setq cLst (vl-sort                  (mapcar '(lambda (x) (cdr (assoc 10 (entget x)))) new_xxlst)                  '(lambda (x1 x2) (< (car x1) (car x2)))))       (setq Rad (vl-sort                   (mapcar '(lambda (x) (cdr (assoc 40 (entget x)))) new_xxlst)                   '(lambda (x1 x2) (> x1 x2))))       (setq ListRowDia (cons (append (list (caddr (assoc 10 (entget (car new_xxlst))))) Rad) ListRowDia))       (mapcar '(lambda (x) (ssdel x jsx)) new_xxlst);;;      (princ (strcat "\nRow ";;;                     (itoa test);;;                     "; MinXCtr: ";;;                     (vl-princ-to-string (car cLst));;;                     " MaxRad = ";;;                     (vl-princ-to-string (car rad));;;                     " => ";;;                     " Total = ";;;                     (rtos total);;;                     "\n-----------------------------------------"))       (ssdel jsx_ename jsx))   (setq test 1)   (foreach x (mapcar 'cdr (vl-sort ListRowDia '(lambda (x1 x2) (< (car x1) (car x2)))))       (setq FinalList (cons (list test x) FinalList) test (1+ test)))   (princ (vl-princ-to-string FinalList))   (textscr))) (princ))

Small Fish 发表于 2022-7-6 15:25:14

Sorry about not replying sooner - our office caught fire overnight about 5 days ago. We are now in a temporary office. Now I have a chance to check it out.
Yes that's what I am trying to achieve - its getting deep for me to understand.I am struggling adapt your changes to my code. I think I have found all your changes but I am not sure if I need to change the filter?
I have attempted to try and copy your filter onto my code but it does not like it. Should the filter be changed?
It gets stuck on the line:
 

(setq ListRowDia (cons (append (list (caddr (assoc 10 (entget (car new_xxlst))))) Rad) ListRowDia))I am almost there after this problem is fixed.
Thanks Lee mac for you patience
Attached is my code
Small Fish
RowareasX.LSP

Small Fish 发表于 2022-7-6 15:27:48

Okay of have worked it out...after nearly 3 weeks!. I was making something a lot more complicated than need be! By trying to mould your selection set code with my selection set. All I needed to do was just a a separate selection set, so that it makes its own list. Now my project is almost finished. Thanks once again Lee Mac.
 
cheers Small Fish

Lee Mac 发表于 2022-7-6 15:35:20

 
I'm glad you got it sorted in the end - I haven't had the time to be looking at much recently, what with the exams going on here, but its great that you worked it out.
 
Cheers,
 
Lee
页: 1 [2]
查看完整版本: 按y值对ss排序