wzg356 发表于 2022-6-6 10:47:27

(defun c:t11 ( / p1 p2 n p12 xx yy lx ly d)
        (if        (and(setq p1(getpoint "指定第一点:"))
                        (setq p2(getcorner p1 "指定第二点:"))                       
                )
                (progn
                        ;(command "_rectang" "none" p1 "none" p2)
                        (initget "1 2")
                        (setq n(getkword "画几条<1>:"))
                        (setq n(if n (read n)1))
                        (setq p12(list p1 p2))
                        (setq xx(mapcar 'car p12) yy(mapcar 'cadr p12))
                        (setq lx(abs(apply '- xx))ly(abs(apply '- yy)))
                        (setq p1(list(apply 'min xx)(apply 'min yy)))
                        (setq d(if(< lx ly) (/ lx (1+ n))(/ ly (1+ n))))                       
                        (if        (< lx ly)
                                (repeat n                                       
                                        (setq p1 (mapcar '+ p1 (list d 0)))
                                        (command "line" "none" p1 "none" (polar p1 (/ pi 2) ly) "")
                                       
                                )
                                (repeat n
                                        (setq p1 (mapcar '+ p1 (list 0 d)))
                                        (command "line" "none" p1 "none" (polar p1 0 lx) "")
                                )
                        )
                       
                )               
        )
)

999999 发表于 2022-6-6 10:48:47

uualice2020 发表于 2022-6-4 19:27
(defun c:ttt(/ p1 p2 p3 p4 pa pb)
      (setq
                p1(getpoint)


谢谢大神,您辛苦啦,

999999 发表于 2022-6-6 11:04:04

wzg356 发表于 2022-6-6 10:47
(defun c:t11 ( / p1 p2 n p12 xx yy lx ly d)
        (if        (and(setq p1(getpoint "指定第一点:"))
                        (setq p ...

大神您好,您发的代码我这边用了一下和我想要的那个功能相似,唯一不一样就是,我需要生成矩形的边框,您发的带选项功能相当的实用考虑的很周到,要是加上记忆功能,那就非常棒了,感谢您的参与,您的代码我也会好好学习的

wzg356 发表于 2022-6-6 11:12:42

999999 发表于 2022-6-6 11:04
大神您好,您发的代码我这边用了一下和我想要的那个功能相似,唯一不一样就是,我需要生成矩形的边框,您 ...

;(command "_rectang" "none" p1 "none" p2)冒号去掉

想学list就试着重简单的开始自己写

不会的搜别人写的例句-理解,自己试着修改

999999 发表于 2022-6-6 11:23:54

wzg356 发表于 2022-6-6 11:12
;(command "_rectang" "none" p1 "none" p2)冒号去掉

想学list就试着重简单的开始自己写


嗯呐,谢谢大神,我会抽时间好好学习,自己试着写一些简单的

999999 发表于 2022-6-6 11:59:21

wzg356 发表于 2022-6-6 11:12
;(command "_rectang" "none" p1 "none" p2)冒号去掉

想学list就试着重简单的开始自己写


大神您好,我根据您的代码删除了几段,带输入模式的,现在可以完全满意了,再一次谢谢您
(defun c:t11 ( / p1 p2 n p12 xx yy lx ly d)
      (if      (and(setq p1(getpoint "指定第一点:"))
                        (setq p2(getcorner p1 "指定第二点:"))                     
                )
                (progn
                        (command "_rectang" "none" p1 "none" p2)
                        (setq n(if n (read n)2))
                        (setq p12(list p1 p2))
                        (setq xx(mapcar 'car p12) yy(mapcar 'cadr p12))
                        (setq lx(abs(apply '- xx))ly(abs(apply '- yy)))
                        (setq p1(list(apply 'min xx)(apply 'min yy)))
                        (setq d(if(< lx ly) (/ lx (1+ n))(/ ly (1+ n))))                     
                        (if      (< lx ly)
                              (repeat n                                       
                                        (setq p1 (mapcar '+ p1 (list d 0)))
                                        (command "line" "none" p1 "none" (polar p1 (/ pi 2) ly) "")
                                       
                              )
                              (repeat n
                                        (setq p1 (mapcar '+ p1 (list 0 d)))
                                        (command "line" "none" p1 "none" (polar p1 0 lx) "")
                              )
                        )
                     
                )               
      )
)

wzg356 发表于 2022-6-6 14:09:37

999999 发表于 2022-6-6 11:59
大神您好,我根据您的代码删除了几段,带输入模式的,现在可以完全满意了,再一次谢谢您
(defun c:t11 ( ...不错!


这里
(setq n(if n (read n)2))===改为(setq n(if n n 2))或(or n (setq n 2)

999999 发表于 2022-6-6 14:14:33

wzg356 发表于 2022-6-6 14:09
不错!




,好的哟,改过来了,谢谢您

xyp1964 发表于 2022-6-6 20:01:41


999999 发表于 2022-6-6 21:12:45

xyp1964 发表于 2022-6-6 20:01


院长大人出手不凡,这个批量展示的很棒哟,怪我没有表达清楚,我需要的是自己画出矩形然后生成直线,感谢院长大人出手哟
页: 1 [2] 3
查看完整版本: (求助)请教一下各位大神如何才能实现在矩形内生成直线