谢谢你的回复fixo!
它工作得很好。剩下一个简单的问题。。。。
如何填充骨灰盒?我不想在屏幕上选择。我自己制作了一系列物品:
- Sub OrderToTop()
- ' This example creates a SortentsTable object and
- ' changes the draw order of selected object(s) to top.
- Dim oSset As AcadSelectionSet
- Dim oEnt
- Dim I As Integer
- Dim setName As String
- setName = "$Order$"
- 'Make sure selection set does not exist
- For I = 0 To ThisDrawing.SelectionSets.Count - 1
- If ThisDrawing.SelectionSets.Item(I).Name = setName Then
- ThisDrawing.SelectionSets.Item(I).Delete
- Exit For
- End If
- Next I
- Set oSset = ThisDrawing.SelectionSets.Add(setName)
- [color=red] ReDim ssobjs(0 To ThisDrawing.Blocks.Count - 1) As AcadBlock[/color]
- [color=red] I = 0[/color]
- [color=red] For I = 0 To ThisDrawing.Blocks.Count - 1[/color]
- [color=red] Set ssobjs(I) = ThisDrawing.Blocks.Item(I)[/color]
- [color=red] Next[/color]
- [color=red] ' Add the array of objects to the selection set[/color]
- [color=red] [b]oSset.AddItems ssobjs[/b][/color]
- If oSset.Count > 0 Then
- ReDim arrObj(0 To oSset.Count - 1) As AcadObject
- 'Process each object
- I = 0
- For Each oEnt In oSset
- Set arrObj(I) = oEnt
- I = I + 1
- Next
- End If
- On Error GoTo Err_Control
- 'Get an extension dictionary and, if necessary, add a SortentsTable object
- Dim eDictionary As Object
- Set eDictionary = ThisDrawing.ModelSpace.GetExtensionDictionary
- ' Prevent failed GetObject calls from throwing an exception
- On Error Resume Next
- Dim sentityObj As Object
- Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
- On Error GoTo 0
- If sentityObj Is Nothing Then
- ' No SortentsTable object, so add one
- Set sentityObj = eDictionary.AddObject("ACAD_SORTENTS", "AcDbSortentsTable")
- End If
- 'Move selected object(s) to the top
- sentityObj.MoveToTop arrObj
- Application.Update
- Exit Sub
- Err_Control:
- If Err.Number <> 0 Then MsgBox Err.Description
如果文本为粗体,则会出现错误:对象“IAcadSelectionSet”的方法“AddItems”失败。
我试图将SSOBJ作为Object、Acadentity、Variant和AcadObject进行模糊处理,但它仍然不起作用。
怎么会?发生了什么?答案是什么? |