找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 527|回复: 2

[VBA函数]:请教晓东

[复制链接]
发表于 2002-10-9 16:55:23 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
请问:晓东为什么我的这个程序对于如下图所示的多义线有的向外偏移,有的向里偏移?
   程序如下:
Public Sub main()
       Call InRdsComp
       Call OutRdsComp
      
End Sub

Sub InRdsComp()
Dim rds As Double

rds = InputBox("请输入偏移距离", "输入")
Dim Insets As AcadSelectionSet
Dim snum As Integer
Dim existf As Boolean
    For snum = 0 To ThisDrawing.SelectionSets.Count - 1
        If ThisDrawing.SelectionSets.Item(snum).Name = "InEnts" Then
          existf = True
    Exit For
        End If
    Next
    If existf = True Then
        Set Insets = ThisDrawing.SelectionSets.Item("InEnts")
        Insets.Clear
    Else
        Set Insets = ThisDrawing.SelectionSets.Add("InEnts")
    End If
Dim gpCode(0) As Integer
gpCode(0) = 8
Dim dataValue(0) As Variant
dataValue(0) = "InlayerBAid"
Dim groupCode, dataCode As Variant
groupCode = gpCode
dataCode = dataValue
Insets.Select acSelectionSetAll, , , groupCode, dataCode  
Dim i, entsnum As Integer
Dim ent As AcadEntity
Dim entry As Variant
entsnum = Insets.Count
For i = 0 To entsnum - 1
    Set ent = Insets.Item(i)
    ent.Highlight (True)
    MsgBox "this is" & ent.ObjectName
   
    If StrComp(ent.ObjectName, "AcDbCircle", 1) = 0 Or StrComp(ent.ObjectName, "AcDbEllipse", 1) = 0 Then
     entry = ent.Offset(-rds)
     entry(0).Color = acRed
     Else
     entry = ent.Offset(rds)
     entry(0).Color = acRed
   End If
Next

End Sub
Sub OutRdsComp()

Dim rds As Double
rds = InputBox("请输入偏移距离", "输入")
Dim Outsets As AcadSelectionSet
Dim snum As Integer
Dim existf As Boolean
    For snum = 0 To ThisDrawing.SelectionSets.Count - 1
        If ThisDrawing.SelectionSets.Item(snum).Name = "OutEnts" Then
          existf = True
    Exit For
        End If
    Next
    If existf = True Then
        Set Outsets = ThisDrawing.SelectionSets.Item("OutEnts")
        Outsets.Clear
    Else
        Set Outsets = ThisDrawing.SelectionSets.Add("OutEnts")
    End If
Dim gpCode(0) As Integer
gpCode(0) = 8
Dim dataValue(0) As Variant
dataValue(0) = "OutlayerBAid"
Dim groupCode, dataCode As Variant
groupCode = gpCode
dataCode = dataValue
Outsets.Select acSelectionSetAll, , , groupCode, dataCode  
Dim i, entsnum As Integer
Dim ent As AcadEntity
Dim entry As Variant
entsnum = Outsets.Count
For i = 0 To entsnum - 1
    Set ent = Outsets.Item(i)
    ent.Highlight (True)
    MsgBox "this is" & ent.ObjectName
   
    If StrComp(ent.ObjectName, "AcDbCircle", 1) = 0 Or StrComp(ent.ObjectName, "AcDbEllipse", 1) = 0 Then
     entry = ent.Offset(rds)
      entry(0).Color = acBlue
    Else
     entry = ent.Offset(-rds)
      entry(0).Color = acBlue
     End If
Next

End Sub

                               
登录/注册后可看大图
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
 楼主| 发表于 2002-10-9 16:59:41 | 显示全部楼层
我执行程序后运行的结果如图
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-10-9 17:04:33 | 显示全部楼层
最初由 luln 发布
[B]我执行程序后运行的结果如图 [/B]


对于曲线,除LINE外,输入正值,是往曲线增大的趋势偏移。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-6 16:12 , Processed in 0.230080 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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