明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: njcknfy

自己动手,改进CASS中欠缺的功能

    [复制链接]
发表于 2005-11-29 21:54 | 显示全部楼层

VBA编写的坐标标注程序(测量用)

Public Sub PTBZ()
On Error Resume Next
'创建名为"坐标标注"的新图层
    Dim layerObj As AcadLayer
    Set layerObj = ThisDrawing.Layers.Add("坐标标注")
    layerObj.Color = acRed
'设置为当前图层
    Dim newlayer As AcadLayer
    Set newlayer = ThisDrawing.Layers("坐标标注")
    ThisDrawing.ActiveLayer = newlayer

'定义线
Dim plineObj As AcadLWPolyline '二维轻量多段线
Dim points(0 To 5) As Double
Dim spnt As Variant  '需标注点
Dim epnt As Variant
Dim textobj As AcadText
Dim BZ As AcadTextStyle    '文字样式
Dim H As Double            '文字高度
Dim WZ As Double           '文字位置
Dim xins(0 To 2) As Double 'x坐标插入点
Dim yins(0 To 2) As Double 'y坐标插入点

Set BZ = ThisDrawing.TextStyles.Add("BZ") '设定文字样式
Set BZ = ThisDrawing.ActiveTextStyle
BZ.width = 0.8
BZ.fontFile = "romant.shx"


On Error GoTo err
H = ThisDrawing.Utility.GetReal("文字高度:")

'循环
    Dim counter As Integer
    For counter = 0 To 50

spnt = ThisDrawing.Utility.GetPoint(, vbCrLf & "标注点:")
epnt = ThisDrawing.Utility.GetPoint(spnt, vbCr & "标注坐标")
If IsEmpty(spnt) Then Exit Sub
If H < 5 Then                  '调整文字位置
WZ = 1
Else
WZ = Int(H / 5)
End If

If epnt(0) > spnt(0) Then      '定位文字位置
xins(0) = epnt(0) + 0.5: xins(1) = epnt(1) + WZ: xins(2) = 0
yins(0) = epnt(0) + 0.5: yins(1) = epnt(1) - (WZ + H): yins(2) = 0
Else
xins(0) = epnt(0) - H * 9.1: xins(1) = epnt(1) + 1: xins(2) = 0
yins(0) = epnt(0) - H * 9.1: yins(1) = epnt(1) - (H + 1): yins(2) = 0
End If

x = Format(spnt(1), "####0.000")
y = Format(spnt(0), "####0.000")

points(0) = spnt(0): points(1) = spnt(1)
points(2) = epnt(0): points(3) = epnt(1)
If epnt(0) > spnt(0) Then
points(4) = epnt(0) + H * 9.1: points(5) = epnt(1)
Else
points(4) = epnt(0) - H * 9.1: points(5) = epnt(1)
End If

Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points) '二维轻量多段线
Set textobj = ThisDrawing.ModelSpace.AddText("X=" & x, xins, H)
textobj.Color = acGreen

Set textobj = ThisDrawing.ModelSpace.AddText("Y=" & y, yins, H)
textobj.Color = acGreen


Next

err:
End

End Sub

发表于 2005-11-30 16:41 | 显示全部楼层

njcknfy,你好

谢谢你发的坐标标注程序,能不能搞得注记X、Y之间的一水平线的长度与坐标数字串一样长?谢谢!

发表于 2005-12-8 15:55 | 显示全部楼层

我是干工程测量的,以前比较少用cass,看版主技术了得,敢问一下怎么学得

发表于 2005-12-17 22:18 | 显示全部楼层
cass5.1作方格网2条边不能和设计的重合,(既边不在整数上)如何办?
发表于 2005-12-22 10:30 | 显示全部楼层

njcknfy,你好

    请给编个能在CAD2004或CAD2005中自动注记面积,能按要求数量调整面积的程序(CASS中有这程序)。谢谢!

发表于 2006-1-7 14:55 | 显示全部楼层
google earth 太好了
发表于 2006-1-24 14:48 | 显示全部楼层
本帖最后由 作者 于 2006-2-6 10:33:12 编辑

搂主一定对CASS很熟悉,请你给我解释一下...\SYSTEM下的index.ini和work.def都记录的是什么内容,我现在需要做一个从国标4位码的CAD图件转为存CASS的程序,请给予帮助。谢谢!
发表于 2006-2-25 19:54 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2006-3-26 12:45 | 显示全部楼层

看来楼主对Auto CAD的熟悉程度达到了非一般的境界了啊!

我想请问楼主:

在Auto CAD中如何批量绘制1:10000的图框(54坐标系和80坐标系)

谢谢楼住了!!

caizhiminglcy@yahoo.com.cn

发表于 2006-4-5 12:08 | 显示全部楼层

高贴!虽然我不是搞测量的!

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

本版积分规则

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

GMT+8, 2024-4-25 06:59 , Processed in 1.022623 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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