明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1380|回复: 0

[源码] 奉献一个小程序,请高手完善一下

[复制链接]
发表于 2013-7-25 10:44:44 | 显示全部楼层 |阅读模式
下面的程序在执行中有一个问题,当画两条折线的长度小于1200是,两条折线没法闭合,请高手完善一下,不胜感激
(defun C:STR (/ pt1 pt2 l n p0 p1 t01 t02 t1 t2 S1 S2 old_osmode old_cmdecho k ent13 i th ths)
;;保存系统变量设置
(setq old_osmode (getvar "osmode"))
(setq old_CMDECHO (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setvar "osmode" 32)
(command "-layer" "m" "栏杆" "C" "1" "" "")
(if (= ths nil)
    (setq ths 0)
  )
  (setq th (getreal (strcat "\n栏杆离板边距<" (rtos ths 2 0) ">:")))
  (if (= th nil)
    (setq th ths)
  )
  (setq ths th)
(if (setq pt1 (getpoint "\n第一点(顺时针):"))
(while (setq pt2 (getpoint pt1 "\n下一点:"))
(setvar "osmode" 0)
(setq k (angle pt1 pt2))
;(setq L (distance pt1 pt2))
(setq t01 (polar pt1 (- k (* 0.5 pi)) th))
(setq t1 (polar t01  k  th))
(setq t02 (polar pt2 (- k (* 0.5 pi)) th))
(setq t2 (polar t02 (- k (* 1 pi)) th))
(setq L (distance t1 t2))
(command "line" t1 t2 "")
(setq ENT13 (entlast)
        S1    (list ENT13 t1)
  )
(if S2
   (command "_.EXTEND" S1 S2 "" S1 S2 "")  
   )
(command "donut" "0" "80" t1 "")
(command "donut" "0" "80" t2 "")
(setq N (/ L 1200))
(setq I 1)
(setq P0 t1)
(while (<= i N)
(setq P1 (polar p0 k 1200))
;(setvar "osmode" 0)
(progn
(command "donut" "0" "80" p1 "")
(setq P0 (polar p0 k 1200))
(setq I (+ i 1))
(setq S2 (list ENT13 t2))
)
)
(setvar "osmode" 32)
(setq pt1 pt2)
)
)
;;恢复系统变量设置
(setvar "osmode" old_osmode)
(setvar "CMDECHO" old_CMDECHO)
(setvar "clayer" "0")
(princ)
)
"觉得好,就打赏"
还没有人打赏,支持一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-23 15:23 , Processed in 0.187483 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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