明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1961|回复: 4

为啥有错?!!

[复制链接]
发表于 2002-11-30 09:44:00 | 显示全部楼层 |阅读模式
(defun midpoint (p2 p3)
  (list (/ (+ (car p2) (car p3)) 2) (/ (+ (cadr p2) (cadr p3)) 2)))
(defun go1 (p3 p2)
  (list ((car p3) (cadr p2))))
(defun go2 (p2 p3)
  (list ((car p2) (cadr p3))))
(defun c:t5 (/ p1 p2 p3 k p4 p5)
  (setq p1 (getpoint "\n input p1"))
  (setq p2 (getpoint "\n input p2"))
  (setq p3 (polar p2 0 30))
  (setq num (getint "\n input number"))
  (command "pline" p1 p2 p3 "")
  (command "text" "j" "mc" (polar (midpoint p2 p3) (/ pi 2) 10) "10" "" num )
  (setq k 1)
  (while (= k 1)
    (setq p1 (getpoint "\n input p1"))
    (setq p3 (getpoint "\n input p2"))
    (setq num (+ num 1))
    (setq ang (angle p2 p3))
    (cond
      ((or (> ang (* (/ pi 4) 7)) (< ang (/ pi 4)) (and (> ang (* (/ pi 4) 3)) (< ang (* (/ pi 4) 5))))
       (setq p4 (go1 p3 p2)))
      ((or (and (> ang (/ pi 4)) (< ang (* (/ pi 4) 3))) (and (< ang (* (/ pi 4) 7)) (> ang (* (/ pi 4) 6))))
       (setq p4 (go1 p2 p3))))
    (setq p5 (polar p4 0 30))
    (command "pline" p1 p4 p5 "")
    (command "text" "j" "mc" (polar (midpoint p4 p5) (/ pi 2) 10) "10" "" num )
    (print "\n")
    (setq k (getdist "\n do you want continue? input 1 mean yes; input 0 mean no"))))
这是一个标注数字用的程序,一个功能是输入一个数字,后面的数字自动加一,另一个主要功能是自动和原来的p2保持平行或垂直,主要修改p4的坐标达到.可是每次运行到求角度ang后就不行了!盼各位高手火眼金睛了!
发表于 2002-12-2 10:52:00 | 显示全部楼层

老兄,初看了一下

你的go1和go2是同一个函数啊,看来你还不懂函数之间参数是如何转递的。
 楼主| 发表于 2002-12-2 12:07:00 | 显示全部楼层

改了一下,还是有错

还是有错呀
帮帮小弟,看看吧!!
发表于 2002-12-2 16:31:00 | 显示全部楼层

TRY

(defun MIDPOINT        (P2 P3)
  (list        (/ (+ (car P2) (car P3)) 2)
        (/ (+ (cadr P2) (cadr P3)) 2)
  )
)
(defun GO1 (P3 P2)
  (list (car P3) (cadr P2))
)
(defun GO2 (P2 P3)
  (list (car P2) (cadr P3))
)
(defun C:T5 (/ P1 P2 P3 K P4 P5)
  (initget 1)
  (setq P1 (getpoint "\n Input p1: "))
  (initget 1)
  (setq P2 (getpoint P1 "\n Input p2: "))
  (setq P3 (polar P2 0 30))
  (initget 1)
  (setq NUM (getint "\n Input number: "))
  (command "pline" P1 P2 P3 "")
  (command "text"
           "j"
           "mc"
           (polar (MIDPOINT P2 P3) (/ pi 2) 10)
           "10"
           ""
           NUM
  )
  (setq K "Yes")
  (while (= K "Yes")
    (initget 1)
    (setq P1 (getpoint "\n Input p1: "))
    (initget 1)
    (setq P3 (getpoint P1 "\n Input p2: "))
    (setq NUM (+ NUM 1))
    (setq ANG (angle P2 P3))
    (cond
      ((or (> ANG (* (/ pi 4) 7))
           (< ANG (/ pi 4))
           (and (> ANG (* (/ pi 4) 3)) (< ANG (* (/ pi 4) 5)))
       )
       (setq P4 (GO1 P3 P2))
      )
      (;|  (or (and (> ANG (/ pi 4)) (< ANG (* (/ pi 4) 3)))
           (and (< ANG (* (/ pi 4) 7)) (> ANG (* (/ pi 4) 6)))
       )|;
       t
       (setq P4 (GO2 P2 P3))
      )
    )
    (setq P5 (polar P4 0 30))
    (command "pline" P1 P4 P5 "")
    (command "text"
             "j"
             "mc"
             (polar (MIDPOINT P4 P5) (/ pi 2) 10)
             "10"
             ""
             NUM
    )
    (setq K (getstring "\n Do you want to continue?<No>/Enter<Yes>: "))
    (if        (= K "")
      (setq K "Yes")
    )
  )
  (princ)
)
 楼主| 发表于 2002-12-2 19:59:00 | 显示全部楼层

好用

谢谢!
我一定好好学习
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 23:53 , Processed in 0.186847 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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