加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

CAD 创建闭合多段线的选择集

(2008-06-18 10:34:20)
标签:

it

分类: 工作/开发方面

废话不多说,直接贴代码:

Option Explicit

'创建选择闭合多段线的选择集
Public Sub ClosedLwpSelSet()
  Dim pClosedLwpSelSet As AcadSelectionSet
  Set pClosedLwpSelSet = CreateSelectionSet
 
  Dim n As Integer
  n = ThisDrawing.ModelSpace.Count - 1
  Dim m As Integer   '记录闭合多段线
  m = 0

  Dim pLwpObj() As AcadLWPolyline
  '得到图形中有多少个闭合的多段线
  Dim I As Integer
  For I = 0 To n
    If TypeOf ThisDrawing.ModelSpace.Item(I) Is AcadLWPolyline Then  '是多段线
      If ThisDrawing.ModelSpace.Item(I).Closed = True Then           '多段线是闭合的
        ReDim Preserve pLwpObj(m) As AcadLWPolyline                  '重新定义数组
        Set pLwpObj(m) = ThisDrawing.ModelSpace.Item(I)
        m = m + 1
      End If
    End If
  Next I

  pClosedLwpSelSet.AddItems pLwpObj               '生成闭合多段线的选择集
 
End Sub

'创建选择集的函数
Public Function CreateSelectionSet(Optional ssName As String = "ss") As AcadSelectionSet

    Dim ss As AcadSelectionSet
    On Error Resume Next
    Set ss = ThisDrawing.SelectionSets(ssName)
    If Err Then Set ss = ThisDrawing.SelectionSets.Add(ssName)
    ss.Clear
    Set CreateSelectionSet = ss

End Function

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有