ywy6688 发表于 2006-5-23 15:50:00

同样使用多行文字,且字高一样,结果为什么不同

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

ywy6688 发表于 2006-6-6 08:20:00

,专家们 :肯请得到你们的帮助。会者不难。再次谢谢

xinghesnak 发表于 2006-6-6 09:26:00

其实问题很简单,( CADobj2.AttachmentPoint = 2'居中 1_靠左,3_靠右   )这句话是将文字在宽度方向上居中,由于你的文字宽度不同,所以文字居中的位置不一样。当然高度就不一样了。。。。。
页: [1]
查看完整版本: 同样使用多行文字,且字高一样,结果为什么不同