明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2681|回复: 2

[求助][编程申请]样条曲线如何反向?vba在源码

[复制链接]
发表于 2007-8-4 11:43: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
发表于 2008-11-5 16:28:00 | 显示全部楼层
对所有曲线都能使用就好了!
发表于 2013-10-9 22:36:40 | 显示全部楼层
也为这问题挠头.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-28 05:23 , Processed in 0.144203 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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