乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 86|回复: 11

[编程交流] 向中的多段线添加尺寸标注

[复制链接]

12

主题

26

帖子

15

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
59
发表于 2022-7-6 22:10:50 | 显示全部楼层 |阅读模式
我开始一个例行程序,添加尺寸的折线。。。
 
问题是,它是在直线上创建的,我想将其与直线分开创建,如果有人能帮助我,这将是非常棒的。。。
 
谢谢
 
  1. Sub add_dim_polyline()
  2.    'to add Panel Dimensions
  3.    Dim ThePolyline As AcadLWPolyline
  4.    Dim polyCoords As Variant
  5.    Dim getPoint As Variant
  6.    Dim a As Integer
  7.    Dim polyCoordBound As Integer
  8.    Dim stPoint(2) As Double
  9.    Dim ePoint(2) As Double
  10.    Dim sectionAngle As Double
  11.    Dim textCoords As Variant
  12.    Dim polyDist As Double
  13.    Dim x1, x2, y1, y2 As Double
  14.    Dim objDimAligned As AcadDimAligned
  15.    ThisDrawing.Utility.GetEntity ThePolyline, getPoint, "Select an object"
  16.    polyCoords = ThePolyline.Coordinates
  17.    polyCoordBound = UBound(polyCoords)
  18.    For a = 0 To polyCoordBound - 1 Step 2
  19.        If a = polyCoordBound - 1 Then
  20.            stPoint(0) = polyCoords(a)
  21.            stPoint(1) = polyCoords(a + 1)
  22.            stPoint(2) = 0
  23.            ePoint(0) = polyCoords(0)
  24.            ePoint(1) = polyCoords(1)
  25.            ePoint(2) = 0
  26.        Else
  27.            stPoint(0) = polyCoords(a)
  28.            stPoint(1) = polyCoords(a + 1)
  29.            stPoint(2) = 0
  30.            ePoint(0) = polyCoords(a + 2)
  31.            ePoint(1) = polyCoords(a + 3)
  32.            ePoint(2) = 0
  33.        End If
  34.        x1 = stPoint(0): x2 = ePoint(0)
  35.        y1 = stPoint(1): y2 = ePoint(1)
  36.        polyDist = Sqr(((x1 - x2) ^ 2) + ((y1 - y2) ^ 2))
  37.        sectionAngle = ThisDrawing.Utility.AngleFromXAxis(stPoint, ePoint)
  38.        textCoords = ThisDrawing.Utility.PolarPoint(stPoint, sectionAngle, polyDist / 2)
  39.        Set objDimAligned = ThisDrawing.ModelSpace.AddDimAligned(stPoint, ePoint, textCoords)
  40.    Next a
  41. End Sub
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 22:21:29 | 显示全部楼层
可能与这里显示的加法类似。
 
  1. sectionAngle = ThisDrawing.Utility.AngleFromXAxis(stPoint, ePoint)
  2. textCoords = ThisDrawing.Utility.PolarPoint(stPoint, sectionAngle, polyDist / 2)
  3. textCoords = ThisDrawing.Utility.PolarPoint(textCoords, sectionAngle + 1.57, 1#) 'Rotate PI/2
  4. Set objDimAligned = ThisDrawing.ModelSpace.AddDimAligned(stPoint, ePoint, textCoords)
回复

使用道具 举报

12

主题

26

帖子

15

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
59
发表于 2022-7-6 22:24:00 | 显示全部楼层
  1. Sub add_dim_polyline()
  2.    'to add Panel Dimensions
  3.    Dim ThePolyline As AcadLWPolyline
  4.    Dim polyCoords As Variant
  5.    Dim getPoint As Variant
  6.    Dim a As Integer
  7.    Dim polyCoordBound As Integer
  8.    Dim stPoint(2) As Double
  9.    Dim ePoint(2) As Double
  10.    Dim sectionAngle As Double
  11.    Dim textCoords As Variant
  12.    Dim polyDist As Double
  13.    Dim x1, x2, y1, y2 As Double
  14.    Dim objDimAligned As AcadDimAligned
  15.    Dim textAngle As Double
  16.    ThisDrawing.Utility.GetEntity ThePolyline, getPoint, "Select an object"
  17.    polyCoords = ThePolyline.Coordinates
  18.    polyCoordBound = UBound(polyCoords)
  19.    For a = 0 To polyCoordBound - 2 Step 2
  20.        stPoint(0) = polyCoords(a)
  21.        stPoint(1) = polyCoords(a + 1)
  22.        stPoint(2) = 0
  23.        ePoint(0) = polyCoords(a + 2)
  24.        ePoint(1) = polyCoords(a + 3)
  25.        ePoint(2) = 0
  26.        x1 = stPoint(0): x2 = ePoint(0)
  27.        y1 = stPoint(1): y2 = ePoint(1)
  28.        polyDist = Sqr(((x1 - x2) ^ 2) + ((y1 - y2) ^ 2))
  29.        sectionAngle = ThisDrawing.Utility.AngleFromXAxis(stPoint, ePoint)
  30.        textAngle = sectionAngle + 1.57
  31.        textCoords = ThisDrawing.Utility.PolarPoint(stPoint, sectionAngle + 1.57, 1#)
  32.        Set objDimAligned = ThisDrawing.ModelSpace.AddDimAligned(stPoint, ePoint, textCoords)
  33.    Next a
  34. End Sub
回复

使用道具 举报

15

主题

83

帖子

68

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 22:29:09 | 显示全部楼层
嘿,我刚刚看到这个帖子,你们中有人能告诉我这个VBA是关于什么的吗??绘制多段线时,它显示并写入直线或….的距离。。??
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 22:33:52 | 显示全部楼层
实际上,例程的结构是选择一条多段线并自动向其添加尺寸。
回复

使用道具 举报

15

主题

83

帖子

68

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 22:39:39 | 显示全部楼层
听起来不错,我有一些类似的lisp,你们选择多段线,它把尺寸放在上面(在pline上的两个点之间,等等),你们如何使用VBA??从来没有这样做过,所以我很好奇。。。简单来说,如果你有时间写下如何开始。。
回复

使用道具 举报

12

主题

26

帖子

15

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
59
发表于 2022-7-6 22:48:38 | 显示全部楼层
 
我仍然不被允许在地址上盖章,但在谷歌上搜索“autocad vba”,并将出现一些带有vba介绍的hyperpics.com页面
回复

使用道具 举报

15

主题

83

帖子

68

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 22:53:27 | 显示全部楼层
 
好的,理解。。。Thx人!!!
回复

使用道具 举报

4

主题

10

帖子

6

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 22:56:25 | 显示全部楼层
此代码无法工作,
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 23:00:25 | 显示全部楼层
欢迎来到论坛,Iyant!
你能说得更具体一点吗?你是如何加载/调用代码的?你收到错误信息了吗?最后,但并非最不重要的是,您试图在哪个版本中测试它?
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-4 08:35 , Processed in 1.045986 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表