明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: Atsai

[源码] 根据輸入面积调整多段线单点或单边至符合面积!!

    [复制链接]
 楼主| 发表于 2015-8-19 10:02 | 显示全部楼层
cable2004 发表于 2015-8-18 20:04
还要考虑一个bug,就是当梯形两边延伸到一点后面积还达不到要求,然后转三角形延伸!

单边调整的是有考虑您说的这个问题,在达不到面积要求的时候出现警告表示「达不到面积要求」然后跳出。
因为原本的想法是既然已经达不到要求转成三角形延伸还是无法符合要求,直接跳出比较快!
发表于 2015-8-19 10:35 | 显示全部楼层
来赞一个大师,我写的太啰嗦了  但是我技术有限 菜鸟级别 望见谅

  1. (defun PoInPl(pt p / d d0 d1 p1 n);;:点表是否包围指定点
  2.   (setq p1(cons(last pt)pt)n 0 d 1e99)
  3.   (repeat(length pt)(setq d0(car(PTOLINE p(nth n p1)(nth(setq n(1+ n))p1)))d(if(< d0 d)d0 d)))
  4.   (if(equal d 0 1e-8)0
  5.     (progn
  6.       (setq n 0 d1 1e99 pt(OFFSETPT pt 1 0)p1(cons(last pt)pt))
  7.       (repeat(length pt)(setq d0(car(PTOLINE p(nth n p1)(nth(setq n(1+ n))p1)))d1(if(< d0 d1)d0 d1)))
  8.       (if(> d1 d)1 -1))))
  9. (defun PlDir(p / n m p1 p2 p3 o a a1 a2)
  10.   (setq n(length p)pi2(* pi 2)m 2 p1(nth 0 p)p2(nth 1 p))
  11.   (while(< m n)
  12.     (setq p3(nth m p)
  13.           o(list(/(+(+(car p1)(car p2))(car p3))3)(/(+(+(cadr p1)(cadr p2))(cadr p3))3))
  14.           m(if(<(PoInPl p o)1)n(1+ m))))
  15.   (setq a(angle o p1) a1(-(angle o p2)a)
  16.         a1(if(< a1 0)(+ a1 pi2)a1)
  17.         a2(-(angle o p3)a)
  18.         a2(if(< a2 0)(+ a2 pi2)a2)
  19.         m(if(> a1 a2)t)))
  20. (defun offsetpt(pt d flag / offsetpt1);|falg 0闭合点表,1不闭合它;d<0向内>0向外(假定它有内外)|;
  21.   (defun offsetpt1(pt d flag / m0 m n pi2 d1 p1 p0 p q0 q2 q22 q1 q pt1 pt2 fx)
  22.     (setq m(length pt)d1(abs d)n flag
  23.           pi15(*(if(> d 0)1 -1) pi 1.5)pt2 pt)
  24.     (while(< n(- m flag))
  25.       (setq p(nth n pt2)
  26.             p0(if(<(1- n)0)(last pt2)(nth(1- n)pt2))
  27.             p1(if(=(1+ n)m)(car pt2)(nth(1+ n)pt2))
  28.             n(1+ n)
  29.             ang1(+(angle p0 p)pi15)
  30.             ang2(+(angle p p1)pi15)
  31.             q(inters (polar p0 ang1 d1)(polar p ang1 d1)(polar p ang2 d1)(polar p1 ang2 d1) nil)
  32.             q(if q q (polar p ang2 d1)))
  33.       (if(=(* flag n)2)(setq pt1(append pt1(list q0))))
  34.       (setq pt1(append pt1(list q)))
  35.       (if(=(* flag n)(- m flag))(setq pt1(append pt1(list q1)))))
  36.     pt1)
  37.   (if(= flag 0)
  38.     (setq d0(apply '+(mapcar'(lambda(x)(distance(nth(1-(vl-position x pt))pt)x))(cdr pt)))
  39.           pt1(offsetpt1 pt(if(> d 0)0.1 -0.1)flag)
  40.           d1(apply '+(mapcar'(lambda(x)(distance(nth(1-(vl-position x pt1))pt1)x))(cdr pt1)))
  41.           pt1(offsetpt1(if((if(> d 0)> <)d1 d0)pt(reverse pt))d flag)
  42.           pt1(if((if(> d 0)> <)d1 d0)pt1(reverse pt1)))
  43.     (offsetpt1 pt d flag)))
  44. (defun Plinexy(e / p a b n ob q et d d1 en et) ;;多线段节点坐标(滤掉了多余点,未处理假闭合)
  45.    (setq a(entget e)ob(vlax-ename->vla-object e)et(cdr(assoc 0 a))n 0 p nil d nil)
  46.    (cond((="LWPOLYLINE"et)
  47.          (repeat(length a)(setq b (nth n a) n (+ n 1))
  48.            (if (= 10 (car b))(progn
  49.                                (setq q(list (cadr b) (caddr b))d1(vlax-curve-getDistAtPoint ob q))
  50.                                (if p (if (not(member d1 d)) (setq p (append p (list q))d (append d (list d1))))
  51.                                  (setq p (list q))))
  52.              )))
  53.         ((="POLYLINE"et)
  54.          (SETQ EN (ENTGET (SETQ E (ENTNEXT E))))
  55.          (WHILE (/= (CDR (ASSOC 0 EN)) "SEQEND")
  56.            (SETQ q (CDR (ASSOC 10 EN))d1(vlax-curve-getDistAtPoint ob q)q(reverse(cdr(reverse q))))
  57.            (if p(if (not(member d1 d)) (setq p (append p (list q))d (append d (list d1))))
  58.              (setq p (list q)))
  59.            (SETQ EN (ENTGET (SETQ E (ENTNEXT E)))))
  60.          (setq p(reverse p))
  61.          ))
  62.    P)
  63. (defun ptoline(p p1 p2 / l a b c d);;p在线外p1近端点p2远端点
  64.   (setq a(distance p1 p2)
  65.         c(distance p p1)
  66.         b(distance p p2)
  67.         l(/(-(+(* a a)(* c c))(* b b))(* a 2))
  68.         d(polar p1(angle p1 p2)(abs l)))
  69.   (if(< 0 l a)(list(distance p d)p d)
  70.     (if(> b c)(list c p p1)(list b p p2))))

  71. ;;164.32 [功能] 多段线反向(起点反成终点) byzml84
  72. ;;(HH:LWPOLYLINEFX (car (entsel)))
  73. (defun HH:LWPOLYLINEFX (EN / A B C D ENT LST LST1 TMP)
  74.   (setq ENT (entget EN))
  75.   (setq tmp ent)
  76.   (while (setq tmp (member (assoc 10 tmp) tmp))
  77.     (setq a   (assoc 10 tmp)
  78.           b   (cons 40 (cdr (assoc 41 tmp)))
  79.           c   (cons 41 (cdr (assoc 40 tmp)))
  80.           d   (cons 42 (- (cdr (assoc 42 tmp))))
  81.           LST (append (list b c d a) LST)
  82.     )
  83.     (setq tmp (cddddr tmp))
  84.   )
  85.   (repeat 3 (setq LST (append (cdr lst) (list (car lst)))))
  86.   (setq lst1 (reverse (cdr (member (assoc 10 ent) (reverse ent)))))
  87.   (entmod (append lst1 lst '((210 0 0 1))))
  88. )

  89. ;;;;;;;
  90. (defun getplarea (l)
  91.   (* 0.5
  92.      (apply
  93.        '+
  94.        (mapcar
  95.          '(lambda (a b) (- (* (car a) (cadr b)) (* (car b) (cadr a))))
  96.          l
  97.          (append (cdr l) (list (car l)))
  98.        )
  99.      )
  100.   )
  101. )
  102. ;;;;;;;

  103. ;; 獲取聚合線點表
  104. (defun vxs (e / i v lst)
  105.   (setq i -1)
  106.   (while
  107.     (setq v (vlax-curve-getpointatparam e (setq i (1+ i))))
  108.      (setq lst (cons v lst))
  109.   )
  110.   (reverse lst)
  111. )
  112. ;;;;;;;;;;;
  113. (defun c:tt ( / ent ent1 mj demj pzx xzp pzx1 xzp1  a b d s l k lwpy pt mt jiaodian dianbiao jiaodian-a jiaodian1)
  114. (setq ent1 (car (entsel "\n请选择需要改变的多段线")))
  115. (setq demj (vlax-curve-getArea  (vlax-ename->vla-object ent1)))
  116. (prompt (strcat "\n原多段线面积为:"(rtos demj 2 3)))
  117. (setq mj (getreal "\n请输入调整后面积:"))


  118. ;;164.18 [功能] 多段线所点击子段的两相邻线端点列表
  119. ;;示例(HH:PickSegEndPt (car(setq en(entsel))) (cadr en))
  120. (defun HH:PickSegEndPt (obj p / pp n)
  121.   (setq        pp (vlax-curve-getclosestpointto obj (trans p 1 0))
  122.         n  (fix (vlax-curve-getparamatpoint obj pp))
  123.     nn (- (length (vxs obj)) 1)
  124.   )
  125.   (list       (vlax-curve-getPointAtParam obj (if (> (1- n) 0) (1- n) (+ n -1 nn)  )  )
  126.     (vlax-curve-getPointAtParam obj n)
  127.         (vlax-curve-getPointAtParam obj (if (< (1+ n) nn) (1+ n) (- (+ n 1 ) nn)))
  128.     (vlax-curve-getPointAtParam obj (if (< (+ n 2) nn) (+ n 2) (- (+ n 2) nn)))
  129.   )
  130. )
  131. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  132.     (if (= (pldir(plinexy ent1)) T)
  133.       (HH:LWPOLYLINEFX ent1)
  134.       )
  135. (setq dianbiao (HH:PickSegEndPt (car(setq en(entsel "请选择需要改变的多段线的一边"))) (cadr en)))

  136. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  137.   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  138. (if (> mj demj)
  139.   (progn

  140. (setq pzx (angle (nth 0 dianbiao)(nth 1 dianbiao)))

  141. (setq xzp (angle (nth 2 dianbiao)(nth 1 dianbiao)))

  142. (setq pzx1 (angle (nth 2 dianbiao)(nth 1 dianbiao)))

  143. (setq xzp1 (angle (nth 2 dianbiao)(nth 3 dianbiao)))
  144. (setq jiaodian (inters (nth 0 dianbiao)(nth 1 dianbiao) (nth 3 dianbiao)(nth 2 dianbiao) nil ))


  145. (if (< (abs (getplarea (list (nth 2 dianbiao)(nth 1 dianbiao) jiaodian))) (- mj demj)) (print (strcat "此线段无法调整至指定面积,必须小于"
  146. (rtos (+ (abs (getplarea (list (nth 2 dianbiao)(nth 1 dianbiao) jiaodian))) demj) 2 3)      )
  147.                         )
  148.   )


  149. (setq b (- xzp pzx pi) )

  150. (setq a  (- xzp1 pzx1 pi) )

  151. (setq d (distance (nth 2 dianbiao)(nth 1 dianbiao)))

  152. (setq s (- mj demj))

  153. ;(setq l  ( / (+ (* 2 d (sin b)) (sqrt (- (expt (* -2 d (sin b)) 2)   (* 8 s (/ (sin b) (sin a)) (sin (- pi a b) )   ) )  )
  154.     ; )
  155.       
  156. ;(* 2 (/ (sin b) (sin a))  (sin (- pi a b) )  )  )
  157.        ;    )
  158. (if (> (abs (getplarea (list (nth 2 dianbiao)(nth 1 dianbiao) jiaodian))) (- mj demj))

  159. (setq l  ( / (- (* 2 d (sin b)) (sqrt (- (expt (* -2 d (sin b)) 2)   (* 8 s (/ (sin b) (sin a)) (sin (- pi a b) )   ) )  )
  160.      )
  161.       
  162. (* 2 (/ (sin b) (sin a))  (sin (- pi a b) )  )  )
  163.            )
  164.   )

  165. (setq k (* (sin b) (/ l (sin a))
  166.      ))

  167. (print l)
  168.   (print k)
  169. (princ)
  170. (setq pt (polar (nth 1 dianbiao) pzx l) )
  171. (setq mt (polar (nth 2 dianbiao) (angle (nth 3 dianbiao)(nth 2 dianbiao)) k) )
  172. (entmake (list '(0 . "point")  (cons 10 pt)            )  )

  173. (entmake (list '(0 . "point")  (cons 10  mt)            )  )
  174. (entmake (list '(0 . "point")  (cons 10  jiaodian)            )  )

  175. (entmod(subst(cons 10 mt)(cons 10(mapcar'+'(0 0)(nth 2 dianbiao)))
  176. (subst(cons 10 pt)(cons 10(mapcar'+'(0 0)(nth 1 dianbiao)))
  177. (entget (car en)))))

  178. )
  179. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  180. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  181.   (if  (<  mj demj)
  182.     (progn

  183. (setq pzx (angle (nth 0 dianbiao)(nth 1 dianbiao)))

  184. (setq xzp (angle (nth 2 dianbiao)(nth 1 dianbiao)))

  185. (setq pzx1 (angle (nth 2 dianbiao)(nth 1 dianbiao)))

  186. (setq xzp1 (angle (nth 2 dianbiao)(nth 3 dianbiao)))

  187. (setq b (- xzp pzx pi) )

  188. (setq a  (- xzp1 pzx1 pi) )

  189. (setq d (distance (nth 2 dianbiao)(nth 1 dianbiao)))

  190. (setq s (- demj mj))

  191. ;;;子程序 (p-l1), 求点到直线距离程序的前半部分 (求常数'c1','c2'和'c3')。
  192. ;;;参数 'p1' 和 'p2' 为直线的两个端点。
  193. (defun pl1 (p1 p2 p0 / x1 y1 x2 y2 c1 c2 c3)
  194.   (setq        x1 (car p1)
  195.         y1 (cadr p1)
  196.         x2 (car p2)
  197.         y2 (cadr p2)
  198.         c1 (- y2 y1)
  199.         c2 (- x1 x2)
  200.         c3 (sqrt (+ (* c1 c1) (* c2 c2)))
  201.         c1 (/ c1 c3)
  202.         c2 (/ c2 c3)
  203.         c3 (/ (- (* x2 y1) (* x1 y2)) c3)
  204.         juli (+ (* c1 (car p0)) (* c2 (cadr p0)) c3)
  205.   )
  206. )
  207. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  208. (if (<  (pl1 (nth 2 dianbiao)(nth 1 dianbiao) (nth 0 dianbiao))   (pl1 (nth 2 dianbiao)(nth 1 dianbiao) (nth 3 dianbiao)))
  209.   (progn
  210. (setq jiaodian-a (polar (nth 2 dianbiao)  (- xzp (* 0.5 pi))    (pl1 (nth 2 dianbiao)(nth 1 dianbiao) (nth 0 dianbiao)) )  )
  211. (setq jiaodian1 (inters (nth 0 dianbiao) jiaodian-a  (nth 2 dianbiao)(nth 3 dianbiao) nil))
  212. (alert (strcat "减小面积不能大于" (rtos (abs (getplarea (list jiaodian1 (nth 2 dianbiao) (nth 1 dianbiao) (nth 0 dianbiao)) )  ) 2 3)))
  213. )
  214. (if  (>  (pl1 (nth 2 dianbiao)(nth 1 dianbiao) (nth 0 dianbiao))   (pl1 (nth 2 dianbiao)(nth 1 dianbiao) (nth 3 dianbiao)))
  215. (progn
  216. (setq jiaodian-a (polar (nth 1 dianbiao)  (+ (angle (nth 1 dianbiao)(nth 2 dianbiao)) (* 0.5 pi))    (pl1 (nth 2 dianbiao)(nth 1 dianbiao) (nth 3 dianbiao)) )  )
  217. (setq jiaodian1 (inters (nth 3 dianbiao) jiaodian-a  (nth 0 dianbiao)(nth 1 dianbiao) nil))
  218. (alert (strcat "减小面积不能大于" (rtos (abs (getplarea (list jiaodian1 (nth 1 dianbiao) (nth 2 dianbiao) (nth 3 dianbiao)) )  ) 2 3)))
  219. )

  220.   )

  221.   
  222.   )

  223. ;(setq l  ( / (+ (* 2 d (sin b)) (sqrt (- (expt (* -2 d (sin b)) 2)   (* 8 s (/ (sin b) (sin a)) (sin (- pi a b) )   ) )  )
  224.     ; )
  225.       
  226. ;(* 2 (/ (sin b) (sin a))  (sin (- pi a b) )  )  )
  227.        ;    )


  228. (setq l  (abs ( / (+ (* -2 d (sin b)) (sqrt (+ (expt (* 2 d (sin b)) 2)   (* 8 s (/ (sin b) (sin a)) (sin (- pi a b) )   ) )  )
  229.      )
  230.       
  231. (* 2 (/ (sin b) (sin a))  (sin (- pi a b) )  )  ))
  232.       
  233.            )
  234.   

  235. (setq k (abs  (* (sin b) (/ l (sin a))
  236.      )  )
  237.       )

  238. (print l)
  239.   (print k)
  240. (princ)
  241. (setq pt (polar (nth 1 dianbiao) (angle (nth 1 dianbiao)(nth 0 dianbiao)) l) )
  242. (setq mt (polar (nth 2 dianbiao) (angle (nth 2 dianbiao)(nth 3 dianbiao)) k) )
  243. (entmake (list '(0 . "point")  (cons 10 pt)            )  )

  244. (entmake (list '(0 . "point")  (cons 10  mt)            )  )

  245. (entmod(subst(cons 10 mt)(cons 10(mapcar'+'(0 0)(nth 2 dianbiao)))
  246. (subst(cons 10 pt)(cons 10(mapcar'+'(0 0)(nth 1 dianbiao)))
  247. (entget (car en)))))


  248. )    )
  249. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  250.   

  251.   )




  252.   )
  253. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



  254. (defun HHH:PickSegEndPt (arg / obj p pp n)
  255.   (setq obj(car arg)p(last arg))
  256.   (setq        pp (vlax-curve-getclosestpointto obj (trans p 1 0))
  257.         n  (fix (vlax-curve-getparamatpoint obj pp))
  258.     nn (- (length (vxs obj)) 1)
  259.   )
  260.   (list       (vlax-curve-getPointAtParam obj (if (> (1- n) 0) (1- n) (+ n -1 nn)  )  )
  261.     (vlax-curve-getPointAtParam obj n)
  262.         (vlax-curve-getPointAtParam obj (if (< (1+ n) nn) (1+ n) (- (+ n 1 ) nn)))
  263.     (vlax-curve-getPointAtParam obj (if (< (+ n 2) nn) (+ n 2) (- (+ n 2) nn)))
  264.   )
  265. )

  266. ;(HH:PICKSEGENDPT(entsel))


东抄西抄的

点评

給一個讚  发表于 2023-11-28 16:12

评分

参与人数 1明经币 +1 收起 理由
Atsai + 1 赞一个!

查看全部评分

 楼主| 发表于 2015-8-19 10:47 | 显示全部楼层
树櫴希德 发表于 2015-8-19 10:35
来赞一个大师,我写的太啰嗦了  但是我技术有限 菜鸟级别 望见谅东抄西抄的

我也是拼东凑西的,能达到目的才是王道,哈哈!
发表于 2015-8-19 10:54 | 显示全部楼层
感谢大师的分享
发表于 2015-8-19 11:18 | 显示全部楼层
; 错误: 读入的 (八进制) 字符不正确: 0  TMJ2
 楼主| 发表于 2015-8-19 12:26 | 显示全部楼层
树櫴希德 发表于 2015-8-19 11:18
; 错误: 读入的 (八进制) 字符不正确: 0  TMJ2

因为我是繁体转简体,可能会有些字符是有错误的,
建议是打开文件,复制内容再到vlisp里去执行。

点评

命令: _appload 已成功加载 tmj2-单一边依面积调整多边形.lsp。 命令: ; 错误: 读入的 (八进制) 字符不正确: 0  发表于 2016-1-18 19:54
发表于 2015-8-19 14:44 | 显示全部楼层
本帖最后由 llsheng_73 于 2015-8-19 14:54 编辑

其实有个最大的问题:下图中黄色线为待调整的边,根据程序中的算法可调整该边至红色线位置,但实际上到绿色线位置按原来的算法已经无法处理了,不知道程序中有没处理方法或者进行检测防范,如果没有,那很可能会得出一个自相交图形并且面积不对。
假定黄线绿线为底的梯形面积为300平方,黄线现红线为底的梯形面积800平方,现在要求调整黄线边,面积减小400平方,按程序的设计思路这是可以有解的,但结果肯定不对。。。

本帖子中包含更多资源

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

x
发表于 2015-8-19 14:49 | 显示全部楼层
边至符合面积
 楼主| 发表于 2015-8-19 14:56 | 显示全部楼层
llsheng_73 发表于 2015-8-19 14:44
其实有个最大的问题:下图中黄色线为待调整的边,根据程序中的算法可调整该边至红色线位置,但实际上到绿色 ...

程序最后有做完成后的面积的检测,如果发生您所说的情况,会出现面积错误的警告,要再重新处理!

我也正在想如何处理红线的这种情况,如果有办法解决的话,就可以将程序修改成批次的自动分割了!

但是目前还没有想到要怎么处理
发表于 2015-8-19 15:03 | 显示全部楼层
Atsai 发表于 2015-8-19 14:56
程序最后有做完成后的面积的检测,如果发生您所说的情况,会出现面积错误的警告,要再重新处理!

我也 ...

线有重复点也不能成功,要先删除重复点,用73哥的函数

  1. (defun InsOrDel(lst pos mod / qlst a hlst);{在指定位置删除或插入元素mod为要插入的元素为空时删除第pos项}
  2.     (setq a -1)
  3.     (setq hlst(vl-member-if-not'(lambda(x)(setq a(1+ a))(if(= a pos) nil(setq qlst (cons x qlst))))lst))
  4.     (if mod(apply 'append (list (reverse(cons mod qlst)) hlst))
  5.       (apply 'append (list (reverse qlst)(cdr hlst)))))

  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  7. (defun Plinexy(e / p a b n ob q et d d1 en et) ;;多线段节点坐标(滤掉了多余点,未处理假闭合)
  8.    (setq a(entget e)ob(vlax-ename->vla-object e)et(cdr(assoc 0 a))n 0 p nil d nil)
  9.    (cond((="LWPOLYLINE"et)
  10.          (repeat(length a)(setq b (nth n a) n (+ n 1))
  11.            (if (= 10 (car b))(progn
  12.                                (setq q(list (cadr b) (caddr b))d1(vlax-curve-getDistAtPoint ob q))
  13.                                (if p (if (not(member d1 d)) (setq p (append p (list q))d (append d (list d1))))
  14.                                  (setq p (list q))))
  15.              )))
  16.         ((="POLYLINE"et)
  17.          (SETQ EN (ENTGET (SETQ E (ENTNEXT E))))
  18.          (WHILE (/= (CDR (ASSOC 0 EN)) "SEQEND")
  19.            (SETQ q (CDR (ASSOC 10 EN))d1(vlax-curve-getDistAtPoint ob q)q(reverse(cdr(reverse q))))
  20.            (if p(if (not(member d1 d)) (setq p (append p (list q))d (append d (list d1))))
  21.              (setq p (list q)))
  22.            (SETQ EN (ENTGET (SETQ E (ENTNEXT E)))))
  23.          (setq p(reverse p))
  24.          ))
  25.    P)
  26. ;;;;
  27. (defun RYD(e / s m n f a p);;删除冗余点
  28.   (setq p(Plinexy e)ob(vlax-ename->vla-object e)e(entget e)F 0)
  29.   (if (or(=(cdr(assoc 70 e))129)(=(cdr(assoc 70 e))1))(setq p(append p(list(car p)))))
  30.   (if (=(vlax-curve-getdistatpoint ob(vlax-curve-getendpoint ob))0)
  31.     (setq p(reverse(cdr(reverse p)))F 1))
  32.   (setq a(list(cons 0 "LWPOLYLINE")(cons 8(cdr(assoc 8 e)))(cons 6(if(assoc 6 e)(cdr(assoc 6 e))""))
  33.               (cons 62(if(assoc 62 e)(cdr(assoc 62 e))256))(cons 370(if(assoc 370 e)(cdr(assoc 370 e))0))
  34.               (cons 48(if(assoc 48 e)(cdr(assoc 48 e))1))(cons 100 "AcDbEntity")(cons 100 "AcDbPolyline")
  35.               (cons 90(-(length P)F))(cons 70 (+ 128 F))(cons 43(if(assoc 43 e)(cdr(assoc 43 e))0))
  36.               (cons 38(caddr(vlax-curve-getstartpoint ob)))(assoc 39 e))
  37.         a(append(vl-remove (cons 6 "")a)(list(cons 10(car p)))))
  38.   (foreach e(cdr P)
  39.     (setq e(cons 10 e)
  40.           a(if(and(not(member e a))(>(distance(cdr(last a))(cdr e))1e-2))(append a (list e))a)))
  41.   (entmod(InsOrDel a 0(assoc -1 e)))
  42.   (princ))

点评

命令: tt 请选择需要改变的多段线; 错误: no function definition: VLAX-ENAME->VLA-OBJECT  发表于 2016-1-18 21:03
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-27 11:21 , Processed in 0.189309 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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