乐筑天下

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

[编程交流] 选择

[复制链接]

5

主题

11

帖子

6

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 22:51:13 | 显示全部楼层 |阅读模式
我正在尝试选择具有圆弧部分的多段线对象。我想通过它的边界进行选择。我该怎么做。我可以用数学的方法来做,但是有什么函数吗?
 
[i get arc parts by item1.getbulge(index)…and coordinates item1.coordinates…]
回复

使用道具 举报

5

主题

11

帖子

6

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 23:30:41 | 显示全部楼层
我的解决方案如下:
aaa111b是我的主要
DaireYeNokta是圆弧段的函数计算中心,并在圆弧段的起点和终点之间添加点。
注:为了放大这些中间点,我使用r*1.1半径,而不是半径r(弧段的半径)
 
[!!!]To test my function open a new drawing and add 100 sided polygon and mirror it.(要测试我的功能,请打开一个新图形,添加100边多边形并镜像它。我的main将凸出值放到所有边上。)
 
  1. Sub aaa111b()
  2.    Dim i As Integer, ic As Integer, j As Integer
  3.    Dim item1 As AcadLWPolyline
  4.    Dim item2 As AcadPoint
  5.    Dim icor As Variant
  6.    Dim katsayi As Integer
  7.    Dim mp As Double, mr As Double, b As Double, t As Double, r As Double, c As Double, Derece As Double, acix As Double, xne As Double, yne As Double, xn As Double, yn As Double
  8.    Dim x1 As Double, x2 As Double, x3 As Double, y1 As Double, y2 As Double, y3 As Double, xc As Double, yc As Double, xkts As Double, ykts As Double
  9.    Dim insertionPnt(0 To 2) As Double, BulgeDeger As Double
  10.    While ThisDrawing.ModelSpace.Count > 2
  11.        'If ThisDrawing.ModelSpace.Item(2).ObjectName = "AcDbPoint" Then
  12.            ThisDrawing.ModelSpace.Item(2).Delete
  13.        'End If
  14.    Wend
  15.    ThisDrawing.Regen acAllViewports
  16.    For i = 0 To 0
  17.        Set item1 = ThisDrawing.ModelSpace.Item(i)
  18.        icor = item1.Coordinates()
  19.        ic = UBound(icor)
  20.        k = 1
  21.        For j = 0 To ic Step 2
  22.            k = k * -1
  23.            item1.SetBulge j / 2, (j / 200 + 1) * k
  24.            BulgeDeger = item1.GetBulge(j / 2)
  25.            If BulgeDeger <> 0 Then
  26.                x1 = icor(j): y1 = icor(j + 1)
  27.                If j = ic - 1 Then
  28.                    x2 = icor(0): y2 = icor(1)
  29.                Else
  30.                    x2 = icor(j + 2): y2 = icor(j + 3)
  31.                End If
  32.                ic2 = DaireYeNokta(x1, x2, y1, y2, BulgeDeger)
  33.                'insertionPnt(0) = ic2(0): insertionPnt(1) = ic2(1): insertionPnt(2) = 0#
  34.                'ThisDrawing.ModelSpace.AddPoint (insertionPnt)
  35.                ThisDrawing.ModelSpace.AddLightWeightPolyline (ic2)
  36.                ThisDrawing.Regen acAllViewports
  37.            End If
  38.        Next
  39.    Next
  40. End Sub
  41. Private Function DaireYeNokta(x1 As Double, x2 As Double, y1 As Double, y2 As Double, BulgeDeger As Double) As Variant
  42.    Dim item1 As AcadLWPolyline
  43.    Dim katsayi As Integer
  44.    Dim mr As Double, t As Double, r As Double, c As Double, acix As Double, xne As Double, yne As Double, xn As Double, yn As Double
  45.    Dim x3 As Double, y3 As Double, xc As Double, yc As Double, xkts As Double, ykts As Double
  46.    Dim xyzm(19) As Double, tetam As Double
  47.    Dim pii As Double
  48.    pii = Math.Atn(1) * 4
  49.    'eps = 100000
  50.    katsayi = 1
  51.    If Math.Abs(BulgeDeger) > 1 Then
  52.        katsayi = -1
  53.    End If
  54.    aci = Math.Atn(BulgeDeger) * 4
  55.    acix = Math.Abs(aci) / aci
  56.    x3 = (x1 + x2) / 2
  57.    y3 = (y1 + y2) / 2
  58.    c = Math.Sqr((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
  59.    t = Math.Abs(c / (2 * Tan(aci / 2)))
  60.    r = Math.Abs(c / (2 * Sin(aci / 2)))
  61.    yn = y1 - y2
  62.    xn = x1 - x2
  63.    If yn <> 0 Then
  64.        xne = yn / Abs(yn)
  65.    Else
  66.        xne = 1
  67.    End If
  68.    If xn = 0 Then
  69.        xkts = xne
  70.        ykts = 0
  71.    Else
  72.        yne = -xn / Math.Abs(xn)
  73.        mr = Math.Abs((y2 - y1) / (x1 - x2))
  74.        xkts = mr / Math.Sqr(mr * mr + 1) * xne
  75.        ykts = 1 / Math.Sqr(mr * mr + 1) * yne
  76.    End If
  77.    xc = x3 + t * xkts * acix * katsayi
  78.    yc = y3 + t * ykts * acix * katsayi
  79.    tetam = Math.Atn((y1 - yc) / (x1 - xc))
  80.    tetam = Math.Abs(tetam)
  81.    If (x1 - xc) < 0 And (y1 - yc) < 0 Then
  82.        tetam = pii + tetam
  83.    ElseIf (x1 - xc) < 0 Then
  84.        tetam = pii - tetam
  85.    ElseIf (y1 - yc) < 0 Then
  86.        tetam = 2 * pii - tetam
  87.    End If
  88.    For i = 0 To 9
  89.        xyzm(i * 2) = xc + (r * 1.1) * Math.Cos(tetam)
  90.        xyzm(i * 2 + 1) = yc + (r * 1.1) * Math.Sin(tetam)
  91.        tetam = tetam + aci / 9
  92.    Next
  93.    DaireYeNokta = xyzm
  94. End Function
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 23:31:25 | 显示全部楼层
酷节目。
我不确定结果到底是什么,但很酷。
回复

使用道具 举报

5

主题

11

帖子

6

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 23:59:54 | 显示全部楼层
谢谢我为此工作了2天哈哈
一些数学和一些编程呵呵
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-5-25 07:04 , Processed in 2.493929 second(s), 71 queries .

© 2020-2025 乐筑天下

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