明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 464|回复: 1

求大神看哪里错了

[复制链接]
发表于 2019-3-3 16:32 | 显示全部楼层 |阅读模式
2明经币
(defun c:bearing1 (/ d x y id std x1 y1)
  (defun getdata ()
    (setq ra (atof (get_tile "ra_box")))
    (setq rb (atof (get_tile "rb_box")))
    (setq b (atof (get_tile "b_box")))
    (setq r1 (atof (get_tile "r1_box")))
    (setq alf (atof (get_tile "alf_box")))
    (setq x (atof (get_tile "X_box")))
    (setq y (atof (get_tile "Y_box")))
    (setvar "cmdecho" 0)
    (setval "layer" "m" "solid" "")
    (setq id (load_dialog "C:\Users\\Administrator\\Desktop\\新建文本文档.dcl"))
    (if (< id 0)
      (exit)
    )
    (setq j 30
          l 10
          b 9
          r1 0.6
          alf 0
          x 0
          y 0
          std 3
          p0 (list 0 O)
    )
    (while (> std 1)
      (if (not (new_dialog "bearing1" id))
        (exit)
      )                                       ; 初始化对话框bearin,
      (setq x1 (dimx_tile "image"))    ; 设置x1为图像宽
      (setq y1 (dimy_tile "image"))    ; 设置y1为图像高
      (start_image "image")               ; 开始建 立图像
      (slide_image 0 0 x1 y1 "D:\\bearing1.sld")
      (end_image)                       ; 图像建 立完毕
      (set_tile "j_box" (rtos J 2 2))
      (set_tile "l_box" (rtos l 2 2))
      (set_tile "b_box" (rtos b 2 2))
      (set_tile "r1_box" (rtos r1 2 2))
      (set_tile "alf_box" (rtos alf 2 2))
      (set_tile "x_box" (rtos x 2 2))
      (set_tile "y_box" (rtos y 2 2))
      (setq p0 (list x y))
      (action_tile "pick" "(getdata)(done-dialog 2)")
      (action_tile "p_a" "(getdata)(done-dialog 3)")
      (action_tile "accept" "(getdata)(done-dialog 1)")
      (action_tile "cancel" "(done-dialog 0)")
      (setq std (start_dialog))
      (if (= std 2)
        (prong (initget 1) (setq p0 (getpoint "定位点:"))
               (setq x (car p0)
                     y (cadr p0)
               )
        )
      )
      (if (= std 3)
        (progn                               ; 用光标确定螺旋角
          (initget 1)
          (setq ang (getangle p0 "输入螺旋角:"))
          (setq alf (* 180.0 (/ ang pi)))
        )
      )
    )
    (if (> std 0)
      (progn
        (setvar "osmode" 0)               ; 关闭目标捕捉状态
        (setvar "cmdecho" 0)
        (setq a1 (- ra rb))
        (setq b1 (* 0.5 b))
        b2
        (* 0.5 b1)
        a2
        (* 0.5 a1)
        a3
        (* 0.5 a2)
      )
      (setq p1 (polar p0 (+ alf (* 0.5 pi)) b2))
      (setq p2 (polar p0 (+ alf (* 0.5 pi)) b1)) ; p1-p16用于绘制直线
      (setq p3 (polar p0 (+ alf (* -0.5 pi)) b2))
      (setq p4 (polar p0 (+ alf (* -0.5 pi)) b1))
      (setq p5 (polar p2 alf rb))
      (setq p6 (polar p1 alf rb))
      (setq p7 (polar p4 alf rb))
      (setq p8 (polar p3 alf rb))
      (setq p9 (polar p2 alf ra))
      (setq p10 (polar p1 alf ra))
      (setq p11 (polar p4 alf ra))
      (setq p12 (polar p3 alf ra))
      (setq p16 (polar p6 alf a3))
      (setq p15 (polar p8 alf a3))
      (setq p13 (polar p16 alf a2))
      (setq p14 (polar p15 alf a2))
      (command "linetype" "set" "bylayer" " ") ; 设置新实体为随层
      (command "line" p2 p9 " ")
      (command "line" p1 p10 " ")
      (command "line" p9 p10 " ")
      (command "line" p4 p11 " ")
      (command "line" p3 p12 " ")
      (command "line" p11 p12 " ")
      (command "line" p5 p6 " ")
      (command "line" p7 p8 " ")
      (command "line" p15 p16 " ")
      (command "line" p13 p14 " ")
      (setq c1 (polar p9 (+ alf (* -0.5 pi)) (* 0.1 b1))) ; 设置倒圆角点
      (setq c2 (polar p9 (+ alf pi) (* 0.1 b1)))
      (setq c3 (polar p11 (+ alf (* 0.5 pi)) (* 0.1 b1)))
      (setq c4 (polar p11 (+ alf pi) (* 0.1 b1)))
      (command "fillet" "r" r1 "fillet" c1 c2)
      (command "fillet" "r" r1 "fillet" c3 c4)
      (setq pm1 (polar p15 (+ alf (* -0.5 pi)) 5)) ; 剖面线点
      (setq pm1 (polar p16 (+ alf (* 0.5 pi)) 5))
      (command "bhatch" "p" "ansi31" "2" "90" pm1 "") ; 绘制剖面线
      (command "bhatch" "p" "ansi31" "2" "0" pm2 "")
      (command "linetype" "set" "center" "") ; 设置新实体为中心线
      (setq p18 (polar p4 (+ alf (* -0.5 pi)) (* 0.1 b))) ; 剖面线点
      (setq p17 (polar p2 (+ alf (* 0.5 pi)) (* 0.1 b)))
      (setq p20 (polar p0 alf (+ ra (* 0.1 b1))))
      (setq p19 (polar p0 (+ alf pi) (* 0.1 b1)))
      (command "lind" p19 p20 "")
      (command "lind" p17 p18 "")
      (command "linetype" "set" "bylayer" "") ; 设置新实体为随层
      (setvar "dinscale" 5)               ; 开始尺寸标注
      (setq t1 (polar p7 (+ alf (* -0.5 pi)) b1))
      (setq t2 (polar p7 (+ alf (* -0.5 pi)) (* 0.5 b1)))
      (setq t3 (polar p10 alf (* 0.5 b1)))
      (setq t4 (polar p4 (+ alf (* 0.5 pi)) b2))
      (setq t5 (polar p4 (+ alf pi) (* 0.5 a2)))
      (command "dimlinear" p4 p11 "h" t1)
      (command "dimlinear" p4 p7 "h" t2)
      (command "dimlinear" P2 p4 "v" t3)
      (command "dimlinear" p13 p14 "v" t5)
      (princ)
    )
  )
  (unload_dialog id)
  (princ)
)




发表于 2019-4-9 15:10 | 显示全部楼层
;;如果你问的是语法上的错的话
;;(if (> std 0) ...) 里面的语句有问题,progn的后一个括号位置不对,应该改成下面的样子

(defun c:bearing1 (/ d x y id std x1 y1)
  (defun getdata ()
    (setq ra (atof (get_tile "ra_box")))
    (setq rb (atof (get_tile "rb_box")))
    (setq b (atof (get_tile "b_box")))
    (setq r1 (atof (get_tile "r1_box")))
    (setq alf (atof (get_tile "alf_box")))
    (setq x (atof (get_tile "X_box")))
    (setq y (atof (get_tile "Y_box")))
    (setvar "cmdecho" 0)
    (setval "layer" "m" "solid" "")
    (setq id (load_dialog "C:\Users\\Administrator\\Desktop\\新建文本文档.dcl"))
    (if (< id 0)
      (exit)
    )
    (setq j 30
          l 10
          b 9
          r1 0.6
          alf 0
          x 0
          y 0
          std 3
          p0 (list 0 O)
    )
    (while (> std 1)
      (if (not (new_dialog "bearing1" id))
        (exit)
      )                                       ; 初始化对话框bearin,
      (setq x1 (dimx_tile "image"))    ; 设置x1为图像宽
      (setq y1 (dimy_tile "image"))    ; 设置y1为图像高
      (start_image "image")               ; 开始建 立图像
      (slide_image 0 0 x1 y1 "D:\\bearing1.sld")
      (end_image)                       ; 图像建 立完毕
      (set_tile "j_box" (rtos J 2 2))
      (set_tile "l_box" (rtos l 2 2))
      (set_tile "b_box" (rtos b 2 2))
      (set_tile "r1_box" (rtos r1 2 2))
      (set_tile "alf_box" (rtos alf 2 2))
      (set_tile "x_box" (rtos x 2 2))
      (set_tile "y_box" (rtos y 2 2))
      (setq p0 (list x y))
      (action_tile "pick" "(getdata)(done-dialog 2)")
      (action_tile "p_a" "(getdata)(done-dialog 3)")
      (action_tile "accept" "(getdata)(done-dialog 1)")
      (action_tile "cancel" "(done-dialog 0)")
      (setq std (start_dialog))
      (if (= std 2)
        (prong (initget 1) (setq p0 (getpoint "定位点:"))
               (setq x (car p0)
                     y (cadr p0)
               )
        )
      )
      (if (= std 3)
        (progn                               ; 用光标确定螺旋角
          (initget 1)
          (setq ang (getangle p0 "输入螺旋角:"))
          (setq alf (* 180.0 (/ ang pi)))
        )
      )
    )
    (if        (> std 0)
      (progn
        (setvar "osmode" 0)                ; 关闭目标捕捉状态
        (setvar "cmdecho" 0)
        (setq a1 (- ra rb))
        (setq b1 (* 0.5 b))
        b2
        (* 0.5 b1)
        a2
        (* 0.5 a1)
        a3
        (* 0.5 a2)
        ;;) 这个注释掉的括号位置不对
        (setq p1 (polar p0 (+ alf (* 0.5 pi)) b2))
        (setq p2 (polar p0 (+ alf (* 0.5 pi)) b1)) ; p1-p16用于绘制直线
        (setq p3 (polar p0 (+ alf (* -0.5 pi)) b2))
        (setq p4 (polar p0 (+ alf (* -0.5 pi)) b1))
        (setq p5 (polar p2 alf rb))
        (setq p6 (polar p1 alf rb))
        (setq p7 (polar p4 alf rb))
        (setq p8 (polar p3 alf rb))
        (setq p9 (polar p2 alf ra))
        (setq p10 (polar p1 alf ra))
        (setq p11 (polar p4 alf ra))
        (setq p12 (polar p3 alf ra))
        (setq p16 (polar p6 alf a3))
        (setq p15 (polar p8 alf a3))
        (setq p13 (polar p16 alf a2))
        (setq p14 (polar p15 alf a2))
        (command "linetype" "set" "bylayer" " ") ; 设置新实体为随层
        (command "line" p2 p9 " ")
        (command "line" p1 p10 " ")
        (command "line" p9 p10 " ")
        (command "line" p4 p11 " ")
        (command "line" p3 p12 " ")
        (command "line" p11 p12 " ")
        (command "line" p5 p6 " ")
        (command "line" p7 p8 " ")
        (command "line" p15 p16 " ")
        (command "line" p13 p14 " ")
        (setq c1 (polar p9 (+ alf (* -0.5 pi)) (* 0.1 b1)))
                                        ; 设置倒圆角点
        (setq c2 (polar p9 (+ alf pi) (* 0.1 b1)))
        (setq c3 (polar p11 (+ alf (* 0.5 pi)) (* 0.1 b1)))
        (setq c4 (polar p11 (+ alf pi) (* 0.1 b1)))
        (command "fillet" "r" r1 "fillet" c1 c2)
        (command "fillet" "r" r1 "fillet" c3 c4)
        (setq pm1 (polar p15 (+ alf (* -0.5 pi)) 5)) ; 剖面线点
        (setq pm1 (polar p16 (+ alf (* 0.5 pi)) 5))
        (command "bhatch" "p" "ansi31" "2" "90" pm1 "") ; 绘制剖面线
        (command "bhatch" "p" "ansi31" "2" "0" pm2 "")
        (command "linetype" "set" "center" "") ; 设置新实体为中心线
        (setq p18 (polar p4 (+ alf (* -0.5 pi)) (* 0.1 b))) ; 剖面线点
        (setq p17 (polar p2 (+ alf (* 0.5 pi)) (* 0.1 b)))
        (setq p20 (polar p0 alf (+ ra (* 0.1 b1))))
        (setq p19 (polar p0 (+ alf pi) (* 0.1 b1)))
        (command "lind" p19 p20 "")
        (command "lind" p17 p18 "")
        (command "linetype" "set" "bylayer" "") ; 设置新实体为随层
        (setvar "dinscale" 5)                ; 开始尺寸标注
        (setq t1 (polar p7 (+ alf (* -0.5 pi)) b1))
        (setq t2 (polar p7 (+ alf (* -0.5 pi)) (* 0.5 b1)))
        (setq t3 (polar p10 alf (* 0.5 b1)))
        (setq t4 (polar p4 (+ alf (* 0.5 pi)) b2))
        (setq t5 (polar p4 (+ alf pi) (* 0.5 a2)))
        (command "dimlinear" p4 p11 "h" t1)
        (command "dimlinear" p4 p7 "h" t2)
        (command "dimlinear" P2 p4 "v" t3)
        (command "dimlinear" p13 p14 "v" t5)
        (princ)
      ) ;;那个括号位置应该在这
    )
  )
  (unload_dialog id)
  (princ)
)

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-17 04:07 , Processed in 0.204246 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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