longxh28 发表于 2015-4-17 17:18:31

VBA 炸开块出错

写了一段VBA 代码,在炸开某些块的时候总是出错,是怎么回事

Private Sub LT_XBlock_Click()
Me.Hide
ThisDrawing.Activate
Dim filtertype(0) As Integer
Dim filterdata(0) As Variant
Dim explodedObjects As Variant
filtertype(0) = 0
filterdata(0) = "INSERT"
Set sset = ThisDrawing.SelectionSets.Add("SSETS" & CStr(Now()))
sset.SelectOnScreen filtertype, filterdata
If sset.Count < 1 Then
    MsgBox "选取对象为空"
    Exit Sub
End If
For Each filterent In sset
    filterent.Explode
    filterent.Delete
Next
End Sub

zzyong00 发表于 2015-4-17 22:24:12

我测试一下你的图,没有发现问题呀,用你的代码也没问题、
只是,有几个变量没定义,是全局变量吗?

zzyong00 发表于 2015-4-17 22:32:34

出错时,最好给出哪行出错,并且,给出出错的代码和内容描述,这样好让大家帮你

longxh28 发表于 2015-4-27 13:54:38

zzyong00 发表于 2015-4-17 22:32 static/image/common/back.gif
出错时,最好给出哪行出错,并且,给出出错的代码和内容描述,这样好让大家帮你

程序弹出:
运行时错误 '-2145386493
输入无效

月牙湾 发表于 2015-4-29 11:05:04

You do not have to explode a block in order to manipulate its constituent entities. All block definitions have an Item method that allow you to manipulate the entities within the block without exploding the block definition itself.
块好像不能分解。
http://www.feizhimeng.com

zzyong00 发表于 2015-4-29 14:57:32

他炸的不是块吧,是块引用

longxh28 发表于 2015-5-6 11:53:28

月牙湾 发表于 2015-4-29 11:05 static/image/common/back.gif
You do not have to explode a block in order to manipulate its constituent entities. All block defini ...

谢谢,我再研究一下

zzyong00 发表于 2015-5-6 18:13:01

Private Sub LT_XBlock_Click()
Me.Hide
ThisDrawing.Activate
Dim filtertype(0) As Integer
Dim filterdata(0) As Variant
Dim explodedObjects As Variant
Dim sset As AcadSelectionSet, filterent As AcadBlockReference
filtertype(0) = 0
filterdata(0) = "INSERT"
Set sset = ThisDrawing.SelectionSets.Add("SSETS" & CStr(Now()))
sset.SelectOnScreen filtertype, filterdata
If sset.Count < 1 Then
    MsgBox "选取对象为空"
    Exit Sub
End If
For Each filterent In sset
    filterent.Explode
    filterent.Delete
Next
End Sub

你的图,你的代码,没问题,只是少变量定义,我在1楼就说过

longxh28 发表于 2015-6-4 15:55:45

月牙湾 发表于 2015-4-29 11:05 static/image/common/back.gif
You do not have to explode a block in order to manipulate its constituent entities. All block defini ...

您好,这段话的意思是:“你不需要为了调整一个块的组成实体而炸开它,所有的块定义都有一则方法允许你块内调整实体,而不用炸开块参照自身”吗?

longxh28 发表于 2015-6-4 16:21:37

zzyong00 发表于 2015-5-6 18:13 static/image/common/back.gif
你的图,你的代码,没问题,只是少变量定义,我在1楼就说过

你好,谢谢你的回答,我现在发现出问题在于这个块的 XYZ插入比例不一样时出错,如果忽略错误,炸开块就没东西了
页: [1]
查看完整版本: VBA 炸开块出错