找回密码
 [加入论坛]
查看: 1526|回复: 1

[转帖]TEXT文本水平,垂直分解

[复制链接]
2443725 发表于 2004-7-14 15:07 | 显示全部楼层 |阅读模式
<FONT face=宋体>'text字符串分解-垂直排列   修改by陌生人
'修改 from lzh
Public Sub Textexv()
Dim pText As AcadEntity
Dim pnt
ThisDrawing.Utility.GetEntity pText, pnt
Dim str As String
str = pText.TextString
Dim pStr As String
Dim Txth As Double
Txth = pText.Height
Dim inspt As ACAD_POINT
inspt = pText.InsertionPoint
Dim polarPnt As ACAD_POINT
polarPnt = ThisDrawing.Utility.PolarPoint(inspt, (pText.Rotation + 1.57079), Txth)
Do While Len(str) &lt;&gt; 0
pStr = pStr &amp; Left(str, 1) &amp; "\P"
str = Right(str, Len(str) - 1)
Loop
Set mT = ThisDrawing.ModelSpace.AddMText(polarPnt, 0, pStr)
mT.Height = Txth
mT.Rotation = pText.Rotation
mT.StyleName = pText.StyleName
ThisDrawing.SendCommand "Explode" &amp; vbCr &amp; "l" &amp; vbCr &amp; vbCr
pText.Delete
End Sub


'text字符串分解-水平排列  by陌生人
Public Sub Textexh()
Dim pText As AcadEntity
Dim pnt
ThisDrawing.Utility.GetEntity pText, pnt
Dim str As String
str = pText.TextString
Dim pStr As String
Dim Txth As Double
Txth = pText.Height
Dim inspt As ACAD_POINT
inspt = pText.InsertionPoint
Dim polarPnt As ACAD_POINT
polarPnt = ThisDrawing.Utility.PolarPoint(inspt, (pText.Rotation + 1.57079), Txth)
Do While Len(str) &lt;&gt; 0
pStr = pStr &amp; Left(str, 1) &amp; "\H1X"
str = Right(str, Len(str) - 1)
Loop
Set mT = ThisDrawing.ModelSpace.AddMText(polarPnt, 0, pStr)
mT.Height = Txth
mT.Rotation = pText.Rotation
mT.StyleName = pText.StyleName
ThisDrawing.SendCommand "Explode" &amp; vbCr &amp; "l" &amp; vbCr &amp; vbCr
pText.Delete
End Sub
</FONT>
[此贴子已经被作者于2004-7-14 7:07:59编辑过]

 楼主| 2443725 发表于 2004-7-14 15:07 | 显示全部楼层
<FONT face=宋体 size=2>偶也来发个Lisp处理汉字的,:)
;转换字符串为字符表,相当与VB.Net的ToChar -by 雪山飞狐
(defun Str2Chrs(strA / pAsc)
(setq pAsc (if (&lt; (ascii strA) 128) 1 2))
(cond ((&gt; (strlen strA) pAsc)
(cons (substr strA 1 pAsc) (str2Chrs (substr strA (1+ pAsc)))))
((list (substr strA 1 pAsc))))
)

;合并字符表,并加入分隔符,相当与VB的同名函数 -by 雪山飞狐
(defun Join(Chrs fchr / pStr)
(setq pStr "")
(foreach i Chrs (setq pStr (strcat pStr i fchr)))
(substr pStr 1 (- (strlen pStr) (strlen fchr)))
)</FONT>
回复 顶 踩

使用道具 举报

您需要登录后才可以回帖 登录 | [加入论坛]

本版积分规则

手机版|化工技术网- 赠人玫瑰 手有余香 ( 苏ICP备14035884号 )

GMT+8, 2026-12-1 16:01

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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