明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3084|回复: 9

源码申请:增加记忆

[复制链接]
发表于 2012-4-21 13:16 | 显示全部楼层 |阅读模式
1明经币
本帖最后由 先进者 于 2012-4-21 13:33 编辑

因为工作中排料带的时候经常用到,所以请帮忙加个记忆,就在当前环境加记忆就好了,我对编程是个小白
  1. ;角度阵列程序;(2005.8.5胡晓航(Angle array routine),比AutoCAD的阵列容易得多。

  2. (defun C:AAR ( / ss ang bp cnt dist d)
  3. (PRINC "\n 角度阵列 ")
  4.   (cond
  5.     (  (setq ss (ssget))
  6.        (initget 1)
  7.        (setq bp (getpoint "\n基点: "))
  8.        (initget 1)
  9.        (setq ang
  10.            (getangle bp "\n阵列方向: "))
  11.          (initget 7)
  12.          (setq dist
  13.            (getdist "\n对象间距: "))
  14.          (initget 7)
  15.          (setq cnt (getint "\n对象个数: "))
  16.          (setq d 0.0)
  17.          (setvar "cmdecho" 0)
  18.          (command "_.undo" "_g"
  19.                   "_.copy" ss "" "_m" bp)
  20.          (repeat (1- cnt)
  21.            (command
  22.                (polar bp ang (setq d (+ d dist)))))
  23.                (command "" "_.undo" "_e")
  24.         )
  25.       )
  26.       (princ)
  27. )

发表于 2012-4-21 13:16 | 显示全部楼层


  1. ;* UANGLE User interface angle function
  2. ;* BIT (1 for no null, 0 for none) and KWD key word ("" for none) are same as
  3. ;* for INITGET. MSG is the prompt string, to which a default real in rads is
  4. ;* added as <DEF> (nil for none), and a : is added. BPT is base point (nil for none).
  5. ;*
  6. (defun uangle (bit kwd msg def bpt / inp)
  7.   (if def
  8.     (setq msg (strcat "\n >> " msg " < " (angtos def) " >: ")
  9.           bit (* 2 (fix (/ bit 2)))
  10.     )
  11.     (if (= " " (substr msg (strlen msg) 1))            ;no def, if last char is space
  12.       (setq msg (strcat "\n >> " (substr msg 1 (1- (strlen msg))) " : ")) ;then strip space
  13.       (setq msg (strcat "\n >> " msg " : "))                ;else msg OK
  14.   ) );if,if
  15.   (initget bit kwd)
  16.   (setq inp
  17.     (if bpt
  18.       (getangle msg bpt)
  19.       (getangle msg)
  20.   ) )
  21.   (if inp inp def)
  22. );defun

  23. ;* UINT User interface integer function
  24. ;* BIT (0 for none) and KWD key word ("" for none) are same as for INITGET.
  25. ;* MSG is the prompt string, to which a default integer is added as <DEF> (nil
  26. ;* for none), and a : is added.
  27. ;*
  28. (defun uint (bit kwd msg def / inp)
  29.   (if def                                                 ;test for a default
  30.     (setq msg (strcat "\n >> " msg " < " (itoa def) " >: ")      ;string'em with default
  31.          bit (* 2 (fix (/ bit 2)))  ;a default and no null bit code conflict so
  32.     )                               ;this reduces bit by 1 if odd, to allow null
  33.     (if (= " " (substr msg (strlen msg) 1))            ;no def, if last char is space
  34.       (setq msg (strcat "\n >> " (substr msg 1 (1- (strlen msg))) " : ")) ;then strip space
  35.       (setq msg (strcat "\n >> " msg " : "))                ;else msg OK
  36.   ) );if,if
  37.   (initget bit kwd)
  38.   (setq inp (getint msg))       ;use the GETINT function
  39.   (if inp inp def)              ;compare the results, return appropriate value
  40. );defun

  41. ;* UDIST User interface distance function
  42. ;* BIT (0 for none) and KWD key word ("" for none) are same as for INITGET.
  43. ;* MSG is the prompt string, to which a default real is added as <DEF> (nil
  44. ;* for none), and a : is added. BPT is base point (nil for none).
  45. ;*
  46. (defun udist (bit kwd msg def bpt / inp)
  47.   (if def                                              ;test for a default
  48.     (setq msg (strcat "\n >> " msg " < " (rtos def) " >: ")   ;string'em  with default
  49.           bit (* 2 (fix (/ bit 2))) ;a default and no null bit code conflict so
  50.     );setq                          ;this reduces bit by 1 if odd, to allow null
  51.     (if (= " " (substr msg (strlen msg) 1))            ;no def, if last char is space
  52.       (setq msg (strcat "\n >> " (substr msg 1 (1- (strlen msg))) " : ")) ;then strip space
  53.       (setq msg (strcat "\n >> " msg " : "))                ;else msg OK
  54.   ) );if,if
  55.   (initget bit kwd)
  56.   (setq inp
  57.     (if bpt                  ;check for a base point
  58.       (getdist msg bpt)      ;and use it in the GET vl-cmdfs
  59.       (getdist msg)
  60.   ) );setq&if
  61.   (if inp inp def)           ;compare the results, return appropriate value
  62. );defun

  63. (defun C:AAR (/ ss ang bp cnt dist d)
  64.   (PRINC "\n 角度阵列 ")
  65.   (cond
  66.     ((setq ss (ssget))
  67.      (initget 1)
  68.      (setq bp (getpoint "\n基点: ")
  69.            ang (uangle 1 "" "阵列方向" *Ang* bp)
  70.           dist (udist 7 "" "对像间距" *Dist* bp)
  71.            cnt (uint 7 "" "对像个数" *Cnt*)

  72.          *Ang* ang
  73.         *Dist* dist
  74.          *Cnt* cnt
  75.              d 0.0
  76.      )
  77.      (setvar "cmdecho" 0)
  78.      (command "_.undo" "_g" "_.copy" ss "" "_m" bp)
  79.      (repeat (1- cnt)
  80.        (command
  81.          (polar bp ang (setq d (+ d dist)))
  82.        )
  83.      )
  84.      (command "" "_.undo" "_e")
  85.     )
  86.   )
  87.   (princ)
  88. )

点评

试用的非常好,暂没发现问题,谢谢  发表于 2012-4-24 11:29
回复

使用道具 举报

发表于 2012-4-21 15:28 | 显示全部楼层
记忆什么?说清楚
回复

使用道具 举报

 楼主| 发表于 2012-4-24 14:52 | 显示全部楼层
本帖最后由 先进者 于 2012-4-24 15:13 编辑
Andyhon 发表于 2012-4-21 13:16


使用中发现一个问题,,我输入的对象间距与实际不一样,阵列方向本来是水平方向,实际阵列出来的不对,请修改一下好吗


遇到了一个很奇怪的事情,同样的图元,有时候阵列有问题,有时候阵列没有问题,

怎么会有这样的问题出现,请大师找下原因
回复

使用道具 举报

发表于 2012-4-24 15:54 | 显示全部楼层
查是否設有UCS且在使用中
回复

使用道具 举报

 楼主| 发表于 2012-4-24 17:32 | 显示全部楼层
我基本上可以确定没有动过UCS
以前就有这个问题,
在没加记忆以前用源程序的时候,会出现最靠近源图的那个图元与源图位置不对,
其他图元位置相对源图位置是对的,很奇怪,,,,,
这个问题遇到了好几次了,现在都不怎么敢用快速阵列了,
呵呵,万一哪天忘检查了,肯定死的很惨
回复

使用道具 举报

发表于 2012-4-24 20:16 | 显示全部楼层
另一个猜想...
关掉捕捉再试
若还不行请上传样本文件(*.Dwg)以利查验
回复

使用道具 举报

发表于 2012-5-3 09:11 | 显示全部楼层
非常好用,谢谢
回复

使用道具 举报

 楼主| 发表于 2012-5-4 11:16 | 显示全部楼层
这个问题别浪费您的时间了
回复

使用道具 举报

发表于 2012-10-26 16:25 | 显示全部楼层
I don't understand .
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-1 06:32 , Processed in 0.507409 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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