明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1754|回复: 11

绘制垂线

[复制链接]
发表于 2020-7-27 08:51 | 显示全部楼层 |阅读模式
1明经币
这是论坛上一个绘制垂线的代码,可以选择垂足和垂线长度,但是只能往垂足的一边绘制,是否可以选择垂足后往两边绘制指定长度的垂线呀
  1. ;http://bbs.mjtd.com/forum.php?mod=viewthread&tid=169824&extra=&highlight=%B4%B9%CF%DF&page=2
  2. (defun c:CCX(/ e p d)
  3.   (setq d(getreal"垂线长度[500]"))
  4.   (setq d(if d d 500));;改长度
  5.   (while(setq e(car(entsel"\n拾取基准线")))
  6.     (while(setq p(getpoint"\n垂足位置"))
  7.       (entmakex(list'(0 . "line")(cons 10(setq p(vlax-curve-getclosestpointto e p)))
  8.                  (cons 11(polar p(+(angle p(mapcar'+(vlax-curve-getfirstDeriv e(vlax-curve-getParamAtPoint e p))p))(* pi 0.5))d))))
  9.     )
  10.    
  11.   )
  12.   (princ)
  13. )


最佳答案

查看完整内容

;画垂线cxx (defun c:CCX(/ e p d) (setq d (getreal "垂线长度[50]" )) (setq d(if d d 50)) ;;改长度 (while(setq e(car(entsel "\n拾取基准线"))) (while(setq p(getpoint "\n垂足位置")) (entmakex ( list'(0 . "line")(cons 10(setq p(vlax-curve-getclosestpointto e p))) (cons 11(polar p(+(angle p(mapcar'+(vlax-curve-getfirstDeriv e(vlax-curve-getParamAtPoint e p))p))(* ...
发表于 2020-7-27 08:51 | 显示全部楼层
;画垂线cxx
(defun c:CCX(/ e p d)
  (setq d (getreal "垂线长度[50]" ))
  (setq d(if d d 50))  ;;改长度
  (while(setq e(car(entsel "\n拾取基准线")))
    (while(setq p(getpoint "\n垂足位置"))
      (entmakex ( list'(0 . "line")(cons 10(setq p(vlax-curve-getclosestpointto e p)))
                 (cons 11(polar p(+(angle p(mapcar'+(vlax-curve-getfirstDeriv e(vlax-curve-getParamAtPoint e p))p))(* pi 0.5))d))  ))
          (entmakex ( list'(0 . "line")(cons 10(setq p(vlax-curve-getclosestpointto e p)))
                 (cons 11(polar p(-(angle p(mapcar'+(vlax-curve-getfirstDeriv e(vlax-curve-getParamAtPoint e p)) p))(* pi 0.5))d))  ))                 
    )
   
  )
  (princ)
)
回复

使用道具 举报

发表于 2020-7-28 13:31 | 显示全部楼层
不错不错,很好。
回复

使用道具 举报

发表于 2020-7-29 22:36 | 显示全部楼层
感谢楼主分享,收下了


                                   
回复

使用道具 举报

发表于 2020-7-29 22:40 | 显示全部楼层
感谢楼主分享,收下了
回复

使用道具 举报

发表于 2020-8-1 13:11 | 显示全部楼层
本帖最后由 sunny_8848 于 2020-8-1 13:32 编辑

解决了,win 10系统的问题
回复

使用道具 举报

发表于 2020-11-19 10:14 | 显示全部楼层
感谢楼主分享!!
回复

使用道具 举报

发表于 2021-2-22 11:39 | 显示全部楼层
zjy2999 发表于 2020-7-27 08:51
;画垂线cxx
(defun c:CCX(/ e p d)
  (setq d (getreal "垂线长度[50]" ))

程序真不错,学习了。
回复

使用道具 举报

发表于 2022-6-11 16:40 | 显示全部楼层
为啥我提示:输入的字符串有缺陷
回复

使用道具 举报

发表于 2022-6-15 11:48 | 显示全部楼层
zjy2999 发表于 2020-7-27 08:51
;画垂线cxx
(defun c:CCX(/ e p d)
  (setq d (getreal "垂线长度[50]" ))

怎么我复制到来用就不行呢?
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-2 17:52 , Processed in 3.911384 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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