[求助]文本样式加不到图中
<P>高人好:<BR> 我利用vb在CAD中出图(公路纵断面),我事先用下面的getpnt()过程取点,画好了图框,在编辑了下面这个添加文本的程序时,CAD中却不显示,而单行文本就很容易显示出来,请您给看看,指点一下:<BR>Public Sub getpnt(basepnt As Variant, distance As Double, angle As Double, pnt1() As Double)<BR>pnt1(0) = basepnt(0) + distance * Cos(angle * pi / 180)<BR>pnt1(1) = basepnt(1) + distance * Sin(angle * pi / 180)<BR>pnt1(2) = 0<BR>End Sub</P><P><BR>'在CAD中画直线<BR>Public Function addln(basepnt As Variant, _<BR>length As Double, lnangle As Double) As AcadLine<BR>Dim pnt(0 To 2) As Double<BR>Call getpnt(basepnt, length * scales, lnangle, pnt())<BR>Set addln = zdmms.AddLine(basepnt, pnt)<BR>End Function<BR><BR>Public Sub drawtk()<BR>'绘制外图框<BR>Dim pnt3(0 To 2) As Double, pnt4(0 To 2) As Double<BR>Dim wtkln1 As AcadLine, wtkln2 As AcadLine, wtkln3 As AcadLine, wtkln4 As AcadLine<BR>Dim ntkln1 As AcadLine, ntkln2 As AcadLine, ntkln3 As AcadLine, ntkln4 As AcadLine<BR>Dim l1 As AcadLine, l2 As AcadLine, l3 As AcadLine, l4 As AcadLine, l5 As AcadLine, _<BR>l6 As AcadLine, l7 As AcadLine, l8 As AcadLine, l9 As AcadLine, l10 As AcadLine, _<BR>l11 As AcadLine, l12 As AcadLine, l13 As AcadLine, l14 As AcadLine, l15 As AcadLine<BR>Dim zhuanye As AcadText, sheji As AcadText, shenhe As AcadText<BR>Dim tuhao As AcadText, bili As AcadText, riqi As AcadText</P>
<P>Dim pt5(0 To 2) As Double, pt6(0 To 2) As Double, pt7(0 To 2) As Double<BR>Dim pt8(0 To 2) As Double, pt9(0 To 2) As Double, pt10(0 To 2) As Double<BR>Dim dist As Double, jd As Double<BR>Dim l16 As AcadLine, l17 As AcadLine, l18 As AcadLine, l19 As AcadLine<BR>pnt3(0) = 0<BR>pnt3(1) = 0<BR>pnt3(2) = 0<BR>pnt4(0) = 25<BR>pnt4(1) = 10<BR>pnt4(2) = 0<BR>Set wtkln1 = addln(pnt3, 297 / scales, 90)<BR>Set wtkln2 = addln(wtkln1.EndPoint, 420 / scales, 0)<BR>Set wtkln3 = addln(wtkln2.EndPoint, 297 / scales, 270)<BR>Set wtkln4 = addln(wtkln3.EndPoint, 420 / scales, 180)<BR>'绘制内图框<BR>Set ntkln1 = addln(pnt4, 277 / scales, 90)<BR>Set ntkln2 = addln(ntkln1.EndPoint, 385 / scales, 0)<BR>Set ntkln3 = addln(ntkln2.EndPoint, 277 / scales, 270)<BR>Set ntkln4 = addln(ntkln3.EndPoint, 385 / scales, 180)<BR>Dim p1(0 To 2) As Double<BR>Dim pnt5(0 To 2) As Double, pnt6(0 To 2) As Double, pnt7(0 To 2) As Double, _<BR>pnt8(0 To 2) As Double, pnt9(0 To 2) As Double, pnt11(0 To 2) As Double<BR>Dim pt1(0 To 2) As Double, pt2(0 To 2) As Double, pt3(0 To 2) As Double, pt4(0 To 2) As Double, _<BR>pt11(0 To 2) As Double, pt12(0 To 2) As Double, pt13(0 To 2) As Double, pt14() As Double<BR>Call getpnt(pnt4, 10, 90, p1)<BR>Set l1 = addln(p1, 385 / scales, 0) '横线<BR>'各栏分隔线<BR>Call getpnt(pnt4, 53, 0, pnt5)<BR>Set l2 = addln(pnt5, 10 / scales, 90)<BR>Call getpnt(pnt5, 32, 0, pnt6)<BR>Set l3 = addln(pnt6, 10 / scales, 90)<BR>Call getpnt(pnt6, 20, 0, pnt7)<BR>Set l4 = addln(pnt7, 10 / scales, 90)<BR>Call getpnt(pnt7, 30, 0, pnt8)<BR>Set l5 = addln(pnt8, 10 / scales, 90)<BR>Call getpnt(pnt8, 20, 0, pnt9)<BR>Set l6 = addln(pnt9, 10 / scales, 90)<BR>Call getpnt(pnt9, 30, 0, pnt11)<BR>Set l7 = addln(pnt11, 10 / scales, 90)<BR>Call getpnt(pnt11, 20, 0, pt1)<BR>Set l8 = addln(pt1, 10 / scales, 90)<BR>Call getpnt(pt1, 30, 0, pt2)<BR>Set l9 = addln(pt2, 10 / scales, 90)<BR>Call getpnt(pt2, 20, 0, pt3)<BR>Set l10 = addln(pt3, 10 / scales, 90)<BR>Call getpnt(pt3, 30, 0, pt4)<BR>Set l11 = addln(pt4, 10 / scales, 90)<BR>Call getpnt(pt4, 20, 0, pt11)<BR>Set l12 = addln(pt11, 10 / scales, 90)<BR>Call getpnt(pt11, 30, 0, pt12)<BR>Set l13 = addln(pt12, 10 / scales, 90)<BR>Call getpnt(pt12, 20, 0, pt13)<BR>Set l14 = addln(pt13, 10 / scales, 90)<BR>Call getpnt(pt13, 30, 0, pt14)<BR>Set l15 = addln(pt14, 10 / scales, 90)<BR>'插入标题栏文字<BR>'定义CAD中的文字<BR>Dim pt5(0 To 2) As Double, pt6(0 To 2) As Double, pt7(0 To 2) As Double<BR>Dim pt8(0 To 2) As Double, pt9(0 To 2) As Double, pt10(0 To 2) As Double<BR>Dim dist As Double, jd As Double</P>
<P>'定义插入点<BR>dist = Sqr(20 * 20 + 10 * 10)<BR>jd = 180 * Atn(10 / 20) / pi<BR>'定义标题栏文字的样式为仿宋体。并将文字样式层定为当前图层。<BR>Set wzysh = zdm.TextStyles.Add("仿宋体")<BR>wzysh.fontFile = "C:\WINDOWS\Fonts\simfang.ttf"<BR>zdm.ActiveTextStyle = wzysh<BR>'指定文字的插入点<BR>Call getpnt(pnt6, dist / 2, jd, pt5)<BR>Call getpnt(pnt8, dist / 2, jd, pt6)<BR>Call getpnt(pnt11, dist / 2, jd, pt7)<BR>Call getpnt(pt2, dist / 2, jd, pt8)<BR>Call getpnt(pt4, dist / 2, jd, pt9)<BR>Call getpnt(pt12, dist / 2, jd, pt10)</P>
<P>'将字体层设置为当前层,在标题栏中添加文字,并使文字在每个标题栏图框里居中显示<BR>Dim layerziti As AcadLayer<BR>Call addlayer<BR>Set layerziti = zdm.Layers("字体")<BR>Set layerziti = zdm.ActiveLayer<BR>Set zhuanye = zdmms.AddText("专业", pt5, 3)<BR>zhuanye.Alignment = acAlignmentMiddleCenter<BR>zhuanye.Move pnt3, pt5<BR>Set sheji = zdmms.AddText("设计", pt7, 3)<BR>sheji.Alignment = acAlignmentMiddleCenter</P>
<P>Set shenhe = zdmms.AddText("审核", pt9, 3)<BR>shenhe.Alignment = acAlignmentMiddleCenter<BR>shenhe.Move pnt3, pt9<BR>Set tuhao = zdmms.AddText("图号", pt6, 3)<BR>tuhao.Alignment = acAlignmentMiddleCenter<BR>tuhao.Move pnt3, pt6<BR>Set bili = zdmms.AddText("比例", pt8, 3)<BR>bili.Alignment = acAlignmentMiddleCenter<BR>bili.Move pnt3, pt8<BR>Set riqi = zdm.ModelSpace.AddText("日期", pt10, 3)<BR>riqi.Alignment = acAlignmentMiddleCenter<BR>riqi.Move pnt3, pt10<BR>end sub<BR>private sub form_load()<BR>call addtxt<BR>end sub<BR>上面的画图框是没错的,下面的加文本就加不了。</P>
页:
[1]