找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 265|回复: 4

[求助] VLISP在CAD2012使用时,出现参数类型错误:二维/三维点:0

[复制链接]

已领礼包: 1个

财富等级: 恭喜发财

发表于 2020-6-24 21:55:12 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我是VLISP初学者,看着实例写的程序,在CAD2008以下版本试用时,没有错误,而且可以正常使用
但是在CAD2010以上版本使用时,就会出现;错误:参数类型错误:二维/三维点:0

是哪里出问题了





论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 19个

财富等级: 恭喜发财

发表于 2020-6-26 22:34:38 | 显示全部楼层
要把你的代码帖上来,才好找问题
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 1个

财富等级: 恭喜发财

 楼主| 发表于 2020-6-28 19:06:29 | 显示全部楼层
;---------autodim----------
(defun bz (yi / AM ANG ANG0 ANG1 BU BUGLE HI IN INPOINT
           KM1 LEN LEN0 LONG MIDPOINT NUM PO0 PO1 PO2 POLY
           R1 RADIUS S SCALE TXTDIST W WZ XX YU YY ZG ZZ)         
  (command "style" "hztxt" "monotxt.shx" 0 1.0 0 "n" "n" "n")     ;设置字体
  (command "style" "standard" "simsun.ttf" 0 1.0 0 "n" "n")       ;设置字体
  (command "dimzin" 1)                                            ;设置未数带0
    (if (= 0.0 (getvar "userr5")) (setvar "userr5" 200.0))
  (setq scale (getvar "userr5"))
  (if (= scale nil) (setq scale 200))                             ;_end of if
  (setq s (* scale 0.0001))                                       ;精确小数位数
  (setvar "cecolor" "2")                                          ;设置颜色为黄色
  (setq in (getpoint "请在区域内取一点:"))                        ;等待用户输入,边界内一点赋于in
  (command "boundary" in "")                                      ;创建边界poly
  (setq poly (entget (entlast)))                                  ;将变量poly设为边界的图元名称
  (setvar "cecolor" "256")                                        ;颜色恢复为bylayer
  (setq long (length poly))                                       ;求表长long
  (setq po0 (assoc 10 poly))                                      ;求第一个端点p0
  (setq num 10)
  (setq bugle (assoc 42 poly))                                    ;求第一个凸度大小
  (setq bu 0)
  (while (/= bu bugle)                                            
    (setq num (+ 1 num))
    (setq bu (nth num poly)))                                     ;确定第一个凸度位置num
  (setq bu (cdr bu))                                              ;去掉第一个元素后所得的表赋于bu
  (while (/= nil bu)                                             
    (setq po1 0
          po2 0)                                                  ;设置po1,po2初值为0
    (if (< (+ 4 num) long)
      (setq po2 (nth (+ 1 num) poly))
      (setq po2 po0))                                             ;_END of if
    (setq po1 (nth (- num 3) poly))
    (setq po1 (cdr po1)
          po2 (cdr po2))
    (setq len (/ (distance po1 po2) 2))                           ;求po1,po2的距离的一半赋于len
    (setq ang0 (angle po1 po2))                                   ;求角度值赋于ang0
    (setq midpoint (polar po1 ang0 len))                          ;求三维点赋于midpoint
    (cond ((/= 0 bu)                                             
           (progn                                                
             (if (> bu 0)
               (setq ang (- ang0 (* pi 0.5)))
               (setq ang (+ ang0 (* pi 0.5))))                    ;_END of if
             (setq zg (* scale 0.002))
             (setq hi (abs bu))
             (setq inpoint (polar midpoint ang (* len hi)))
             (setq radius (/ (* len (+ 1 (* hi hi)) 2) (* 4 hi)))
             (setq R1 (fix (+ 0.5 (* radius 1000))))
             (setq yu (fix (rem R1 10)))
             (if (/= 0 yu)
               (setq w 3)
               (setq w 2))                                        ;_END of if
             (setq radius (rtos radius 2 w))
             (setq radius (strcat "←R" radius))
             (setq ang1 (+ ang0 (* pi 0.5)) wz radius)
             (f4 inpoint zg 0.5 "standard" "套内标注" wz 256 ang1)
             (setq txtdist (distance (cdr (assoc 10 (entget (entlast))))
                                     (cdr (assoc 11 (entget (entlast))))))
             (setq inpoint (polar midpoint ang (+ (* len hi) (* yi txtdist))))
             (entdel (entlast))
             (f4 inpoint zg 0.5 "standard" "套内标注" wz 256 (+ (* pi (+ 1 yi) 0.5 ang1))));完成半径标注
           )
           ((= 0 bu)
            (progn                                               
              (setq s (* scale 0.0001))
              (setq km1 (fix (+ 0.5 (* len 1000 2))))
              (setq yu (fix (rem km1 10)))
              (if (/= 0 yu)
                (setq w 3)
                (setq w 2))
              (setq len0 (* len 2))
              (setq wz (rtos len0 2 w))
              (setq ang0 (+ ang0 (* pi (/ (+ 1 yi) 2))))
              (setq ang1 ang0)
              (if (and (> ang1 1.570796327) (< ang1 5.759586532))
                (progn
                  (setq ang1 (+ ang1 3.141592654))
                  (setq s (* scale 0.003))))
              (setq am (polar midpoint (+ ang0 (* pi 0.5)) s))
              (setq xx (car am)                                   ;返回表am中的第一个元素赋于xx
                    yy (cadr am)                                  ;返回表am中的第二个元素赋于yy
                    zz 0.0000)
              (setq zg (* scale 0.002))
              (setq inpoint (list xx yy zz))
              (f4 inpoint zg 0.5 "hztxt" "套内标注" wz 256 ang1)) ;完成直线标注
            ))
    (setq num (+ 4 num))                                           ;求下一个num+4
    (setq bu (cdr (nth num poly)))                                ;求下一个凸度bu
    ))                                                            ;_END of defun
;---------------------------------AUTOdim-----------------------------------------
(defun c:ba () (bz -1))
(defun c:bw () (bz 1))


                    
               



点评

在代码的适当位置,加一些打印语句,看看执行到哪里出问题的  详情 回复 发表于 2020-6-28 19:08
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 1个

财富等级: 恭喜发财

 楼主| 发表于 2020-6-28 19:08:39 | 显示全部楼层
Lisphk 发表于 2020-6-26 22:34
要把你的代码帖上来,才好找问题

;---------autodim----------
(defun bz (yi / AM ANG ANG0 ANG1 BU BUGLE HI IN INPOINT
           KM1 LEN LEN0 LONG MIDPOINT NUM PO0 PO1 PO2 POLY
           R1 RADIUS S SCALE TXTDIST W WZ XX YU YY ZG ZZ)         
  (command "style" "hztxt" "monotxt.shx" 0 1.0 0 "n" "n" "n")     ;设置字体
  (command "style" "standard" "simsun.ttf" 0 1.0 0 "n" "n")       ;设置字体
  (command "dimzin" 1)                                            ;设置未数带0
    (if (= 0.0 (getvar "userr5")) (setvar "userr5" 200.0))
  (setq scale (getvar "userr5"))
  (if (= scale nil) (setq scale 200))                             ;_end of if
  (setq s (* scale 0.0001))                                       ;精确小数位数
  (setvar "cecolor" "2")                                          ;设置颜色为黄色
  (setq in (getpoint "请在区域内取一点:"))                        ;等待用户输入,边界内一点赋于in
  (command "boundary" in "")                                      ;创建边界poly
  (setq poly (entget (entlast)))                                  ;将变量poly设为边界的图元名称
  (setvar "cecolor" "256")                                        ;颜色恢复为bylayer
  (setq long (length poly))                                       ;求表长long
  (setq po0 (assoc 10 poly))                                      ;求第一个端点p0
  (setq num 10)
  (setq bugle (assoc 42 poly))                                    ;求第一个凸度大小
  (setq bu 0)
  (while (/= bu bugle)                                            
    (setq num (+ 1 num))
    (setq bu (nth num poly)))                                     ;确定第一个凸度位置num
  (setq bu (cdr bu))                                              ;去掉第一个元素后所得的表赋于bu
  (while (/= nil bu)                                             
    (setq po1 0
          po2 0)                                                  ;设置po1,po2初值为0
    (if (< (+ 4 num) long)
      (setq po2 (nth (+ 1 num) poly))
      (setq po2 po0))                                             ;_END of if
    (setq po1 (nth (- num 3) poly))
    (setq po1 (cdr po1)
          po2 (cdr po2))
    (setq len (/ (distance po1 po2) 2))                           ;求po1,po2的距离的一半赋于len
    (setq ang0 (angle po1 po2))                                   ;求角度值赋于ang0
    (setq midpoint (polar po1 ang0 len))                          ;求三维点赋于midpoint
    (cond ((/= 0 bu)                                             
           (progn                                                
             (if (> bu 0)
               (setq ang (- ang0 (* pi 0.5)))
               (setq ang (+ ang0 (* pi 0.5))))                    ;_END of if
             (setq zg (* scale 0.002))
             (setq hi (abs bu))
             (setq inpoint (polar midpoint ang (* len hi)))
             (setq radius (/ (* len (+ 1 (* hi hi)) 2) (* 4 hi)))
             (setq R1 (fix (+ 0.5 (* radius 1000))))
             (setq yu (fix (rem R1 10)))
             (if (/= 0 yu)
               (setq w 3)
               (setq w 2))                                        ;_END of if
             (setq radius (rtos radius 2 w))
             (setq radius (strcat "←R" radius))
             (setq ang1 (+ ang0 (* pi 0.5)) wz radius)
             (f4 inpoint zg 0.5 "standard" "套内标注" wz 256 ang1)
             (setq txtdist (distance (cdr (assoc 10 (entget (entlast))))
                                     (cdr (assoc 11 (entget (entlast))))))
             (setq inpoint (polar midpoint ang (+ (* len hi) (* yi txtdist))))
             (entdel (entlast))
             (f4 inpoint zg 0.5 "standard" "套内标注" wz 256 (+ (* pi (+ 1 yi) 0.5 ang1))));完成半径标注
           )
           ((= 0 bu)
            (progn                                               
              (setq s (* scale 0.0001))
              (setq km1 (fix (+ 0.5 (* len 1000 2))))
              (setq yu (fix (rem km1 10)))
              (if (/= 0 yu)
                (setq w 3)
                (setq w 2))
              (setq len0 (* len 2))
              (setq wz (rtos len0 2 w))
              (setq ang0 (+ ang0 (* pi (/ (+ 1 yi) 2))))
              (setq ang1 ang0)
              (if (and (> ang1 1.570796327) (< ang1 5.759586532))
                (progn
                  (setq ang1 (+ ang1 3.141592654))
                  (setq s (* scale 0.003))))
              (setq am (polar midpoint (+ ang0 (* pi 0.5)) s))
              (setq xx (car am)                                   ;返回表am中的第一个元素赋于xx
                    yy (cadr am)                                  ;返回表am中的第二个元素赋于yy
                    zz 0.0000)
              (setq zg (* scale 0.002))
              (setq inpoint (list xx yy zz))
              (f4 inpoint zg 0.5 "hztxt" "套内标注" wz 256 ang1)) ;完成直线标注
            ))
    (setq num (+ 4 num))                                           ;求下一个num+4
    (setq bu (cdr (nth num poly)))                                ;求下一个凸度bu
    ))                                                            ;_END of defun
;---------------------------------AUTOdim-----------------------------------------
(defun c:ba () (bz -1))
(defun c:bw () (bz 1))

   
                    
               
   
  
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 40个

财富等级: 招财进宝

发表于 2020-6-28 19:08:49 | 显示全部楼层
xufeihzq 发表于 2020-6-28 19:06
;---------autodim----------
(defun bz (yi / AM ANG ANG0 ANG1 BU BUGLE HI IN INPOINT
           KM1 LEN LE ...

在代码的适当位置,加一些打印语句,看看执行到哪里出问题的
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-3-29 17:41 , Processed in 0.181166 second(s), 39 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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