用文档对象的AddText方法可以创建单行文本对象,结合文本字体设置,可以显示丰富多彩的文字,创建单行文本的语法如下所示。
RetVal=object.AddText(TextString,InsertionPoint,Height)
RetVal新创建的单行文本对象,Object模型空间、图纸空间块对象,TextString字符串型,要显示的文本内容,InsertionPoint双精度型,文本插入点坐标,Height文字高度。下面的代码使用不同的字体,创建单行文字对象。
Private Sub Command1_Click()
Dim styobj1 As AcadTextStyle
Dim typeface As String
Dim bold As Boolean
Dim italic As Boolean
Dim charset As Long
Dim pitchandfamily As Long
Set styobj1 = acadapp.ActiveDocument.TextStyles.Add("自定义文字样式")
typeface = "宋体"
italic = True
bold = True
charset = 1
pitchandfamily = 1 Or 16
styobj1.SetFont typeface, bold, italic, charset, pitchandfamily
Dim styobj2 As AcadTextStyle
Set styobj2 = acadapp.ActiveDocument.TextStyles.Add("自定义")
styobj2.fontFile = "C:windowsfontsvani.ttf"
Dim textobj As AcadText
Dim textstring As String
Dim insertionpoint(0 To 2) As Double
Dim height As Double
textstring = "acad二次开发"
height = 0.3
insertionpoint(0) = 5#: insertionpoint(1) = 2#: insertionpoint(2) = 0
acadapp.ActiveDocument.ActiveTextStyle = styobj1
Set textobj = acadapp.ActiveDocument.ModelSpace.AddText(textstring, insertionpoint, height)
textobj.Update
insertionpoint(0) = 5: insertionpoint(1) = 1: insertionpoint(2) = 0
acadapp.ActiveDocument.ActiveTextStyle = styobj2
Set textobj = acadapp.ActiveDocument.ModelSpace.AddText(textstring, insertionpoint, height)
textobj.Update
styobj2.fontFile = "C:windowsfontsvani.ttf"
insertionpoint(0) = 5: insertionpoint(1) = 0: insertionpoint(2) = 0
acadapp.ActiveDocument.ActiveTextStyle = styobj2
Set textobj = acadapp.ActiveDocument.ModelSpace.AddText(textstring, insertionpoint, height)
textobj.Update
ZoomExtents
End Sub
相关文章
- 2021-08-01Visual Basic与AutoCAD二次开发PDF下载
- 2021-08-01Mastering AutoCAD Civil 3D 2010PDF下载
- 2021-07-12Maya总动员:动画编程篇 张宝贵等PDF下载
- 2016-02-22VisualBasic与AutoCAD二次开发教程下载
- 2016-02-17AutoCAD2010中文版入门与提高PDF高清版下载
- 2013-03-01AutoCAD三维转二维视频操作过程
- 2012-05-10天正建筑8使用操作练习免费下载
- 2012-05-07天正电气CAD上机操作免费下载
- 2012-02-25某污水厂全套施工图(CASS工艺)
- 2011-08-08彻底解决CAD字体不认的问题