hd464011547 发表于 2010-6-3 15:42:00

求助,帮我看看错在哪里

Private Sub CommandButton1_Click()
Dim sSet As AcadSelectionSet
Dim ftype(0) As Integer
Dim fdata(0) As Variant
Dim xx As AcadText
ftype(0) = 0
fdata(0) = "TEXT"
With ThisDrawing
On Error Resume Next
   If Not IsNull(.SelectionSets.Item("MySetSelectionSet")) Then
       Set sSet = .SelectionSets.Item("MySetSelectionSet")
       CreateSelectionSet.Delete
   End If
   Set sSet = .SelectionSets.Add("MySetSelectionSet")
End With
sSet.Select acSelectionSetAll, , , ftype, fdata
sco = sSet.Count

xx = sSet.Item(1)
ass.Delete
End Sub
我想用xx变量得到选择集内的某个元素(文字),这么写不对,该怎么写

sailorcwx 发表于 2010-6-3 16:29:00

1).CreateSelectionSet.Delete的CreateSelectionSet是否有误?是否应该为sSet
2).xx = sSet.Item(1)前面加上Set,对象赋值需要Set
3).ass.Delete的ass又是什么?

henanlypl 发表于 2010-6-5 11:16:00

Private Sub Test()
Dim sco As Integer
Dim sSet As AcadSelectionSet
Dim ftype(0) As Integer
Dim fdata(0) As Variant
Dim xx As AcadText
ftype(0) = 0
fdata(0) = "TEXT"
With ThisDrawing
On Error Resume Next
   If Not IsNull(.SelectionSets.Item("MySetSelectionSet")) Then
       Set sSet = .SelectionSets.Item("MySetSelectionSet")
       sSet.Delete
   End If
   Set sSet = .SelectionSets.Add("MySetSelectionSet")
End With
sSet.Select acSelectionSetAll, , , ftype, fdata
sco = sSet.Count
Set xx = sSet.Item(1)
xx.color = acBlue
End Sub
这样可以了,你参考一下
页: [1]
查看完整版本: 求助,帮我看看错在哪里