y1982_0 发表于 2005-8-6 10:35:00

求助:多行文本的字高在程序中如何设置?

谢谢啦,等待中

y1982_0 发表于 2005-8-6 11:12:00

<PRE class=Code>Sub Example_AddMtext()
    ' This example creates an MText object in model space.
   
    Dim MTextObj As AcadMText
    Dim corner(0 To 2) As Double
    Dim width As Double
    Dim text As String
    corner(0) = 0#: corner(1) = 10#: corner(2) = 0#
    width = 10
    text = "This is the text String for the mtext Object"

    ' Creates the mtext Object
    Set MTextObj = ThisDrawing.ModelSpace.AddMText(corner, width, text)
    ZoomAll
   
End Sub</PRE><PRE class=Code>这程序里也没有设置字高的?</PRE>

王咣生 发表于 2005-8-6 11:12:00

<P>Sub Example_Height()<BR>&nbsp;&nbsp;&nbsp; ' This example creates a text object in model space.<BR>&nbsp;&nbsp;&nbsp; ' It then changes the height of the text object.</P>
<P>&nbsp;&nbsp;&nbsp; Dim textObj As AcadText<BR>&nbsp;&nbsp;&nbsp; Dim textString As String<BR>&nbsp;&nbsp;&nbsp; Dim insertionPoint(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim height As Double<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' Define the text object<BR>&nbsp;&nbsp;&nbsp; textString = "Hello, World."<BR>&nbsp;&nbsp;&nbsp; insertionPoint(0) = 3: insertionPoint(1) = 3: insertionPoint(2) = 0<BR>&nbsp;&nbsp;&nbsp; height = 0.5<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' Create the text object in model space<BR>&nbsp;&nbsp;&nbsp; Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, height)<BR>&nbsp;&nbsp;&nbsp; ZoomAll<BR>&nbsp;&nbsp;&nbsp; MsgBox "The text height is " &amp; textObj.height, vbInformation, "Height Example"<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' Change the value of the Height to 1<BR>&nbsp;&nbsp;&nbsp; textObj.<FONT color=#0938f7><STRONG>height</STRONG></FONT> = 6<BR>&nbsp;&nbsp;&nbsp; textObj.Update<BR>&nbsp;&nbsp;&nbsp; MsgBox "The text height is set to " &amp; textObj.height, vbInformation, "Height Example"<BR>&nbsp;&nbsp;&nbsp; <BR>End Sub</P>

y1982_0 发表于 2005-8-6 11:21:00

谢谢大哥回复,你写的是单行文本的高度设置,我现在只能用MTEXT,因为我在做引线标注,引线标注里面只识别多行文本,希望得到解答,多行文本的高度设置?

王咣生 发表于 2005-8-6 11:34:00

<P>Sub Example_AddMtext()<BR>&nbsp;&nbsp;&nbsp; ' This example creates an MText object in model space.<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim MTextObj As AcadMText<BR>&nbsp;&nbsp;&nbsp; Dim corner(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim width As Double<BR>&nbsp;&nbsp;&nbsp; Dim text As String<BR>&nbsp;&nbsp;&nbsp; corner(0) = 0#: corner(1) = 10#: corner(2) = 0#<BR>&nbsp;&nbsp;&nbsp; width = 10<BR>&nbsp;&nbsp;&nbsp; text = "This is the text String for the mtext Object"</P>
<P>&nbsp;&nbsp;&nbsp; ' Creates the mtext Object<BR>&nbsp;&nbsp;&nbsp; Set MTextObj = ThisDrawing.ModelSpace.AddMText(corner, width, text)<BR>&nbsp;&nbsp;&nbsp; <FONT color=#f70909><STRONG>MTextObj.Height = 20</STRONG></FONT><BR>&nbsp;&nbsp;&nbsp; ZoomAll<BR>&nbsp;&nbsp;&nbsp; <BR>End Sub</P>

y1982_0 发表于 2005-8-6 14:27:00

好用,谢谢楼上兄台,结帖
页: [1]
查看完整版本: 求助:多行文本的字高在程序中如何设置?