- 积分
- 5987
- 明经币
- 个
- 注册时间
- 2006-7-8
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 兰州人 于 2015-10-12 07:28 编辑
下面代码是通过数据集,fDataArr = Array("MText", "Text"): fTypeArr = Array("0", "0")
通过ReturnAllSelectSet获得MText,Text集。
Case "AcDbText"
Set objTxt = objSet.Item(ii)
With objTxt
'Debug.Print .TextString
'Debug.Print .ScaleFactor
.ScaleFactor = 0.5
End With
请求帮助,如何更改text的字体字形名,如更改为黑体,宋体字- Sub ls1()
- Dim objSet As AcadSelectionSet
- Dim fDataArr, fTypeArr
- fDataArr = Array("Line", "Arc"): fTypeArr = Array("0", "0")
- fDataArr = Array("Line", "Text"): fTypeArr = Array("0", "0")
- fDataArr = Array("Text"): fTypeArr = Array("0")
- fDataArr = Array("MText", "Text"): fTypeArr = Array("0", "0")
- Dim objLine As AcadLine, objArc As AcadArc, objText As AcadText
- Set objSet = ReturnAllSelectSet(fTypeArr, fDataArr)
- Dim objTxt As AcadText, objMTxt As AcadMText
- ''
- For ii = 0 To objSet.Count - 1
- 'Debug.Print objSet.Item(ii).ObjectName
- Select Case objSet.Item(ii).ObjectName
- Case "AcDbText"
- Set objTxt = objSet.Item(ii)
- With objTxt
- 'Debug.Print .TextString
- 'Debug.Print .ScaleFactor
- .ScaleFactor = 0.5
- End With
- Case "AcDbMText"
- Set objMTxt = objSet.Item(ii)
- With objMTxt
- Debug.Print .TextString
- End With
- End Select
-
- Next ii
-
- End Sub
- Function ReturnAllSelectSet(fTypeArray As Variant, fDataArray As Variant) As AcadSelectionSet
- Dim Sset As AcadSelectionSet
- On Error Resume Next
- '建立选择集
- ThisDrawing.SelectionSets("aa").Delete
- Set Sset = ThisDrawing.SelectionSets.Add("aa")
- '建立过滤器
- Dim fType, fData
- ReDim fType(0 To UBound(fTypeArray) + 2) As Integer
- ReDim fData(0 To UBound(fDataArray) + 2) As Variant
- fType(0) = -4
- For ii = 0 To UBound(fTypeArray)
- fType(ii + 1) = fTypeArray(ii)
- Next ii
- fType(UBound(fType)) = -4
- ''
- fData(0) = "<Or"
- For ii = 0 To UBound(fDataArray)
- fData(ii + 1) = fDataArray(ii)
- Next ii
- fData(UBound(fData)) = "Or>"
- ''
- '选择过滤出图形中所有的标注对象
- Sset.Select acSelectionSetAll, , , fType, fData
- Set ReturnAllSelectSet = Sset
- End Function
- Private Sub ll()
- Dim Count As Integer
-
- Dim Ent As AcadEntity, BlkRef As AcadBlockReference
- Dim mTxtEnt As AcadMText, TxtEnt As AcadText
- For ii = 0 To ThisDrawing.ModelSpace.Count - 1
- Set Ent = ThisDrawing.ModelSpace.Item(ii)
- Select Case Ent.ObjectName
- Case "AcDbBlockReference"
- Set BlkRef = Ent
- Case "AcDbMText"
- Set mTxtEnt = Ent
- Debug.Print mTxtEnt.TextString
- End Select
- Next ii
- End Sub
|
|