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

X=123,如何化为123?

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

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

用left ,mid ,right和cint
先转换为单行文本.
a="X=123"
b=right(a,3)
c=cint(b)

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

唉,好不容易会一个,还。。。

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

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

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

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

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

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