乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 46|回复: 2

为什么我的块刷不出来???

[复制链接]

4

主题

6

帖子

1

银币

初来乍到

Rank: 1

铜币
22
发表于 2005-5-24 19:22:00 | 显示全部楼层 |阅读模式
为什么我的文件中本来有十几个块,执行vba程序刷新后且只能得到一个,而且块中所含的物体的数量也得不到??
代码如下:
Private Sub cmdexplode_Click()
Dim objblock As AcadBlockReference
If txtcount.Text = 0 Then
MsgBox "图形中未存在之定的块参照", vbCritical
Exit Sub
End If
For Each objblock In ThisDrawing.ModelSpace
        If objblock.Name = lstblocks.Text Then
        objblock.Explode
        objblock.Delete
        End If
        Next
       
        txtcount.Text = CInt(txtcount.Text) - 1
End SubPrivate Sub cmdgetpnt_Click()
Dim returnobject As Object
Dim elem As Object
Dim basepnt As Variant
i = 1
For Each elem In returnobject
         If elem.ObjectName = "AcDbAttributeDefinition" Then
                 basepnt = i
                 i = i + 1
                 End If
                 Next
                 txtcount = basepnt
End SubPrivate Sub UserForm_Initialize()
refresh
txtcount.Enabled = False
txtatt.Enabled = False
End Sub
Sub blockmanage()
        form1.Show
       
End Sub
Private Sub refresh()
        Dim blocklist As Collection
       
        On Error Resume Next
       
        Set blocklist = getblocks
       
        If blocklist Is Nothing Then
         MsgBox "当前图形中不存在任何块", vbCritical
         Exit Sub
         End If
         
         refreshlist lstblocks, blocklist
         
         If lstblocks.ListIndex = -1 Then
                 lstblocks.ListIndex = 0
                 End If
                 
                 Exit Sub
                 
errhandle:
                 MsgBox "在更新列表的过程中发生如下错误:" & Err.Description, vbCritical
                 End
                         
End SubPrivate Function getblocks() As Collection
        Dim blocklist As New Collection
        Dim icount As Long
        Dim acadobject As AcadBlock
       
        For Each acadobject In ThisDrawing.Blocks
         If acadobject.IsLayout = False Then
                 blocklist.Add acadobject.Name, acadobject.Name
                 End If
                 Next
                 
                 If blocklist.Count > 0 Then
                         Set getblocks = blocklist
                         Else
                         Set getblocks = Nothing
                         End If
End FunctionPrivate Sub refreshlist(ByRef lstobject As ListBox, ByRef blocklist As Collection)
         lstblocks.Clear
         
         Dim icount As Integer
         For icount = 1 To blocklist.Count
                         addsorted lstobject, blocklist(icount)
                         Next
                         End Sub
                         
         
Private Sub lstblocks_click()
         On Error Resume Next
         Dim blockname As String
         Dim i As Integer
         Dim num As Integer
         i = 0
         
         txtatt.Text = "无"
         
         blockname = lstblocks.Text
         Dim blkref As AcadBlockReference
         For Each blkref In ThisDrawing.ModelSpace
                 If blkref.Name = blockname Then
                 i = i + 1
                 If blkref.HasAttributes Then
                         txtatt.Text = "有"
                         End If
                         End If
                         Next blkref
                         
                         txtcount.Value = i
                         End Sub
Private Sub addsorted(ByRef lstobject As ListBox, ByRef sitem As String)
         Dim icount As Long
                 If lstobject.ListCount = 0 Then
                         lstobject.AddItem sitem
                         GoTo finish
                         End If
                         
                         For icount = 0 To (lstobject.listciunt - 1)
                                 If StrComp(lstobject.List(icount), sitem, vbTextCompare) = 1 Then
                                 GoTo finish
                                 End If
                                 Next
                         
                         lstobject.AddItem sitem
                         
finish:
                         End Sub
回复

使用道具 举报

34

主题

372

帖子

7

银币

中流砥柱

Rank: 25

铜币
508
发表于 2005-5-25 09:15:00 | 显示全部楼层
为什么我的文件中本来有十几个块,执行vba程序刷新后且只能得到一个???
不太明白你的意思,请详细描述一下,时间太紧,没有看代码。
回复

使用道具 举报

4

主题

6

帖子

1

银币

初来乍到

Rank: 1

铜币
22
发表于 2005-5-25 10:51:00 | 显示全部楼层
就是说,通过执行         eattext 命令,可以看出文件中总共有十几个块,但是我通过上述代码对图形进行扫描刷新,在文本框中只能得到一个块,而且这个块的所包含的物体的个数也无法显示(代码中有相关部分 令文本框中所选中的块 显示他的包含物体的数量),不知道为什么。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-3 08:51 , Processed in 1.032071 second(s), 58 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表