明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 507|回复: 7

[源码] 简化阵列

[复制链接]
发表于 2020-12-10 17:18 | 显示全部楼层 |阅读模式
2明经币
麻烦哪位大神帮忙优化下,感激不尽
简化阵列
(defun c:rrR(/ *hang2 *jj2 *lie2 a1 ab1 b1 ss xlen ylen)
(setq ss (ssget))
(setq ab1 (box ss) a1 (car ab1) b1         (cadr ab1))
(setq xlen (abs (- (car b1) (car a1))))
(setq ylen (abs (- (cadr b1) (cadr a1))))
(if (not *hang)(setq *hang 1))
(setq *hang (if (setq *hang2 (getint (strcat "\n输入行数:<" (itoa *hang) ">:"))) *hang2  *hang))
        
(if (not *lie)(setq *lie 1))
(setq *lie (if (setq *lie2 (getint (strcat "\n输入列数:<" (itoa *lie) ">:"))) *lie2 *lie))
(if (not *jj)(setq *jj 100))        
(setq *jj (if (setq *jj2 (getdist (strcat "\n输入间距:<" (rtos *jj 2 2) ">:"))) *jj2 *jj))
(command "ARRAY" ss "" "r" *hang *lie (+ ylen *jj) (+ xlen *jj))
;(princ)        
)

按x轴阵列是没有问题但是按Y轴阵列就会出现重叠的现象

最佳答案

查看完整内容

(command "ARRAY" ss "" "r" *hang *lie (+ ylen *jj) (+ xlen *jj)) 改为: (if (= 1 *hang) (command "ARRAY" ss "" "r" *hang *lie (+ xlen *jj)) (command "ARRAY" ss "" "r" *hang *lie (+ ylen *jj) (+ xlen *jj)))
发表于 2020-12-10 17:18 | 显示全部楼层
(command "ARRAY" ss "" "r" *hang *lie (+ ylen *jj) (+ xlen *jj))
改为:
(if (= 1 *hang) (command "ARRAY" ss "" "r" *hang *lie (+ xlen *jj)) (command "ARRAY" ss "" "r" *hang *lie (+ ylen *jj) (+ xlen *jj)))
回复

使用道具 举报

 楼主| 发表于 2020-12-10 19:28 | 显示全部楼层
start4444 发表于 2020-12-10 17:18
(command "ARRAY" ss "" "r" *hang *lie (+ ylen *jj) (+ xlen *jj))
改为:
(if (= 1 *hang) (command " ...

可以了,谢谢
回复

使用道具 举报

 楼主| 发表于 2020-12-10 19:46 | 显示全部楼层
start4444 发表于 2020-12-10 17:18
(command "ARRAY" ss "" "r" *hang *lie (+ ylen *jj) (+ xlen *jj))
改为:
(if (= 1 *hang) (command " ...

错误: no function definition: BOX    出现问题了

点评

别把box这个函数弄丢了  发表于 2020-12-10 23:27
回复

使用道具 举报

发表于 2020-12-11 08:03 | 显示全部楼层
box这个函数?在哪里呢,没上传啊
回复

使用道具 举报

 楼主| 发表于 2020-12-11 09:00 | 显示全部楼层
vlisp2012 发表于 2020-12-11 08:03
box这个函数?在哪里呢,没上传啊

已经好了,谢谢
回复

使用道具 举报

 楼主| 发表于 2020-12-11 09:10 | 显示全部楼层
GDFGFGF 发表于 2020-12-10 19:46
错误: no function definition: BOX    出现问题了

已经好了,谢谢
回复

使用道具 举报

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

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-24 07:57 , Processed in 0.374440 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表