找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 844|回复: 2

[他山之石] Ghostbx

[复制链接]

已领礼包: 1268个

财富等级: 财源广进

发表于 2013-10-4 00:34:44 | 显示全部楼层 |阅读模式

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

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

×
  1. (defun ghostbx (inspnt cursor_type /)
  2.   (setq picked "")
  3.   ;; loop while user moves mouse - until point clicked
  4.   (while (/= picked 3)
  5.     (setq gr_read      (grread t 4 cursor_type)
  6.    picked       (car gr_read)
  7.    cursor_pnt   (cadr gr_read)
  8.    current_vecs (calc_vecs inspnt cursor_pnt)
  9.     )
  10.     ;; 'erase; the last vectors
  11.     (if last_vecs
  12.       (grvecs (list 0
  13.       inspnt
  14.       last_cursor_pnt
  15.       (nth 0 last_vecs)
  16.       (nth 1 last_vecs)
  17.       (nth 1 last_vecs)
  18.       (nth 2 last_vecs)
  19.       (nth 2 last_vecs)
  20.       (nth 3 last_vecs)
  21.       (nth 3 last_vecs)
  22.       (nth 4 last_vecs)
  23.       (nth 4 last_vecs)
  24.       (nth 0 last_vecs)
  25.        )
  26.       )
  27.     )
  28.     ;; 'draw' the current vectors
  29.     (if current_vecs
  30.       (grvecs (list 7
  31.       inspnt
  32.       cursor_pnt
  33.       (nth 0 current_vecs)
  34.       (nth 1 current_vecs)
  35.       (nth 1 current_vecs)
  36.       (nth 2 current_vecs)
  37.       (nth 2 current_vecs)
  38.       (nth 3 current_vecs)
  39.       (nth 3 current_vecs)
  40.       (nth 4 current_vecs)
  41.       (nth 4 current_vecs)
  42.       (nth 0 current_vecs)
  43.        )
  44.       )
  45.     )
  46.     (setq last_cursor_pnt cursor_pnt
  47.    last_vecs   (calc_vecs inspnt last_cursor_pnt)
  48.     )
  49.   )
  50.   ;; end while user drags the mouse
  51.   ;; 'erase' the remaining vectors
  52.   (grvecs (list 0
  53.   inspnt
  54.   last_cursor_pnt
  55.   (nth 0 last_vecs)
  56.   (nth 1 last_vecs)
  57.   (nth 1 last_vecs)
  58.   (nth 2 last_vecs)
  59.   (nth 2 last_vecs)
  60.   (nth 3 last_vecs)
  61.   (nth 3 last_vecs)
  62.   (nth 4 last_vecs)
  63.   (nth 4 last_vecs)
  64.   (nth 0 last_vecs)
  65.    )
  66.   )
  67.   last_vecs
  68.   ;; return the final vectors
  69. )
  70. (defun calc_vecs (cpnt ins_pnt / p1 p2 p3 p4)
  71.   ;; get the user angle and distance and adjust box length and width per
  72.   ;; the functionality desired
  73.   (cond ((= (type ins_pnt) 'list)
  74.   (setq cang (angle cpnt ins_pnt))
  75.   (setq box_len (distance ins_pnt cpnt))
  76.   (setq box_wid (cond ((< box_len 900) 150.0)
  77.         ((< box_len 3000) (* box_len 0.1667))
  78.         (t box_wid)
  79.          )
  80.   )
  81. )
  82.   )
  83.   ;; return the adjusted vectors accordingly
  84.   (list (setq p1 cpnt)
  85. (setq p2 (polar p1 cang box_len))
  86. (setq p3 (polar p2 (+ cang (* 0.5 pi)) box_wid))
  87. (setq p4 (polar p3 (- cang pi) box_len))
  88. (setq p5 p1)
  89.   )
  90. )
  91.      ; EOF
  92. ;;; setup to test the code
  93. (setq inspnt (getpoint "\nSelect first point: "))
  94. (setq pntlst (ghostbx inspnt 4)) ; run the test

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

已领礼包: 207个

财富等级: 日进斗金

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

使用道具 举报

已领礼包: 1268个

财富等级: 财源广进

 楼主| 发表于 2013-10-4 19:26:59 | 显示全部楼层
演示 Grdraw 应用, 给定基点,由基点模拟一个矩形, 另一点处由参数控制模拟光标或者选择模式的 小矩形, 或者无
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-4 01:23 , Processed in 0.319343 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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