明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: guosheyang

[函数] 将圆和圆弧转为两节点多段线

    [复制链接]
发表于 2022-12-31 08:31 | 显示全部楼层
圆转换为多段线,可以用bo命令
发表于 2023-1-3 09:43 | 显示全部楼层
看着很厉害
发表于 2023-1-3 10:34 | 显示全部楼层

转圆或弧为二点多段线

本帖最后由 llsheng_73 于 2023-1-3 14:52 编辑

没想通转个圆或弧为二点多段线怎么搞出3k多代码的,自己搞个
  1. (defun arctopl(p r ang1 ang2 / a);;圆(弧)转多段线
  2.   (setq a(*(rem(+(- ang2 ang1)pi pi)(+ pi pi))0.25)a(cons 42(/(sin a)(cos a))))
  3.   (List(cons 10(polar p ang1 r))a(cons 10(polar p ang2 r))a))
  4. (defun tt(e yn / en p r ang1 ang2)
  5.   (setq en(entget e)
  6.         p(cdr(assoc 10 en))
  7.         r(cdr(assoc 40 en))
  8.         ang1(cdr(assoc 50 en)))
  9.   (entmakex(vl-remove'nil(append(mapcar'cons'(0 100 100 90 70)(list"LWPOLYLINE""AcDbEntity""AcDbPolyline"2(if ang1 0 1)))(list(assoc 8 en)(assoc 370 en)(assoc 62 en))
  10.                                 (if ang1(arctopl p r ang1(cdr(assoc 51 en)))(arctopl p r 0 pi)))))
  11.   (or(="1"Yn)(entdel e)))
  12. (defun c:tt(/ e Yn )
  13.   (initget "1 2")
  14.   (or(member(setq Yn(getkword"1.保留圆(弧) 2.不保留圆(弧)[2]"))'("1""2"))(setq Yn"2"))
  15.   (while(setq e(ssget":E:S"'((0 . "circle,arc"))))
  16.     (tt(ssname e 0)Yn))
  17.   )

回复 支持 1 反对 0

使用道具 举报

发表于 2023-1-3 10:48 | 显示全部楼层
感谢分享、这个功能还是很有用的
 楼主| 发表于 2023-1-3 12:43 | 显示全部楼层
llsheng_73 发表于 2023-1-3 10:34
没想通转个圆或弧为二点多段线怎么搞出3k多代码的,自己搞个

测试了下tt命令  好像 下凹型圆弧  会改变原来的方向
发表于 2023-1-3 13:08 | 显示全部楼层

感谢楼主分享,
发表于 2023-1-3 14:52 | 显示全部楼层
guosheyang 发表于 2023-1-3 12:43
测试了下tt命令  好像 下凹型圆弧  会改变原来的方向

当终止角小于起始角的时候会出问题,已修正
发表于 2023-6-14 23:17 | 显示全部楼层
llsheng_73 发表于 2023-1-3 10:34
没想通转个圆或弧为二点多段线怎么搞出3k多代码的,自己搞个

老大,能不能搞个批量的?这个一个一个点,累啊.
发表于 2023-6-15 08:44 | 显示全部楼层
迷失1786 发表于 2023-6-14 23:17
老大,能不能搞个批量的?这个一个一个点,累啊.

轮子有了,怎么用轮子那是自己的事了,c:tt只是为了方便测试而已
发表于 2023-8-2 15:02 | 显示全部楼层
不明觉力,学习学习!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-7 21:19 , Processed in 1.037546 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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