各位专家:你们好!
我定义了一个多行文字的样式,多次调用该多行文字生成相关内容,但文字的高度为什么不一致,是CAD出毛病了吗?我用的是CAD2004
程序部分代码如下:
Dim cad1 As Object 'AutoCAD对象 Dim cad2 As Object 'AutoCAD当前绘图模型区对象 Dim CADobj1 As Object, CADobj2 As Object, CADobj3 As Object '定义备用的三个CAD对象 Dim CADpoint1(3) As Double, CADpoint2(3) As Double, CADpoint3(3) As Double, CADpoint4(3) As Double '定义备用的三个点变量 必须只能是数据型的 Dim eg0point5(6) As Double '缓和曲线起终点坐标 Dim Ppt1(3) As Double, Ppt2(3) As Double, Ppt3(3) As Double, Pptcen(3) As Double, Ppt3R As Double, AngS As Double, AngE As Double '已知三点求圆弧参数 Set cad1 = CreateObject("autOcad.application") Set cad2 = cad1.ActiveDocument: cad1.ActiveDocument.Utility.InitializeUserInput 1 '该句命令使CAD接收VB的命令,并将在CAD中的输入传入VB的变量中 Dim txtMODE As AcadTextStyle '定义mytxt变量为文本样式 Dim ddmmss As String, i As Long, j As Long Dim mh As Integer, zh As Integer, dh As Integer Dim dxks As String, dxke As String, lcjsdkkm As String, nowdk As String, lcjskm As String Dim dldlcs As Double, dldlce As Double, dlznow As Double, t1 As Double, t2 As Double Dim lcjsk As Long, lcjsm As Double Dim xhy As Double, yhy As Double, xyh As Double, yyh As Double Set txtMODE = cad2.TextStyles.Add("txtMODE") '建立以名为 txtMODE 的文字样式 txtMODE.fontFile = "c:\windows\fonts\simfang.ttf" '设置字体文件为仿宋体 txtMODE.Height = 5000 '字高 txtMODE.Width = 0.8 '宽高比 txtMODE.ObliqueAngle = cad2.Utility.AngleToReal(0, 0) '倾斜角度(需转为弧度) cad2.ActiveTextStyle = txtMODE '将当前文字样式设置为mytxt
Set CADobj2 = cad2.ModelSpace.AddMText(CADpoint1, 150, jdmnow) '写字
Set CADobj2 = cad2.ModelSpace.AddMText(CADpoint1, 350, "\H 15" + dxks): CADobj2.AttachmentPoint = 2 '居中 1_靠左,3_靠右
Set CADobj2 = cad2.ModelSpace.AddMText(CADpoint1, 200, "\H 15" + jdmnow): CADobj2.AttachmentPoint = 2 '居中 1_靠左,3_靠右
Set CADobj2 = cad2.ModelSpace.AddMText(CADpoint1, 200, "\H 15" + jdmnow): CADobj2.AttachmentPoint = 2 '居中 1_靠左,3_靠右
附:程序多次调用生成的线路图,其中大的文字是不的。我不知道原因在哪,请专家解答。谢谢 |