- 积分
- 808
- 明经币
- 个
- 注册时间
- 2012-10-26
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 yealor 于 2022-12-22 16:47 编辑
需求: 对坐标网格进行批量标注
cad版本:2016
Sub Start_WangGeZuoBiao()
Dim Px As AcadEntity 'AcadObject ' AcadLine
Dim PLX As AcadLine
Dim PtPick As Variant
On Error GoTo Err_handle
Do While ThisDrawing.SelectionSets.Count > 0 '选择集使用完了就要删除,图中原有的选择集
ThisDrawing.SelectionSets.Item(0).Delete
Loop
Dim XuanZeji As AcadSelectionSet
Set XuanZeji = ThisDrawing.SelectionSets.Add("XZJ") '添加选择集,选择集名为XZJ
Dim ft(0) As Integer
Dim fd(0) As Variant
ft(0) = 0
fd(0) = "Line"
XuanZeji.SelectOnScreen ft, fd '在屏幕上批量选择对象,但只选直线到选择集中
Dim JiaoDian As Variant
'''Dim Str As String
Dim Yi(0) As AcadEntity
'''Dim Yd(0) As AcadEntity
'''Dim tt As AcadEntity
Dim TXT As AcadText
For Each Px In XuanZeji
Set Yi(0) = Px
''' Debug.Print Px.Handle
XuanZeji.RemoveItems Yi '在选择集中删掉本图元,减少自和自己比较有没有交点
For Each PLX In XuanZeji
''' Debug.Print PLX.Handle '看看在和什么图元比较
JiaoDian = Px.IntersectWith(PLX, acExtendNone) '计算交点坐标
If UBound(JiaoDian) > 0 Then '判断交点是否存在
ThisDrawing.ModelSpace.AddText "N" & Format(JiaoDian(0), "0.000"), JiaoDian, 1
Set TXT = ThisDrawing.ModelSpace.AddText("S" & Format(JiaoDian(1), "0.000"), JiaoDian, 1)
TXT.Rotate JiaoDian, (270 * 3.14159265358979 / 180) '''弧度旋转
''' Str = JiaoDian(0) & "," & JiaoDian(1)
''' Debug.Print Str
''' Set Yd(0) = PLX
''' Debug.Print Px.Handle
'''' XuanZeji.RemoveItems Yi '此处不能移除配对项,否则在循环过程中会出现跳过的现象
''' For Each tt In XuanZeji
''' Debug.Print tt.Handle
''' Next
Exit For
End If
Next
Next
Err_handle:
End Sub
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|