kwok 发表于 2012-9-7 23:02
赞同,cad把简单事弄复杂化了,,,,,,,,
;;;先选目标三个点,再点目标三个点,似乎解决了鼠标移来移去的问题,但
;;;使用起来不方便.Autocad设计的align的点取顺序,还是很道理的.
;;;自贡黄明儒:H版的这个程序,可以演绎出许多我们自己需要的程序
- ;;;先选目标三个点,再点目标三个点,似乎解决了鼠标移来移去的问题,但
- ;;;使用起来不方便.Autocad设计的align的点取顺序,还是很道理的.
- ;;;自贡黄明儒:H版的这个程序,可以演绎出许多我们自己需要的程序
- ;;;-----------------------------------------------------------;;
- ;;; 三点维的平齐命令,山寨Express Tools的align ;;
- ;;; 命令:Align3d ,可自己修改 ;;
- ;;; Author: Highflybird, Date:2012-8-6. ;;
- ;;; All copyrights reserved. ;;
- ;;;-----------------------------------------------------------;;
- (defun C:Align3d (/ sel sP1 sP2 sP3 dP1 dP2 dP3 sclp
- scl mat0 mat1 mat2 mat i ent obj app
- doc pt
- )
- (setvar "cmdecho" 0)
- (if (setq sel (ssget))
- (progn
- (initget 9)
- (setq sP1 (getpoint "\n 指定第一个源点:"))
- (initget 9)
- (princ "\n 指定第一个目标点:")
- (command "_.move" sel "" sP1 pause)
- (setq dP1 (getvar "lastpoint"))
- (setq pt (mapcar '- dP1 sP1))
- (initget 9)
- (setq sP2 (getpoint "\n 指定第二个源点:"))
- (initget 9)
- (setq dP2 (getpoint sP2 "\n 指定第二个目标点:"))
- (setq sP2 (mapcar '- sP2 pt))
- (initget 8)
- (setq sP3 (getpoint "\n 指定第三个源点或 <继续>:"))
- (if (null sP3)
- (progn
- (setq sP3 (Mat:Rotate90 sP2 sP1))
- (setq dP3 (Mat:Rotate90 dP2 dP1))
- )
- (progn
- (initget 9)
- (progn
- (setq dP3 (getpoint sP3 "\n 指定第三个目标点:"))
- (setq sP3 (mapcar '- sP3 pt))
- )
- )
- )
- (foreach x '(sP1 sP2 sP3 dP1 dP2 dP3)
- (set x (trans (eval x) 1 0))
- )
- (initget "Yes No")
- (setq sclp
- (getkword "\n 是否基于对齐点缩放对象?[是(Y)/否(N)] <否>:")
- )
- (command "_.move" sel "" dP1 sP1)
- (setq mat1 (Mat:Get3PMatrix sP1 sP2 sP3))
- (setq mat2 (Mat:Get3PMatrix dP1 dP2 dP3))
- (if (= "Yes" sclp)
- (setq scl (/ (distance dP1 dP2) (distance sP2 sP1))
- mat0 (list (list scl 0 0 0)
- (list 0 scl 0 0)
- (list 0 0 scl 0)
- '(0 0 0 1)
- )
- mat (Mat:mxm (cadr mat2) (Mat:mxm mat0 (car mat1)))
- )
- (setq mat (Mat:mxm (cadr mat2) (car mat1)))
- )
- (setq app (vlax-get-acad-object))
- (setq doc (vla-get-ActiveDocument app))
- (vla-StartUndoMark doc)
- (setq i 0)
- (if sel
- (repeat (sslength sel)
- (setq ent (ssname sel i))
- (setq obj (vlax-ename->vla-object ent))
- (vla-transformby obj (vlax-tmatrix mat))
- (setq i (1+ i))
- )
- )
- (vla-EndUndoMark doc)
- (vlax-release-object doc)
- (vlax-release-object app)
- )
- )
- (princ)
- )
|