明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2542|回复: 3

旋转文字方向怎末无效

[复制链接]
发表于 2004-5-26 21:47:00 | 显示全部楼层 |阅读模式
我用VBA编制的粗糙度程序,数值不能随粗糙度符号方向改变而改变,请大家帮忙看看。谢谢了!! Sub rough()
Dim p1(0 To 2) As Double
Dim p2(0 To 2) As Double
Dim p3(0 To 2) As Double
Dim p0 As Variant
Dim a, a1, a2 As Double
Dim h1 As Double
Dim text As String
On Error Resume Next
p0 = ThisDrawing.Utility.GetPoint(, "请输入粗糙度符号插入点:")
a = ThisDrawing.Utility.GetAngle(, "请输入粗糙度符号旋转角:")
text = ThisDrawing.Utility.GetString(1, vbCrLf & "请输入粗糙度符号Ra值:")
h = ThisDrawing.Utility.GetReal("请输入粗糙度符号文本字符高度:")
h1 = 1.4 * h / Cos(30 * 3.14159 / 180)
p1(0) = p0(0) + 2 * h1 * Cos(60 * 3.14159 / 180 + a)
p1(1) = p0(1) + 2 * h1 * Sin(60 * 3.14159 / 180 + a)
p1(2) = 0

p2(0) = p0(0) - h1 * Cos(60 * 3.14159 / 180 - a)
p2(1) = p0(1) + h1 * Sin(60 * 3.14159 / 180 - a)
p2(2) = 0

p3(0) = p0(0) + h1 * Cos(60 * 3.14159 / 180 + a)
p3(1) = p0(1) + h1 * Sin(60 * 3.14159 / 180 + a)
p3(2) = 0

Dim line1 As AcadLine
Dim line2 As AcadLine
Dim line3 As AcadLine
Set line1 = ThisDrawing.ModelSpace.AddLine(p0, p2)
Set line2 = ThisDrawing.ModelSpace.AddLine(p2, p3)
Set line3 = ThisDrawing.ModelSpace.AddLine(p0, p1)
ThisDrawing.Application.ZoomExtents


Dim tobject As AcadText
tobject = ThisDrawing.ModelSpace.AddText(text, p2, h)
ThisDrawing.Application.ZoomExtents

a2 = 180 * a / 3.14159
If a2 > 90 And a2 <= 270 Then
a1 = a - 3.14159
ElseIf a2 > 270 Then
a1 = a - 2 * 3.14159
ElseIf a2 = -90 Then
a1 = 3.14159 / 2
ElseIf a2 < 90 Then
a1 = a

End If
tobject.Alignment = acAlignmentLeft
tobject.Rotation = a1
tobject.Update

End Sub
发表于 2004-5-27 12:32:00 | 显示全部楼层
你把它做成属性块插入不就玩了
发表于 2004-5-27 15:33:00 | 显示全部楼层
楼主,Rotation,应该给PI的
发表于 2004-5-27 16:56:00 | 显示全部楼层
错在这句(跟踪发现后面tobject是空的)



tobject = ThisDrawing.ModelSpace.AddText(text, p2, h)


创建是完成了,但是没有赋给变量,而且这是不报错的.


对象赋值别忘了用Set


Set tobject = ThisDrawing.ModelSpace.AddText(text, p2, h)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-1 04:53 , Processed in 0.142340 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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