大家好,
我正在尝试创建一个宏来更新AutoCAD图形-只需选择文字、多行文字、直线并修改其属性,如线宽、文字大小、文字样式。
因此,我的图形包含线条、文本或多行文字和属性引用-这些文件是未来的块。
一切都很好,我相信我很快就要完成了,但有一件事引起了问题。
当我试图选择属性引用并修改其文本高度时,就会出现问题。我不知道如何选择它们。我试着设置
- FilterTypeText(1) = 2
- FilterDataText(1) = "*"
- For Each entity In sstext
- entity.color = acByLayer
- entity.Height = 3.5
- Next
但它会选择一些无法修改文本高度的实体-没有这样的属性,我得到了一个错误。
现在我把
下一个错误将继续,但要解决这个问题。
请参阅下面的代码。
- Sub UpdateBlocks()
- Dim sstext As AcadSelectionSet
- Dim FilterTypeText(3) As Integer
- Dim FilterDataText(3) As Variant
- Dim tsObject As AcadTextStyle
- Dim ent As AcadEntity
- Dim ssall As AcadSelectionSet
- Dim layer As AcadLayer
- Dim entity As AcadEntity
- On Error Resume Next
- 'set acwhite for each layer in the drawing
- For Each layer In ThisDrawing.Layers
- layer.color = acWhite
- Next
- 'set all text styles
- For Each tsObject In ThisDrawing.TextStyles
- tsObject.fontFile = "SIMPLEX.shx"
- tsObject.Width = 0.8
- tsObject.Height = 3.5
- Next
- 'select all entities and change the lineweight and color
- Set ssall = ThisDrawing.SelectionSets.Add("SelectAll")
- ssall.Select acSelectionSetAll
- For Each ent In ssall
- ent.Lineweight = acLnWt000
- ent.color = acByLayer
- Next
- ssall.Clear
- ssall.Delete
- 'select and change all text and Mtext
- Set sstext = ThisDrawing.SelectionSets.Add("SelectText")
- FilterTypeText(0) = -4
- FilterDataText(0) = ""
- sstext.Select acSelectionSetAll, , , FilterTypeText, FilterDataText
- For Each entity In sstext
- entity.color = acByLayer
- entity.Height = 3.5
- Next
- sstext.Clear
- sstext.Delete
- 'need select all the block attributes and move them to the standard text style or at least modify the size and textstyle
- ThisDrawing.Application.ActiveDocument.PurgeAll
- End Sub
非常感谢您的帮助,
彼得 |