明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2096|回复: 5

如何将不规则曲线(非圆弧)与其它线合成多段线

[复制链接]
发表于 2004-8-25 10:19:00 | 显示全部楼层 |阅读模式
小弟试了很久了。用pedit无法将不规则曲线变为多段线。


将图转化为r12格式,再打开,可将曲线本身变为多段线,但用peidt时却没有了合并选项(J)
发表于 2004-8-25 10:58:00 | 显示全部楼层
;;思路:判断ptlist(spline的各个节点的表)中前后两点的斜率是否一样。 ;;BY LUCAS(龙龙仔)
;;将spline等分为n个弧,再转为pline
;;只对2D spline有效, 3D spline要改用3dpoly
;;程序其实有个bug,对直线的spline会出错,用一个偷懒的办法解决了. (defun C:SPLINE_TO_PLINE (/ HOLDECHO OS SSS NUMPT N
ED ED1 PTST PTEND SS2 PT1 PT2
PT3 J ENT NNO SS SSL
ptlist b ) (defun VAL1 (N SS INDEX)
(cdr (assoc N (entget (ssname SS INDEX))))
) (defun CH_IT (NOS)
(if (assoc NOS ED)
(progn
(if (assoc NOS ENT)
(setq ENT (subst (assoc NOS ED) (assoc NOS ENT) ENT))
(setq ENT (append ENT (list (assoc NOS ED))))
)
(entmod ENT)
)
)
) (setq HOLDECHO (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "_.undo" "group")
(setq OS (getvar "osmode"))
(setvar "osmode" 0)
(prompt "\nPlease pick the spline: ")
(setq SSS (ssget '((0 . "spline"))))
(if SSS ;if1
(progn;progn1
(initget (+ 1 2 4))
(setq NUMPT
(getint
"\nPlease specify the accuracy of conversion: "
)
)
(setq N 0)
(setq SSL (sslength SSS))
(repeat SSL ;repeat1
(prompt (strcat "\r余 " (itoa (- SSL N)) " 个物件 "));相当于进度条
(setq ED1 (ssname SSS N))
(setq ED (entget ED1)) (setq ptlist (pp ed))
(leo ptlist)

(setq PTST (cdr (assoc 10 ED)) ;取得起点坐标
PTEND (cdr (assoc 10 (reverse ED)));取得终点坐标
) (if (= b 123)
(progn ;progn3
(command "erase" ed1 "")
(command "pline" ptst ptend "")
(setq N (1+ N))
);end progn3 (progn ;progn2
(command "_.divide" ED1 (* 2 NUMPT))
(setq SS2 (ssget "p"))
(if (= (logand (cdr (assoc 70 ED)) 1) 1)
(setq J 1)
(setq J 0)
)
(setq PT3 PTST)
(setq SS (ssadd))
(repeat NUMPT;repeat2
(setq PT2 (VAL1 10 SS2 J))
(if (/= NUMPT (/ (+ J 2) 2))
(setq PT1 (VAL1 10 SS2 (+ 1 J)))
(setq PT1 PTEND)
)
(command "_.arc" PT3 PT2 PT1)
(ssadd (entlast) SS)
(setq PT3 PT1)
(setq J (+ 2 J))
);end repeat2
(command "_.pedit" (ssname SS 1) "" "j" SS "" "")
(setq ENT (entget (entlast)))
(foreach NNO '(6 8 62 48)
(CH_IT NNO)
)
(command "_.erase" SS2 ED1 "")
(setq N (1+ N))
);end progn2
);end if2
);end repeat1
(prompt (strcat "\r完成转换 ")
)
);end progn1
(alert "Nothing selected!!")
);end if1
(setvar "osmode" OS)
(command "_.undo" "end")
(setvar "cmdecho" HOLDECHO)
(princ)
)
(defun pp (obj /)
(vl-load-com)
(MASSOC 10 obj)
) (defun massoc (key alist / x nlist)
(foreach x alist
(if (eq key (car x))
(setq nlist (cons (cdr x) nlist))
)
)
(reverse nlist)
) ;判断一个表中的各点的是不是在一直线上
(defun leo (listpoint / listnumber listpoint ang1 ang a list_pt)
(setq list_pt listpoint)
(setq listnumber (length list_pt))
(if (>= listnumber 2)
(setq ang1 (angle (car list_pt) (cadr list_pt)))
)
(setq a 1)
(while (and (>= listnumber 2) (= a 1))
(setq ang (angle (car list_pt) (cadr list_pt)))
(if (equal ang1 ang 0.000001)
(setq a 1)
(setq a 2)
)
(setq ang1 ang)
(setq list_pt (cdr list_pt))
(setq listnumber (length list_pt))
)
(if (= listnumber 1)
(setq b 123)
(setq b 456) ;b在主程序中设成变量
)
)
(print)
(prompt "\nType SPLINE_TO_PLINE to run")
(print)
 楼主| 发表于 2004-8-25 12:13:00 | 显示全部楼层
????????????????
发表于 2004-8-25 15:04:00 | 显示全部楼层
不明白吗?上面的程序就是将SPLINE线转成PLINE线。这样您就可以对转换成的线条进行编辑了。
发表于 2004-8-25 15:06:00 | 显示全部楼层
发表于 2004-8-25 15:45:00 | 显示全部楼层
PEDIT有几项条件:


1. 必须是连续性的(continuous)。


2. 必须有头有尾,如X.Y.O,Ø等形皆不行。


3. 各线段线性质,如Line. Pline,Lwpline.Spline....等必须相同。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-29 10:37 , Processed in 0.182933 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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