qfkxc 发表于 2011-9-11 16:56:31

作中垂线

; 作中垂线
(defun c:ZCX( / )
(setq en1 (entsel "\n Select Line: "))
(setq ent1 (car en1))
(setq p1 (cadr en1))

(command "-array" ent1 "" "p"
   (osnap p1 "mid") 2 90 "")
(princ)
)

caoyin 发表于 2011-9-11 19:00:08

有很多更好的方法的时候,command和osnap不推荐使用

leono 发表于 2011-9-11 19:01:56

谢谢。。。。。。

qfkxc 发表于 2011-9-11 19:42:30

多谢版主指点

leono 发表于 2011-9-11 19:49:48

caoyin 发表于 2011-9-11 19:00 static/image/common/back.gif
有很多更好的方法的时候,command和osnap不推荐使用

版主能说说吗。是有什么VLISP函数可以用吗

caoyin 发表于 2011-9-11 20:54:48

;;AutoLISP 就可轻松实现:
;;----------------------------------------------------------------------
(defun C:ZCX (/ ENT P1 P2 MP AN DI)
(setq ENT (entsel "\n选择直线:")
      ENT (entget (car ENT))
      P1(cdr (assoc 10 ENT))
      P2(cdr (assoc 11 ENT))
      MP(mapcar '(lambda (X Y) (/ (+ X Y) 2.)) P1 P2)
      AN(+ (angle P1 P2) (/ PI 2.))
      DI(/ (distance P1 P2) 2.)
)
(entmake (list '(0 . "LINE")
               (cons 10 (polar MP AN DI))
               (cons 11 (polar MP AN (- DI)))
))
)

leono 发表于 2011-9-11 21:00:53

caoyin 发表于 2011-9-11 20:54 static/image/common/back.gif
;;AutoLISP 就可轻松实现:
;;----------------------------------------------------------------------
...

谢谢版主,能帮我看看这个吗?
http://bbs.mjtd.com/thread-89299-1-1.html

caoyin 发表于 2011-9-11 21:04:26

;;AutoLISP 就可轻松实现:
;;----------------------------------------------------------------------
(defun C:ZCX (/ ENT P1 P2 MP AN DI)
(setq ENT (entsel "\n选择直线:")
      ENT (entget (car ENT))
      P1(cdr (assoc 10 ENT))
      P2(cdr (assoc 11 ENT))
      MP(mapcar '(lambda (X Y) (/ (+ X Y) 2.)) P1 P2)
      AN(+ (angle P1 P2) (/ PI 2.))
      DI(/ (distance P1 P2) 2.)
)
(entmake (list '(0 . "LINE")
               (cons 10 (polar MP AN DI))
               (cons 11 (polar MP AN (- DI)))
))
)

自贡黄明儒 发表于 2012-2-3 15:20:11

caoyin 发表于 2011-9-11 21:04 static/image/common/back.gif
;;AutoLISP 就可轻松实现:
;;----------------------------------------------------------------------
...

(setq ENT (entsel "\n选择块中曲线:"))时,请问怎么办呢?

caoyin 发表于 2012-2-3 19:30:31

本帖最后由 caoyin 于 2012-2-3 19:30 编辑

;;;做任意曲线的垂线
(defun C:TT (/ curve point ang)
(setq curve (entsel "\n选择任意曲线: "))
(mapcar 'set '(curve point) curve)
(setq point (vlax-curve-getClosestPointTo curve point)
      ang   (angle '(0 0)
                     (vlax-curve-getFirstDeriv
                     curve
                     (vlax-curve-getParamAtPoint curve point)
                     )
            )
      ang   (+ ang (/ pi 2))
)
(command "_.xline" "_non" point "_non" (polar point ang 10) "")
)
页: [1] 2
查看完整版本: 作中垂线