明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1412|回复: 7

[提问] 此程序有点小问题,大师们能帮忙修正吗?

[复制链接]
发表于 2014-3-4 15:25 | 显示全部楼层 |阅读模式
本帖最后由 lucas_3333 于 2014-3-4 15:43 编辑

不管命令是正确结束,还是错误,都会出现:
line 指定第一点:
命令: DDBRUSH 未知命令“DDBRUSH”。按 F1 查看帮助。
命令: nil

另外里面有个选项是“尺寸”不知道怎么用。
上传源文件,请大师们帮忙看看,问题出在哪?

本帖子中包含更多资源

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

x
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2014-3-4 18:38 | 显示全部楼层
考量这句呗
(command "line" '(0,0) "") ;此语句是为了回退(undo)的需要而编写,即一次只能回退一条操作。
发表于 2014-3-6 13:13 | 显示全部楼层
  1. 我还是给答案:(command "line" '(0 0) "")
发表于 2014-3-6 13:45 | 显示全部楼层
所谓尺寸,应该是指标注尺寸对象,可以将标注样式刷成一样,猜测。
  1. (defun c:ddbrush(/ sss ee leng n ss standard ok) ;本程序是类似于R14应用程序中经常用的格式刷的功能
  2. (setq sss (entsel "请输入要刷子原形") )
  3. (setq mother (entget (car sss)))
  4. (setq moname (cdr (assoc 0 mother)))
  5. (setq standard (list -3 '("ACAD" (1000 . "DSTYLE") (1002 . "{") (1002 . "}"))))

  6. (setq id (load_dialog (findfile "ddbrush.dcl")))
  7. (if (not (new_dialog "brush" id))
  8.         (exit)
  9. )


  10. (if (= jzxz 1) (init))
  11. (initl)
  12. ;--------------------
  13. (setq mc (assoc 8 mother) mx  (assoc 6 mother) my  (assoc 62 mother))
  14. (setq myy (cadr (assoc (cdr mc) nn1)) mxx (caddr (assoc (cdr mc) nn1)))
  15. ;--------------------------

  16. (setq ok 0)
  17. (action_tile "accept" "(do_set)(done_dialog 1)")
  18. (start_dialog)
  19. (unload_dialog id)
  20. (if (= ok 0) (exit))        ;如果取消就退出


  21. (prompt "请选择要修改的实体")
  22. (if (= qx 1) (setq ss (ssget "x")) (setq ss (ssget ) ))
  23. (print "请您耐心等待,程序正在处理......")
  24. (setq leng (sslength ss) n 0 str "")
  25. (repeat leng
  26.         (setq ee (ssname ss n))
  27.         (setq aa (entget ee))
  28.         (setq name (cdr (assoc 0 aa)))

  29. (setq yesno f)
  30. (if (and (= tt1 0) (= tt2 0) (= tt3 0) (= tt4 0)) (setq yesno t)
  31.         (progn
  32.         (setq tc (assoc 8 aa) tx  (assoc 6 aa) ty  (assoc 62 aa))
  33.         (setq tyy (cadr (assoc (cdr tc) nn1)) txx (caddr (assoc (cdr tc) nn1)))
  34.        

  35.         (setq ttt1 f)
  36.         (if (= tt1 0) (setq ttt1 t))
  37.         (if (and (not (= tt1 0)) (= (car (nth (1- tt1) nn1)) (cdr tc)))        (setq ttt1 t) );;处理层
  38.        

  39.        
  40.         (setq ttt2 f)
  41.         (if (= tt2 0) (setq ttt2 t)                                                        ;处理线型
  42.                 (if  (NULL tx)  
  43.                         ( if (= (nth (1- tt2) nn2) txx) (setq ttt2 t))
  44.                         (if (= (nth (1- tt2) nn2) (cdr tx)) (setq ttt2 t))
  45.                 )
  46.         )


  47.         (setq ttt3 f)                                                                        ;处理颜色
  48.         (if (= tt3 0) (setq ttt3 t)
  49.                 (if (NULL ty)
  50.                         ( if (= tt3  tyy) (setq ttt3 t))
  51.                         (if (= tt3 (cdr ty))  (setq ttt3  t))
  52.                 )
  53.         )

  54.        
  55.        
  56.         (setq ttt4 f)                                                                        ;处理实体
  57.         (if (= tt4 0) (setq ttt4 t)
  58.                 (if (= (nth (1- tt4) nn4) name) (setq ttt4 t))
  59.         )



  60.         (setq yesno (and ttt1 ttt2 ttt3 ttt4))
  61.        
  62.         );endprogn
  63. );endif


  64. (if (= yesno t)
  65.         (progn
  66. ( if (and (or (= moname "DIMEMSION") (= moname "CIRCLE") (= moname "ARC") (= moname "INSERT") (= moname "LINE") (= moname "PLINE")  (= moname "LEADER"))
  67.           (or (= name "DIMEMSION") (= name "INSERT") (= name "LINE")  (= name "CIRCLE") (= name "ARC") (= name "PLINE")  (= name "LEADER")))
  68.         (progn
  69.         (if (= xx 1) (myreplace 6))                                                        ;线型
  70.         (if (= xxbl 1) (myreplace 48))                                                        ;线型比例
  71.         );ENDPROGN
  72. )        ;ENDIF
  73.        


  74. (if (and (or (= name "TEXT") (= name "MTEXT") (= name "ATTDEF")) (or (= moname "TEXT") (= moname "MTEXT") (= moname "ATTDEF")))
  75.         (progn
  76.         (if (= wzlx 1) (myreplace 7))                                                          ;自设系统变量,如果sss不为空,一切字体类型都要更换
  77.        
  78.         (if (= zxbl 1) (if  (or (= moname "MTEXT") (= name "MTEXT")) ()        (myreplace 41)));字宽比
  79.         (if (= zg 1) (myreplace 40))                                                        ;字高
  80.        
  81.         (if (= ztjd 1) (myreplace 50))                                                        ;逆时针弧度值
  82.         (if (= ztjd 1) (myreplace 51))                                                        ;斜体斜角弧度值
  83.         );;endprogn
  84. );;endif       

  85. (if (and (or (= name "TEXT") (= name "MTEXT") (= name "DIMENSION")) (or (= moname "TEXT") (= moname "MTEXT") (= moname "DIMENSION")))
  86.         (if (= wznr 1) (myreplace 1))                                                        ;文字内容
  87. )

  88. ;;;以下两项为专属修改
  89. (if (and (= moname "DIMENSION") (= "DIMENSION" name))
  90.         (if (= cc 1)
  91.                 (progn
  92.                 (modim)
  93.                 (myreplace 3)                                                                ;改变尺寸的标注风格
  94.                 )                                                                         ;改变尺寸
  95.         )
  96. )       

  97. (if (and (= moname "SOLID") (= name "SOLID") (= jt 1)) (mysol))                                ;改变箭头的大小
  98.        
  99. (if (and (or (= moname "CIRCLE") (= moname "ARC")) (or (= name "CIRCLE") (= name "ARC")) (= bj 1)) (myreplace 40))  ;半径

  100. ;;;以下两项为基本属性修改
  101.         (if (= c 1) (myreplace 8))                ;层
  102.         (if (= yc 1) (myreplace 62))                ;颜色
  103.         );;;;endprogn
  104. );;;;;endif


  105.    
  106. (setq n (1+ n))
  107. )        ;endrep

  108. (setq ss nil)
  109. (princ "\n请尊重原作者的辛勤劳动,同时,如果您愿意请为非洲贫困儿童献一份爱心!\n您在使用本程序时如有问题,请与huihl@netease.com联系!\n")
  110. (command "line" '(0 0) "")                ;此语句是为了回退(undo)的需要而编写,即一次只能回退一条操作。


  111. )        ;endfun

  112. (defun modim( / exmo exmo3 exch)

  113. (setq exmo (entget (car sss) '("ACAD")))
  114. (setq exmo3 (assoc -3 exmo))
  115. (setq exch (entget ee '("ACAD")))
  116. (setq exch3 (assoc -3 exch))
  117. (princ "\nsecond\n\n")
  118. (princ exch)
  119. (princ "\n\n first\n")
  120. (princ exmo3)
  121.   ;;判断标注对象的样式是否是替换样式
  122.   (cond
  123.     ((and exmo3 exch3) (setq exch (subst exmo3 (assoc -3 exch) exch)))
  124.     ((and exmo3 (not exch3))(setq exch (append exch (list  exmo3))))
  125.     ((and (not exmo3) exch3) (setq  exch (subst standard (assoc -3 exch) exch)))
  126.     )
  127. ;;;(if (not (or (NULL (assoc -3 exch)) (NULL exmo3))) (setq exch (subst exmo3 (assoc -3 exch) exch)))
  128. ;;;(if (NULL (assoc -3 exch))  (setq exch (append exch (list  exmo3))))
  129. ;;;(if (NULL exmo3) (setq  exch (subst standard (assoc -3 exch) exch)))


  130. (princ "\n\nstart newsecond\n")
  131. (princ exch)
  132. (princ "\n\nend\n")
  133. (entmod exch)
  134. )


  135. (defun myreplace(attrib / variey1 variey2 variety xxxx yyyy)

  136. (if (NULL variey1) (setq variey1  (assoc attrib aa)))
  137. (setq variey2 (cdr (assoc attrib mother)))
  138. (if (NULL variey2) (setq variey2  (assoc attrib mother)))


  139. (if (and (not (null variey1)) (not (null variey2)))           
  140.                         (progn (setq aa
  141.                               (subst (cons attrib variey2) (assoc                         attrib aa) aa)) (entmod aa))                )                ;endif母有子有,即母子属性不随层
  142.        

  143.                
  144. (if (and  (null variey1) (not (null variey2)) ) (setq aa (append aa                         (list  (assoc attrib mother))))
  145. )  ;endif母有子没有,即母属性不随层,但子属性随层

  146. ;以下,母没有子有,即母属性随层,但子属性不随层,分三种情况。。。。。(不知何故cond总是有问题,故用三个if的拙法完

  147. (if (= scjd 1) (setq xxxx mxx yyyy myy) (setq xxxx "BYLAYER" yyyy 256))  ;用于色层绝对

  148. (if (and (not (null variey1)) (null variey2) (= attrib 6)) (setq aa   (subst (cons attrib xxxx) (assoc attrib aa) aa)) )                ;线型

  149. (if  (and (not (null variey1)) (null variey2) (= attrib 62)) (setq aa   (subst (cons attrib yyyy) (assoc attrib aa) aa)))                ;颜色,注:随层为256;随块为0


  150. ;;以下是母子都没有的情况
  151. (if (and (null variey1) (null variey2) (= attrib 6))  (setq aa (append aa (list  (cons attrib xxxx))))        )
  152. (if (and (null variey1) (null variey2) (= attrib 62))  (setq aa (append aa (list  (cons attrib yyyy))))        )



  153. (if (and (not (null variey1)) (null variey2)  (= attrib 48 )) (progn (setq aa   (subst (cons attrib 1) (assoc attrib aa) aa)) (princ "ok") (princ aa)))                ;线型比例
  154. (entmod aa)
  155. )  ;endsubfun


  156. (defun mysol(/ ll pt0 pt1)                                                   ;该函数用于修改箭头的大小
  157. (setq ll (distance (cdr (assoc 10 mother)) (cdr (assoc 13 mother))))
  158.                 (setq pt0 (cdr (assoc 10 aa)) pt1 (cdr (assoc 11  aa)) pt3 (cdr (assoc 13  aa)))
  159.                 (setq rate (/ ll (distance pt0 pt3)))
  160.                 (setq pt0 (snpt pt3 pt0 rate) pt1 (snpt pt3 pt1 rate))               
  161.                 (setq aa                
  162.                         (subst (cons 10 pt0) (assoc 10 aa) aa)
  163.                 )   
  164.                 (setq aa                
  165.                         (subst (cons 11 pt1) (assoc 11 aa) aa)
  166.                 )   

  167.         (entmod aa)
  168. )

  169. (defun snpt(p1 p2 rate / sx1 sx2 sx3 sy1 sy2 sy3 )
  170. (setq sx1 (car p1) sy1 (cadr p1) sx2 (car p2) sy2 (cadr p2))
  171. (setq sx3 (+ (* rate (- sx2 sx1)) sx1) )
  172. (setq sy3 (+ (* rate (- sy2 sy1)) sy1) )
  173. (list sx3 sy3 0.0)
  174. )

  175. (defun do_set(/ n)
  176. (setq sf (atoi (get_tile "sf")))
  177. (setq jzxz (atoi (get_tile "jzxz")))

  178. (if (= sf 1) (setq n 1) (setq n 0))

  179. (setq xx (+ (atoi (get_tile "xx")) n))
  180. (setq xxbl (+ (atoi (get_tile "xxbl")) n))
  181. (setq yc (+ (atoi (get_tile "yc")) n))
  182. (setq wzlx (+ (atoi (get_tile "wzlx")) n))
  183. (setq  zg (+ (atoi (get_tile "zg")) n))
  184. (setq zxbl (+ (atoi (get_tile "zxbl")) n))
  185. (setq wznr (+ (atoi (get_tile "wznr")) n))

  186. (setq cc (+ (atoi (get_tile "cc")) n))
  187. (setq c (+ (atoi (get_tile "c")) n))
  188. (setq jt (+ (atoi (get_tile "jt")) n))
  189. (setq ztjd (+ (atoi (get_tile "ztjd")) n))
  190. (setq bj (+ (atoi (get_tile "bj")) n))
  191. (setq scjd (+ (atoi (get_tile "scjd")) n))

  192. (setq tt1 (atoi (get_tile "tt1")))
  193. (setq tt2 (atoi (get_tile "tt2")))
  194. (setq tt3 (atoi (get_tile "tt3")))
  195. (setq tt4 (atoi (get_tile "tt4")))

  196. (setq qx (atoi (get_tile "qx")))
  197. (setq ok 1)

  198. )

  199. (defun init()

  200. (set_tile "jzxz" (itoa jzxz))
  201. (if (= sf 1) (setq n 1) (setq n 0))
  202. (set_tile "sf" (itoa sf))
  203. (set_tile "xx" (itoa (- xx n)))
  204. (set_tile "xxbl" (itoa (- xxbl n)))
  205. (set_tile "yc" (itoa (- yc n)))
  206. (set_tile "wzlx" (itoa (- wzlx n)))
  207. (set_tile "zg" (itoa (- zg n)))
  208. (set_tile "zxbl" (itoa (- zxbl n)))
  209. (set_tile "wznr" (itoa (- wznr n)))

  210. (set_tile "cc" (itoa (- cc n)))
  211. (set_tile "c" (itoa (- c n)))
  212. (set_tile "jt" (itoa (- jt n)))
  213. (set_tile "ztjd" (itoa (- ztjd n)))
  214. (set_tile "bj" (itoa (- bj n)))
  215. (set_tile "scjd" (itoa (- scjd n)))

  216. (set_tile "qx" (itoa qx))
  217. )

  218. (defun initl()
  219. (setq nn1 '() nn2 '() nn3 '() nn4 '("LINE" "PLINE" "CIRCLE" "ARC" "TEXT" "MTEXT" "ATTDEF" "DIMENSION" "INSERT" "SOLID") n 0)
  220. (start_list "tt1" 3)
  221. (add_list "过滤层(不过滤)")
  222. (setq blk (tblnext "LAYER" 1))

  223. (while (not (NULL blk))
  224. (setq n (1+ n))
  225. (setq tname (cdr (nth 1 blk)))
  226. (setq nn1 (append nn1 (list (list  tname (cdr (nth 3 blk)) (cdr (nth 4 blk))))))
  227. (add_list tname)
  228. (setq blk (tblnext "LAYER" NIL))
  229. )
  230. (end_list)


  231. (start_list "tt2" 3)
  232. (add_list "过滤线型(不过滤)")
  233. (setq blk (tblnext "LTYPE" 1))
  234. (while (not (NULL blk))
  235. (setq tname (cdr (nth 1 blk)))
  236. (setq nn2 (append nn2 (list  tname)))
  237. (add_list tname)
  238. (setq blk (tblnext "LTYPE" NIL))

  239. )
  240. (end_list)

  241. (start_list "tt3" 3)
  242. (add_list "过滤颜色(不过滤)")
  243. (setq n 0)
  244. (repeat 255
  245. (setq n (1+ n))
  246. (add_list (itoa n))
  247. )
  248. (end_list)

  249. (start_list "tt4" 3)
  250. (add_list "过滤实体(不过滤)")
  251. (setq n 0)
  252. (setq len (length nn4))
  253. (repeat len

  254. (add_list (nth n nn4))
  255. (setq n (1+ n))
  256. )
  257. (end_list)

  258. )

评分

参与人数 2明经币 +2 收起 理由
lucas_3333 + 1 E大,再帮忙修复!代表论坛朋友们感谢你了
liuhaixin88 + 1 乐于助人!赞!

查看全部评分

 楼主| 发表于 2014-3-6 21:43 | 显示全部楼层
本帖最后由 lucas_3333 于 2014-3-6 21:47 编辑
edata 发表于 2014-3-6 13:45
所谓尺寸,应该是指标注尺寸对象,可以将标注样式刷成一样,猜测。

E大,谢谢你的修改,我还发现几个问题,如下:
1.线型与线型比例,不能将LINE的线型与线型比例刷到多段线PL上,PL线的同样不能刷到L线上,但是颜色可以
2.字型比例,只能在单行文字之间刷,多行文字之间不行,单行文字刷到多行文字不行,多行文字刷到单行文字不行,但是文字内容可以相互刷。
3.“箭头散”与“色,层绝对” 不知道有何用?没试出效果
3.下方的 “反向选择”好像也没有什么作用。

请E大再帮忙审查一下
 楼主| 发表于 2014-3-8 19:03 | 显示全部楼层
lucas_3333 发表于 2014-3-6 21:43
E大,谢谢你的修改,我还发现几个问题,如下:
1.线型与线型比例,不能将LINE的线型与线型比例刷到多段线 ...

请E大帮忙看一看
 楼主| 发表于 2014-3-10 21:25 | 显示全部楼层
没人解答?请问“箭头散”与“色,层绝对” 是怎么回事?
 楼主| 发表于 2014-3-15 13:55 | 显示全部楼层
改不改没关系,请高手说说 “箭头散”与“色,层绝对” 是怎么回事?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-19 07:25 , Processed in 0.215275 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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