明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1808|回复: 2

帮帮我吧!!

[复制链接]
发表于 2002-7-12 12:54 | 显示全部楼层 |阅读模式
帮帮我吧!!
我在网上寻到一在AutoCAD绘装配图时标序号的Lisp程序,但在AutoCAD中加载时提示程序错误;我不懂编程,那位大虾能帮我一把!,这程序错在哪儿?BXH.LSP源程序如下:
;---------------------------

 (defun C:Bxh (/ p1 p2 p3 1 ang 1 bx bxh radi txth) ;标序号

  (setq radi 5) ;圆圈半径

  (setq txth 5) ;字高

  (if (not bx) (setq bx 1))

  (setq p1 (getpoint "\n请选择起点:")) ;在零件上选一点

  (setq p2 (getpoint "\n请选择第二点或回车表示无第二点")) ;标注位置处一点

  (setq bxh (getint (gstr "\n请输入序号" bx))) ;序号数

  (if bxh (setq bx bxh))

  (cond (p2

   (command "layer" "set" 2 " ") ;改到画细线图层

   (setq ang 1 (angle p1 p2))

   (setq p3 (polar p1 ang (-(distance p1 p2) radi))) ;画圆、线

   (command "pline"

   (polar p1 ang 1 0.25)

   "w" 0.5 0,5 "A" "CE"p1"A"359.9"L""W"0 0 p3"")

   (command"circle"p2 radi)

   (command "layer" "set" 6 " " ;改到写文字图层

   "text" "J" "M" p2 txth 0 bx) ;写文字

  )

   ((not p2) ;如果在零件中直接标注

   (command "layer" "set" 2 " ") ;改到画细线图层

   (Command "circle" p1 radi) ;画圆

   (command "layer" "set" 6 " " ;改到写文字图层

   "text" "J" "M" p1 txth 0 bx) ;写文字

   )

  )

  (setq bx (+ bx 1))

  (princ)

 )

  ;-----------------------
 楼主| 发表于 2002-7-15 13:40 | 显示全部楼层

谢谢!!我知足了。

发表于 2002-7-12 20:31 | 显示全部楼层

只是改到可用,但该程序还是需要很多改进

(defun C:Bxh (/ p1 p2 p3  ang  bx bxh radi txth) ;标序号
  (setq radi 5) ;圆圈半径
  (setq txth 5) ;字高
  (if (not bx)
       (setq bx 1)
       (setq bx (+ bx 1))
    )
  (setq p1 (getpoint "\n请选择起点:")) ;在零件上选一点
  (setq p2 (getpoint "\n请选择第二点或回车表示无第二点")) ;标注位置处一点
  (setq bxh (getint (strcat "\n请输入序号<" (itoa bx) ">:"))) ;序号数
  (if bxh (setq bx bxh))
  (cond (p2
   (command "layer" "set" "2" "") ;改到画细线图层
   (setq ang  (angle p1 p2))
   (setq p3 (polar p1 ang (-(distance p1 p2) radi))) ;画圆、线
   (command "pline"
   (polar p1 ang  0.25)
   "w" "0.5" "0.5" "A" "CE"p1"A""359.9""L""W""0" "0" p3"")
   (command"circle"p2 radi)
   (command "layer" "set" "6" "" ;改到写文字图层
   "text" "J" "M" p2 txth 0 bx) ;写文字
  )
   ((not p2) ;如果在零件中直接标注
   (command "layer" "set" "2" "") ;改到画细线图层
   (Command "circle" p1 radi) ;画圆
   (command "layer" "set" "6" "" ;改到写文字图层
   "text" "J" "M" p1 txth "0" bx) ;写文字
   )
  )
  (setq bx (+ bx 1))
  (princ)
 )
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-3-29 15:51 , Processed in 0.197622 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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