cqy 发表于 2005-8-11 14:08:00

X=123,如何化为123?

<P>CAD中的座标X=123,Y=567,可能是单行或多行文本还是图块,如何化为123,567?</P>

wyj7485 发表于 2005-8-11 18:23:00

<P>用left ,mid ,right和cint</P>
<P>先转换为单行文本.</P>
<P>a="X=123"</P>
<P>b=right(a,3)</P>
<P>c=cint(b)</P>
<P>&nbsp;</P>

y1982_0 发表于 2005-8-11 19:05:00

<P>唉,好不容易会一个,还。。。</P>

cqy 发表于 2005-8-12 13:10:00

多行文本没问题,但带属性图块怎样化为单行文本?

wyj7485 发表于 2005-8-12 14:36:00

直接提取其属性就可以啊.

cqy 发表于 2005-8-12 15:35:00

<P>Public Sub text()<BR>&nbsp;&nbsp;&nbsp; On Error Resume Next<BR>&nbsp;&nbsp;&nbsp; Dim ptInsert As Variant<BR>&nbsp;&nbsp;&nbsp; Dim txtStr As String<BR>&nbsp;&nbsp;&nbsp; Dim height As Double<BR>&nbsp;&nbsp;&nbsp; Dim width As Double<BR>&nbsp;&nbsp;&nbsp; Dim angle As Double<BR>&nbsp;&nbsp;&nbsp; Dim SSet As AcadSelectionSet<BR>&nbsp;&nbsp;&nbsp; If Not IsNull(ThisDrawing.SelectionSets.Item("this")) Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set SSet = ThisDrawing.SelectionSets.Item("this")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SSet.Delete<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Set SSet = ThisDrawing.SelectionSets.Add("this")<BR>&nbsp;&nbsp;&nbsp; Dim FilterType(0 To 4) As Integer<BR>&nbsp;&nbsp;&nbsp; Dim FilterData(0 To 4) As Variant<BR>&nbsp;&nbsp;&nbsp; FilterType(0) = -4<BR>&nbsp;&nbsp;&nbsp; FilterData(0) = "&lt;or"<BR>&nbsp;&nbsp;&nbsp; FilterType(1) = 0<BR>&nbsp;&nbsp;&nbsp; FilterData(1) = "text"<BR>&nbsp;&nbsp;&nbsp; FilterType(2) = 0<BR>&nbsp;&nbsp;&nbsp; FilterData(2) = "TEXT"<BR>&nbsp;&nbsp;&nbsp; FilterType(3) = 0<BR>&nbsp;&nbsp;&nbsp; FilterData(3) = A<BR>&nbsp;&nbsp;&nbsp; FilterType(4) = -4<BR>&nbsp;&nbsp;&nbsp; FilterData(4) = "or&gt;"<BR>&nbsp;&nbsp;&nbsp; SSet.Select acSelectionSetAll, , , FilterType, FilterData<BR>&nbsp;&nbsp;&nbsp; Dim objText As AcadText<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Each objText In SSet<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ptInsert = objText.InsertionPoint<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtStr = objText.TextString<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height = objText.height<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; angle = objText.Rotation<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objText.Delete<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A = txtStr<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim B As Double<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; B = Right(A, 3)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim C As Double<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C = CInt(B)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddTextHA C, ptInsert, height, angle<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objText.Update<BR>&nbsp;&nbsp;&nbsp; Next<BR>&nbsp;&nbsp;&nbsp; SSet.Delete<BR>End Sub</P>
<P>X=123可以变为123,X=12.3变为2,X=1.23变为0</P>
页: [1]
查看完整版本: X=123,如何化为123?