- UID
- 64353
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-7-12
- 最后登录
- 1970-1-1
|
发表于 2005-11-11 10:06:17
|
显示全部楼层
我的坐标标注程序:(VB写的,刚学二次开发)
Private Sub 坐标注记_Click()
Dim Pnt(0 To 2) As Double
Dim point1 As Variant
Dim point2 As Variant
Dim LineObj1 As AcadLine
Dim LineObj2 As AcadLine
Dim XTxtObj As AcadText
Dim YTxtObj As AcadText
Dim XInsertPnt(0 To 2) As Double
Dim YInsertPnt(0 To 2) As Double
Dim XCoord As String
Dim YCoord As String
Dim deltax As Double
point1 = acaddoc.Utility.GetPoint(, "指定注记点: ")
point2 = acaddoc.Utility.GetPoint(point1, "指定注记位置: ")
If point2(0) > point1(0) Then
deltax = -7
XInsertPnt(0) = point2(0): XInsertPnt(1) = point2(1) + 0.6: XInsertPnt(2) = point2(2)
YInsertPnt(0) = point2(0): YInsertPnt(1) = point2(1) - 1.5: YInsertPnt(2) = point2(2)
Else
deltax = 7
XInsertPnt(0) = point2(0) - deltax: XInsertPnt(1) = point2(1) + 0.5: XInsertPnt(2) = point2(2)
YInsertPnt(0) = point2(0) - deltax: YInsertPnt(1) = point2(1) - 1.2: YInsertPnt(2) = point2(2)
End If
Pnt(0) = point2(0) - deltax: Pnt(1) = point2(1): Pnt(2) = point2(2)
Set LineObj1 = acaddoc.ModelSpace.AddLine(point1, point2)
Set LineObj2 = acaddoc.ModelSpace.AddLine(point2, Pnt)
LineObj1.Layer = "ZJ"
XCoord = point1(1): YCoord = point1(0)
XCoord = Str(QUWEI(Val(XCoord), 3))
YCoord = Str(QUWEI(Val(YCoord), 3))
Set XTxtObj = acaddoc.ModelSpace.AddText(XCoord, XInsertPnt, 1)
Set YTxtObj = acaddoc.ModelSpace.AddText(YCoord, YInsertPnt, 1)
End Sub
Public Function QUWEI(X As Double, Y As Integer) As Double '数据四舍五入取位函数
'X为需要四舍五入的字符串数据,Y为小数点后保留的位数
Dim p As String
Dim g As Integer
Dim dotback As String '小数点后数据
Dim dotbefore As String '小数点前数据
Dim n As String
Dim k As String
p = Str(X)
p = RTrim(LTrim(p))
g = InStr(1, p, ".")
dotbefore = Left(p, g - 1)
dotback = Right$(p, Len(p) - g)
dotback = Left(dotback, Y + 1)
n = Right(dotback, 1)
dotback = Left(dotback, Y)
k = Right(dotback, 1)
dotback = Left(dotback, Y - 1)
If Val(n) >= 5 Then
k = Str(Val(k) + 1)
End If
dotback = dotback + k
QUWEI = Val(dotbefore + "." + dotback)
End Function |
|