明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 8291|回复: 15

谁有将多线段反向的程序

  [复制链接]
发表于 2006-3-17 10:11:00 | 显示全部楼层 |阅读模式
谁有将多线段反向的程序,在这先谢过了!
发表于 2018-3-6 16:10:15 | 显示全部楼层
自带的reserve命令呀
发表于 2006-3-17 21:33:00 | 显示全部楼层
论坛里有,你搜索一下。
 楼主| 发表于 2006-3-18 09:50:00 | 显示全部楼层
我只找到直线反向的,可多段线没有!
发表于 2006-3-23 00:04:00 | 显示全部楼层

以前明总帖的:

Sub RevPline()
      Dim ent As AcadEntity
      Dim pnt As Variant
      Dim NewCoord() As Double
      Dim i As Integer
      On Error Resume Next
      Do
          ThisDrawing.Utility.GetEntity ent, pnt, "选择多段线:"
          If Err Then Exit Sub
          If TypeName(ent) Like "IAcad*Polyline" Then Exit Do
      Loop
      Dim Coord As Variant
      Dim CoordCount As Integer
      Dim Bulge() As Double
      If TypeName(ent) = "IAcadLWPolyline" Then
          Coord = ent.Coordinates
          CoordCount = (UBound(Coord) + 1) / 2
          ReDim NewCoord(UBound(Coord)) As Double
          For i = 0 To UBound(Coord) - 1 Step 2
              NewCoord(UBound(Coord) - i - 1) = Coord(i)
              NewCoord(UBound(Coord) - i) = Coord(i + 1)
          Next
          ReDim Bulge(CoordCount - 1) As Double
          For i = 0 To CoordCount - 1
              Bulge(i) = ent.GetBulge(i)
          Next
          ent.Coordinates = NewCoord
          For i = 0 To CoordCount - 2
              ent.SetBulge i, -Bulge(CoordCount - 2 - i)
          Next
          ThisDrawing.Regen acActiveViewport
      ElseIf TypeName(ent) = "IAcadPolyline" Then
          Coord = ent.Coordinates
          CoordCount = (UBound(Coord) + 1) / 3
          ReDim NewCoord(UBound(Coord)) As Double
          For i = 0 To UBound(Coord) - 1 Step 3
              NewCoord(UBound(Coord) - i - 2) = Coord(i)
              NewCoord(UBound(Coord) - i - 1) = Coord(i + 1)
              NewCoord(UBound(Coord) - i) = Coord(i + 2)
          Next
          If ent.Type = acSimplePoly Then
              ReDim Bulge(CoordCount - 1) As Double
              For i = 0 To CoordCount - 1
                  Bulge(i) = ent.GetBulge(i)
              Next
          End If
          ent.Coordinates = NewCoord
          If ent.Type = acSimplePoly Then
              For i = 0 To CoordCount - 2
                  ent.SetBulge i, -Bulge(CoordCount - 2 - i)
              Next
          End If
         ThisDrawing.Regen acActiveViewport
      End If
      
  End Sub

发表于 2006-3-24 09:03:00 | 显示全部楼层

有没有lisp版得呢

发表于 2006-3-24 16:57:00 | 显示全部楼层
  1. ;;By LUCAS(龙龙仔)
  2. ;;FOR LWPOLYLINE ONLY
  3. (defun C:TEST (/ ENT ENT1 Q Q1 Q3 Q4 N)
  4.   (setq ENT (entget (setq ENT1 (car (entsel)))))
  5.   (setq Q (reverse (member (assoc 39 (reverse ENT)) (reverse ENT))))
  6.   (setq Q1 (member (assoc 10 ENT) ENT))
  7.   (setq N  0
  8. Q3 NIL
  9.   )
  10.   (repeat (/ (- (length Q1) 1) 4)
  11.     (setq Q3 (append Q3
  12.        (list (nth N Q1)
  13.       (cons 42 (* -1 (cdr (nth (+ N 3) Q1))))
  14.       (cons 41 (cdr (nth (+ N 1) Q1)))
  15.       (cons 40 (cdr (nth (+ N 2) Q1)))
  16.        )
  17.       )
  18.     )
  19.     (setq N (+ N 4))
  20.   )
  21.   (setq Q3 (reverse Q3))
  22.   (entmake (append Q
  23.      (member (assoc 10 Q3) Q3)
  24.      (list (nth 0 Q3))
  25.      (list (nth 1 Q3))
  26.      (list (nth 2 Q3))
  27.      (list (last Q1))
  28.     )
  29.   )
  30.   (entdel ENT1)
  31.   (princ)
  32. )
发表于 2006-4-3 20:18:00 | 显示全部楼层

很好

发表于 2006-7-31 21:34:00 | 显示全部楼层

 

发表于 2006-9-16 22:06:00 | 显示全部楼层
有没有先判断方向,若符合再反向的?
发表于 2008-5-7 23:29:00 | 显示全部楼层
下定了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 11:41 , Processed in 0.180250 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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