明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1506|回复: 5

X=123,如何化为123?

[复制链接]
发表于 2005-8-11 14:08:00 | 显示全部楼层 |阅读模式

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

发表于 2005-8-11 18:23:00 | 显示全部楼层

用left ,mid ,right和cint

先转换为单行文本.

a="X=123"

b=right(a,3)

c=cint(b)

 

发表于 2005-8-11 19:05:00 | 显示全部楼层

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

 楼主| 发表于 2005-8-12 13:10:00 | 显示全部楼层
多行文本没问题,但带属性图块怎样化为单行文本?
发表于 2005-8-12 14:36:00 | 显示全部楼层
直接提取其属性就可以啊.
 楼主| 发表于 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) = "<or"
    FilterType(1) = 0
    FilterData(1) = "text"
    FilterType(2) = 0
    FilterData(2) = "TEXT"
    FilterType(3) = 0
    FilterData(3) = A
    FilterType(4) = -4
    FilterData(4) = "or>"
    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

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-27 12:48 , Processed in 0.164728 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表