sijinbo 发表于 2011-4-11 00:31:57

程序一直说有错误,输入的列表有缺陷

(defun C:bezier3()
   (setq b0 (getpoint"\nEnter first point:"))
   (setq b1 (getpoint"\nSencond point:"))
   (setq b2 (getpoint"\nThird point:"))
   (setq b3 (getpoint"\nForth point:"))
   (setq x0 (car b0) yo (cadr b0))
   (setq x1 (car b1) y1 (cadr b1))
   (setq x2 (car b2) y2 (cadr b2))
   (setq x3 (car b3) y3 (cadr b3))
   (setq a1 (* 3 (- x1 x0)))
   (setq a2 (+ (- (* 3 x0)(* 6 x1))(* 3 x2)))
   (setq a3 (- (+ (* 3 x1) x3)(+(* 3 x2) x0)))
   (setq a4 (* 3 (- y1 y0)))
   (setq a5 (+ (- (* 3 y0)(* 6 y1))(* 3 y2)))
   (setq a6 (- (+ (* 3 y1) y3)(+(* 3 y2) y0)))
   (command "layer" "s" 4 "")
   (command "line" b0 b1 b2 b3 "")         
   (command "layer" "s" 1 "")
   (setq t1 0)
   (command "pline")
   (repeat 11
      (setq x (+ x0 (* a1 t1)(* a2 t1 t1)(* a3 t1 t1 t1)))
      (setq y (+ y0 (* a4 t1)(* a5 t1 t1)(* a6 t1 t1 t1)))
      (command(list x y)
      (setq t1 (+ t1 0.1))
      )
   (command)
   (command "pedit" "L" "f" "")
   (command "redraw")
)
不知道出了什么问题,这是用来画三次bezier曲线的

啵浪鼓 发表于 2011-4-11 01:25:42

少了一个右括号
(command(list x y)

Andyhon 发表于 2011-4-11 08:32:12

   
   ;; (setq x0 (car b0) yo (cadr b0))
   (setq x0 (car b0) y0 (cadr b0))

   
   ;; (command "layer" "s" 4 "")
   (command "layer" "s" "4" "")
   ;; (command "layer" "s" 1 "")
   (command "layer" "s" "1" "")

   might be
   (Setvar "Clayer" "1")   ;; <====> (command "layer" "s" "1" "")

其下因不知您的算法本意,未校.......

mandala 发表于 2011-4-11 11:41:55

本帖最后由 mandala 于 2011-4-11 11:42 编辑

(repeat 11
      (setq x (+ x0 (* a1 t1)(* a2 t1 t1)(* a3 t1 t1 t1)))
      (setq y (+ y0 (* a4 t1)(* a5 t1 t1)(* a6 t1 t1 t1)))
      (command(list x y))   
(setq t1 (+ t1 0.1))
      )
少个括弧

xyp1964 发表于 2011-4-11 11:43:32

本帖最后由 xyp1964 于 2011-4-11 11:48 编辑

(defun C:tt ()
(if (setq b0 (getpoint "\nEnter first point: ")
   b1 (getpoint b0 "\nSencond point: ")
   b2 (getpoint b1 "\nThird point: ")
   b3 (getpoint b2 "\nForth point: ")
      )
    (progn
      (setq x0 (car b0)
   y0 (cadr b0)
   x1 (car b1)
   y1 (cadr b1)
   x2 (car b2)
   y2 (cadr b2)
   x3 (car b3)
   y3 (cadr b3)
   a1 (* 3 (- x1 x0))
   a2 (+ (- (* 3 x0) (* 6 x1)) (* 3 x2))
   a3 (- (+ (* 3 x1) x3) (+ (* 3 x2) x0))
   a4 (* 3 (- y1 y0))
   a5 (+ (- (* 3 y0) (* 6 y1)) (* 3 y2))
   a6 (- (+ (* 3 y1) y3) (+ (* 3 y2) y0))
      )
      (command "layer" "s" "4" "c" "4" "" "")
      (command "pline" b0 b1 b2 b3 "")
      (command "layer" "s" "1" "c" "1" "" "")
      (setq t1 0)
      (command "pline")
      (repeat 11
(setq x(+ x0 (* a1 t1) (* a2 t1 t1) (* a3 t1 t1 t1))
       y(+ y0 (* a4 t1) (* a5 t1 t1) (* a6 t1 t1 t1))
       t1 (+ t1 0.1)
)
(command (list x y))
      )
      (command "")
      (command "pedit" "L" "f" "")
      (command "redraw")
    )
)
(princ)
)

sijinbo 发表于 2011-4-17 21:00:21

谢谢各位,非常感谢

sijinbo 发表于 2011-4-17 21:23:30

回复 mandala 的帖子

在输入的四个点时是怎么输入的,我输入时提示参数类型错误,麻烦你了
页: [1]
查看完整版本: 程序一直说有错误,输入的列表有缺陷