明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2099|回复: 8

强力系列之三:增强型绘制圆柱断面线

[复制链接]
发表于 2011-11-23 16:32 | 显示全部楼层 |阅读模式
本帖最后由 luoguoqianga 于 2011-11-24 19:19 编辑



特别注意:本程序绿色非源码,下载需花1个明经币,看清楚才下载。

本帖子中包含更多资源

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

x
发表于 2011-11-23 16:48 | 显示全部楼层
又收币,贪财的家伙!!!
发表于 2011-11-23 18:12 | 显示全部楼层
这个应该不难哦,看看谁来模仿你了
发表于 2011-11-23 22:42 | 显示全部楼层
本帖最后由 sen.sam 于 2011-11-23 22:48 编辑

我来贴一个源码,支持圆弧,样条,不过不支持多段线,截断的形状跟选线的顺序有关,算是一个bug吧,因为现在工作没用到这种东西,也没去修改了,有心人可以完善一下

  1. (defun dra_line  (p1 p2 / pp)
  2.   (setq pp (mapcar '* (mapcar '+ p1 p2) '(0.5 0.5 0.5)))
  3.   (entmake (list '(0 . "LWPOLYLINE")
  4.      '(100 . "AcDbEntity")
  5.      '(100 . "AcDbPolyline")
  6.      '(90 . 4)
  7.      (cons 10 p1)
  8.      '(42 . 0.414214)
  9.      (cons 10 pp)
  10.      '(42 . -0.414214)
  11.      (cons 10 p2)
  12.      '(42 . -0.414214)
  13.      (cons 10 pp)
  14.      '(42 . -1.75126)
  15.      )
  16.   )
  17. )
  18. ;;支持所有曲线
  19. (defun c:yzjd ()
  20.   (vl-load-com)
  21.   (setq  enp1 (entsel)
  22.   en1  (car enp1)
  23.   p1   (cadr enp1)
  24.   )
  25.   (setq  enp2 (entsel)
  26.   en2  (car enp2)
  27.   p2   (cadr enp2)
  28.   )
  29.   (setq  p1 (vlax-curve-getClosestPointTo en1 p1 t)
  30.   p2 (vlax-curve-getClosestPointTo en2 p2 t)
  31.   )
  32.   (setq  p3 (vlax-curve-getClosestPointTo en2 p1 t)
  33.   p4 (vlax-curve-getClosestPointTo en1 p2 t)
  34.   )
  35.   (dra_line p1 p3)
  36.   (setq l1 (entlast))
  37.   (dra_line p2 p4)
  38.   (setq l2 (entlast))
  39.   (setq en1_pa1 (vlax-curve-getParamAtPoint en1 p1))
  40.   (setq en1_pa2 (vlax-curve-getParamAtPoint en1 p4))
  41.   (setq
  42.     trimp1 (vlax-curve-getPointAtParam en1 (/ (+ en1_pa1 en1_pa2) 2))
  43.   )
  44.   (setq en2_pa1 (vlax-curve-getParamAtPoint en2 p2))
  45.   (setq en2_pa2 (vlax-curve-getParamAtPoint en2 p3))
  46.   (setq
  47.     trimp2 (vlax-curve-getPointAtParam en2 (/ (+ en2_pa1 en2_pa2) 2))
  48.   )
  49.   (command "trim"
  50.      l1
  51.      l2
  52.      ""
  53.      (list en1 trimp1)
  54.      (list en2 trimp2)
  55.      ""
  56.   )
  57.   (princ)
  58. )


  59. (defun c:X1 ( / @lay en1 en1_pa1 en1_pa2 en2 en2_pa1 en2_pa2 l1 l2 olderr p1 p2 p3 p4 trimp1 trimp2)
  60. (vl-load-com)
  61. (setvar "osmode" 641)
  62. (command "_.undo" "be")
  63. (setq p1 (getpoint "\n指定第一条线上的点:")
  64. en1 (ssname (ssget p1) 0))
  65. (setq p2 (getpoint "\n指定第二条线上的点:")
  66. en2 (ssname (ssget p2) 0))
  67. (setq p1 (vlax-curve-getClosestPointTo en1 p1 t)
  68. p2 (vlax-curve-getClosestPointTo en2 p2 t)
  69. )
  70. (setq p3 (vlax-curve-getClosestPointTo en2 p1 t)
  71. p4 (vlax-curve-getClosestPointTo en1 p2 t)
  72. )
  73. (dra_line p1 p3)
  74. (setq l1 (entlast))
  75. (if (or (equal p1 p3 0.001)(equal p2 p3 0.001))
  76. (princ "\n绘制单一管道剖断线。")
  77. (progn
  78. (dra_line p2 p4)
  79. (setq l2 (entlast))
  80. )
  81. )
  82. (if (and l1 l2)
  83. (progn
  84. (setq en1_pa1 (vlax-curve-getParamAtPoint en1 p1)
  85. en1_pa2 (vlax-curve-getParamAtPoint en1 p4))
  86. (setq
  87. trimp1 (vlax-curve-getPointAtParam en1 (/ (+ en1_pa1 en1_pa2) 2))
  88. )
  89. (setq en2_pa1 (vlax-curve-getParamAtPoint en2 p2)
  90. en2_pa2 (vlax-curve-getParamAtPoint en2 p3))
  91. (setq
  92. trimp2 (vlax-curve-getPointAtParam en2 (/ (+ en2_pa1 en2_pa2) 2))
  93. )
  94. (command "trim" l1 l2 "" (list en1 trimp1) (list en2 trimp2) "")))
  95. (command "undo" "e")
  96. (princ)
  97. )



本帖子中包含更多资源

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

x

点评

精神可架  发表于 2011-11-24 01:28

评分

参与人数 4明经币 +5 收起 理由
cabinsummer + 1 很给力!
xiaxiang + 2 感谢分享!
kwok + 1 赞一个!
yjr111 + 1 你没用到可能别人正着急找呢

查看全部评分

发表于 2011-11-24 01:28 | 显示全部楼层
支持2楼的......
发表于 2011-12-26 12:37 | 显示全部楼层
sen.sam真强悍.服了
发表于 2012-2-23 12:45 | 显示全部楼层
luoguoqianga,楼主你好,我一直在用你的程序,但每次点出来的断截面的距离都不一样,不知楼主是否方便改善一下呢,把两截面的距离设定为圆柱直径的  四分之一。非常期待楼主能够更新。
发表于 2012-2-23 13:21 | 显示全部楼层
哈哈,多谢多谢,
发表于 2012-2-23 21:48 | 显示全部楼层
luoguoqianga,罗锅前嘎???
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-28 21:11 , Processed in 1.922201 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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