明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1887|回复: 5

如何实现这个效果?请高手指教

[复制链接]
发表于 2005-11-27 18:57 | 显示全部楼层 |阅读模式

问题1:画直线命令选择第二点时有一条橡皮筋,我的问题是我想画双线条,宽度是用户指定的,如何实现选择第二点时有两条橡皮筋?

问题2:和第一个问题类似,比如我在一水平直线附近绘制一个三角形,当鼠标移动到直线上时,三角形的尖头朝上;当鼠标移动到直线下时,三角形尖头朝下。我想要的效果是随着鼠标在直线上的上下移动,我能够动态的看到三角形尖头方向变化的效果。

 楼主| 发表于 2005-11-27 20:51 | 显示全部楼层

没人知道?不会吧

发表于 2005-11-28 08:46 | 显示全部楼层
需要用GRREAD函数,剩下的你可以慢慢考虑。
发表于 2005-11-28 08:48 | 显示全部楼层

1.命令:mline

2.随便画一个三角形,再用鼠标拖着某个顶点跑就可以了

发表于 2005-11-28 11:55 | 显示全部楼层

用了反应器,感觉不怎么好,双击结束第二点输入

(defun c:qq (/ P1 p2 curp w)
  (vlr-remove-all :vlr-Mouse-reactor)
  (setq Vlr_MouseDClick (vlr-Mouse-reactor nil '((:vlr-beginDoubleclick . MouseDClick))))
  (setq 1   (getpoint "\nFirst Point :")
 p2   nil
 curp nil
 w    3.0
  )
  (while (and (not p2) (= 5 (car (grread t 4 2))))
    (setq curp (cadr (grread t 4 2)))
    (if (= (type Curp) 'List)
      (progn
 (if (and Curp0 (= (type Curp0) 'List) (/= curp Curp0))
   (progn
     (grdraw P1 Curp0 (atoi (getenv "Background")))
     (grdraw P31 p32 (atoi (getenv "Background")))
   )
 )
 (if (= (type Curp) 'List)
   (progn
     (setq ang1 (+ (* 0.5 pi) (angle curp P1)))
     (setq p31 (polar p1 ang1 w)
    p32 (polar curp ang1 w)
     )
     (grdraw P1 curp 2)
     (grdraw P31 p32 2)
   )
 )
 (setq Curp0 curp)
      )
    )
  )
  (if p2
    (progn
      (vl-cmdf "Line" P1 p2 "")
      (vl-cmdf "Line" (polar p1 ang1 w) (polar p2 ang1 w) "")
    )
  )
  (vlr-remove Vlr_MouseDClick)
)
;;;;;;;;;;;;;;;;
(defun MouseDClick (Param1 Param2 /)
  (setq p2 (car Param2))
)

发表于 2005-12-1 15:50 | 显示全部楼层
本帖最后由 作者 于 2005-12-5 10:22:29 编辑

做了修改,不用反映器,左键点击结束

(defun c:qq (/ P1 p2 curp curp0 w P31 p32)
  (setq 1    (getpoint "\nFirst Point :")
 p2    nil
 curp  nil
 curp0 nil
 w     3.0
  )
  (setvar "Osmode" 0)
  (while (not p2)
    (IF (= (car (setq curp (grread t 4))) 5)
      (progn
 (setq curp (cadr curp))
 (if (and Curp0 (/= curp Curp0))
   (progn
     (grdraw P1 Curp0 0)
     (grdraw P31 p32 0)
   )
 )
 (setq ang1 (+ (* 0.5 pi) (angle curp P1)))
 (setq p31 (polar p1 ang1 w)
       p32 (polar curp ang1 w)
 )
 (grdraw P1 curp 256)
 (grdraw P31 p32 256)
 (setq Curp0 curp)
      )
      (IF (= (car curp) 3)
 (setq p2 (cadr curp))
      )
    )
  )
  (if p2
    (progn
      (grdraw P1 p2 0)
      (grdraw (polar p1 ang1 w) (polar p2 ang1 w) 0)
      (vl-cmdf "Line" P1 p2 "")
      (vl-cmdf "Line" (polar p1 ang1 w) (polar p2 ang1 w) "")
    )
  )
  (setvar "Osmode" 16383)
  (princ)
)

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

本版积分规则

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

GMT+8, 2024-5-3 05:01 , Processed in 0.986820 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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