zhb236623 发表于 2011-7-8 23:13:49

求助,帮忙看下此程序哪里出错

(defun c:tt(/insertp n1 wz )

(if (not (setq n1 (getint "\n请输入起始顺序号 <1>: ")))
    (setq n1 1)
)

(setq wz (strcat (itoa 3) (itoa -50) (itoa -411) "-" (itoa n1)))
(setq insertp (getpoint "\n请指定插入点: "))
(setq insertp_move (pmove insertp 0 -2))
(while (/= insertp nil)

   (command ".text" "j" "mc" insertp_move 0.6 0wz);;设置文字
   
    (setq
      n1   (+ n1 1)
      wz (strcat (itoa 3) (itoa -50) (itoa -411) "-" (itoa n1))
      insertp   (getpoint "\n请指定下一插入点: ")
      insertp_move (pmove insertp 0 -2)
    )
)
);end defun


(defun pmove(/point_xy px py);点位,X Y Z
    (setq point_x(car point_xy))
    (setq point_y(cadr point_xy))
    (list (+ point_xpx)(+ point_y py))
)


程序的功能 是输入3-50-411-1,3-50-411-2 。。。。。。。
捕捉线段的中点,在该点向下偏移2单位输入3-50-411-1
不知道哪里出错,请高手指教。(请指定插入点: ; 错误: 参数类型错误: numberp: nil)
还有怎么定义 wz (strcat (itoa 3) (itoa -50) (itoa -411) "-" (itoa n1))
可以直接写成 (setq wz (strcat3-50-411-(itoa n1)))

ljpnb 发表于 2011-7-9 20:55:54


(defun c:tt (/insertp n1 wz)
(if (not (setq n1 (getint "\n请输入起始顺序号 <1>: ")))
    (setq n1 1)
)
;;(setq wz (strcat (itoa 3) (itoa -50) (itoa -411) "-" (itoa n1)))
(setq wz (strcat "3-50-411-" (itoa n1)))
(setq insertp (getpoint "\n请指定插入点: "))
(setq insertp_move (pmove insertp 0 -2))
(while (/= insertp nil)
    (command ".text" "j" "mc" insertp_move 0.6 0 wz)
    ;;设置文字

    (setq
      n1           (+ n1 1)
      wz           (strcat "3-50-411-" (itoa n1))
      insertp           (getpoint "\n请指定下一插入点: ")
      insertp_move (pmove insertp 0 -2)
    )
)
)                                        ;end defun

(defun pmove (point_xy px py)                ;点位,X Y Z
(setq point_x (car point_xy))
(setq point_y (cadr point_xy))
(list (+ point_x px) (+ point_y py))
)

zhynt 发表于 2011-7-9 20:57:10

如果前面的字符串是固定的可以写成
(setq wz (strcat“3-50-411-"(itoa n1)))

zhb236623 发表于 2011-7-9 23:31:22

本帖最后由 zhb236623 于 2011-7-9 23:42 编辑

谢谢zhynt
发错地方多发了帖子,http://bbs.mjtd.com/forum.php?mo ... 01&page=1#pid472759,也谢谢gbhsu 帮忙解决。
页: [1]
查看完整版本: 求助,帮忙看下此程序哪里出错