乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: Small Fish

[编程交流] 按y值对ss排序

[复制链接]

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:22:29 | 显示全部楼层
Its a bit complicated, but maybe this is what you are trying to achieve?
 
  1. (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))
回复

使用道具 举报

55

主题

243

帖子

188

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
275
发表于 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:
 
  1. (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
回复

使用道具 举报

55

主题

243

帖子

188

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
275
发表于 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
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 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
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-5 00:11 , Processed in 0.352194 second(s), 58 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表