- 积分
- 1147
- 明经币
- 个
- 注册时间
- 2004-8-4
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2005-1-21 15:17:00
|
显示全部楼层
多谢你的提醒啊,我倒是忘了用几何的办法来判断了。多谢多谢。我也把源代码贴在这里吧,楼下的也可以看出其中的关系。呵呵
Sub GetTextWidth() Dim Obj As AcadObject Dim ObjText As AcadText, ObjLWLine As AcadLWPolyline, ObjLWLine2 As AcadLWPolyline Dim InsertPoint(0 To 2) As Double, MinPoint As Variant, MaxPoint As Variant For Each Obj In ThisDrawing.ModelSpace Obj.Delete Next InsertPoint(0) = 10 InsertPoint(1) = 10 InsertPoint(2) = 0 Set ObjText = ThisDrawing.ModelSpace.AddText("123456", InsertPoint, 10) ObjText.GetBoundingBox MinPoint, MaxPoint Set ObjLWLine = DrawLWPolylinebyTwoPoints(ThisDrawing, MinPoint, MaxPoint) Set ObjLWLine2 = ObjLWLine.Copy ObjText.Rotate InsertPoint, 30 * 3.1415926 / 180 ObjLWLine.Rotate InsertPoint, 30 * 3.1415926 / 180 ObjText.GetBoundingBox MinPoint, MaxPoint Set ObjLWLine = DrawLWPolylinebyTwoPoints(ThisDrawing, MinPoint, MaxPoint) ZoomExtents
End Sub
'根据两个角点绘制LWPolyline Public Function DrawLWPolylinebyTwoPoints(AcadDoc As AcadDocument, Pt1 As Variant, Pt2 As Variant) As AcadLWPolyline On Error Resume Next Dim PtArray(0 To 7) As Double PtArray(0) = Pt1(0): PtArray(1) = Pt1(1) PtArray(2) = Pt2(0): PtArray(3) = Pt1(1) PtArray(4) = Pt2(0): PtArray(5) = Pt2(1) PtArray(6) = Pt1(0): PtArray(7) = Pt2(1) Set DrawLWPolylinebyTwoPoints = AcadDoc.ModelSpace.AddLightWeightPolyline(PtArray) DrawLWPolylinebyTwoPoints.Closed = True End Function
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|