X=123,如何化为123?
<P>CAD中的座标X=123,Y=567,可能是单行或多行文本还是图块,如何化为123,567?</P> <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> </P> <P>唉,好不容易会一个,还。。。</P> 多行文本没问题,但带属性图块怎样化为单行文本? 直接提取其属性就可以啊. <P>Public Sub text()<BR> On Error Resume Next<BR> Dim ptInsert As Variant<BR> Dim txtStr As String<BR> Dim height As Double<BR> Dim width As Double<BR> Dim angle As Double<BR> Dim SSet As AcadSelectionSet<BR> If Not IsNull(ThisDrawing.SelectionSets.Item("this")) Then<BR> Set SSet = ThisDrawing.SelectionSets.Item("this")<BR> SSet.Delete<BR> End If<BR> Set SSet = ThisDrawing.SelectionSets.Add("this")<BR> Dim FilterType(0 To 4) As Integer<BR> Dim FilterData(0 To 4) As Variant<BR> FilterType(0) = -4<BR> FilterData(0) = "<or"<BR> FilterType(1) = 0<BR> FilterData(1) = "text"<BR> FilterType(2) = 0<BR> FilterData(2) = "TEXT"<BR> FilterType(3) = 0<BR> FilterData(3) = A<BR> FilterType(4) = -4<BR> FilterData(4) = "or>"<BR> SSet.Select acSelectionSetAll, , , FilterType, FilterData<BR> Dim objText As AcadText<BR> For Each objText In SSet<BR> ptInsert = objText.InsertionPoint<BR> txtStr = objText.TextString<BR> height = objText.height<BR> angle = objText.Rotation<BR> objText.Delete<BR> <BR> A = txtStr<BR> Dim B As Double<BR> B = Right(A, 3)<BR> Dim C As Double<BR> C = CInt(B)<BR> AddTextHA C, ptInsert, height, angle<BR> objText.Update<BR> Next<BR> SSet.Delete<BR>End Sub</P>
<P>X=123可以变为123,X=12.3变为2,X=1.23变为0</P>
页:
[1]