mftbrothers 发表于 2022-7-6 22:51:13

选择

我正在尝试选择具有圆弧部分的多段线对象。我想通过它的边界进行选择。我该怎么做。我可以用数学的方法来做,但是有什么函数吗?
 

mftbrothers 发表于 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将凸出值放到所有边上。)
 
Sub aaa111b()
   Dim i As Integer, ic As Integer, j As Integer
   Dim item1 As AcadLWPolyline
   Dim item2 As AcadPoint
   Dim icor As Variant
   Dim katsayi As Integer
   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
   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
   Dim insertionPnt(0 To 2) As Double, BulgeDeger As Double
   While ThisDrawing.ModelSpace.Count > 2
       'If ThisDrawing.ModelSpace.Item(2).ObjectName = "AcDbPoint" Then
         ThisDrawing.ModelSpace.Item(2).Delete
       'End If
   Wend
   ThisDrawing.Regen acAllViewports
   For i = 0 To 0
       Set item1 = ThisDrawing.ModelSpace.Item(i)
       icor = item1.Coordinates()
       ic = UBound(icor)
       k = 1
       For j = 0 To ic Step 2
         k = k * -1
         item1.SetBulge j / 2, (j / 200 + 1) * k
         BulgeDeger = item1.GetBulge(j / 2)
         If BulgeDeger <> 0 Then
               x1 = icor(j): y1 = icor(j + 1)
               If j = ic - 1 Then
                   x2 = icor(0): y2 = icor(1)
               Else
                   x2 = icor(j + 2): y2 = icor(j + 3)
               End If
               ic2 = DaireYeNokta(x1, x2, y1, y2, BulgeDeger)
               'insertionPnt(0) = ic2(0): insertionPnt(1) = ic2(1): insertionPnt(2) = 0#
               'ThisDrawing.ModelSpace.AddPoint (insertionPnt)
               ThisDrawing.ModelSpace.AddLightWeightPolyline (ic2)
               ThisDrawing.Regen acAllViewports
         End If
       Next
   Next
End Sub

Private Function DaireYeNokta(x1 As Double, x2 As Double, y1 As Double, y2 As Double, BulgeDeger As Double) As Variant
   Dim item1 As AcadLWPolyline
   Dim katsayi As Integer
   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
   Dim x3 As Double, y3 As Double, xc As Double, yc As Double, xkts As Double, ykts As Double
   Dim xyzm(19) As Double, tetam As Double
   Dim pii As Double
   pii = Math.Atn(1) * 4
   'eps = 100000
   katsayi = 1
   If Math.Abs(BulgeDeger) > 1 Then
       katsayi = -1
   End If
   aci = Math.Atn(BulgeDeger) * 4
   acix = Math.Abs(aci) / aci
   x3 = (x1 + x2) / 2
   y3 = (y1 + y2) / 2
   c = Math.Sqr((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
   t = Math.Abs(c / (2 * Tan(aci / 2)))
   r = Math.Abs(c / (2 * Sin(aci / 2)))
   yn = y1 - y2
   xn = x1 - x2
   If yn <> 0 Then
       xne = yn / Abs(yn)
   Else
       xne = 1
   End If
   If xn = 0 Then
       xkts = xne
       ykts = 0
   Else
       yne = -xn / Math.Abs(xn)
       mr = Math.Abs((y2 - y1) / (x1 - x2))
       xkts = mr / Math.Sqr(mr * mr + 1) * xne
       ykts = 1 / Math.Sqr(mr * mr + 1) * yne
   End If
   xc = x3 + t * xkts * acix * katsayi
   yc = y3 + t * ykts * acix * katsayi
   tetam = Math.Atn((y1 - yc) / (x1 - xc))
   tetam = Math.Abs(tetam)
   If (x1 - xc) < 0 And (y1 - yc) < 0 Then
       tetam = pii + tetam
   ElseIf (x1 - xc) < 0 Then
       tetam = pii - tetam
   ElseIf (y1 - yc) < 0 Then
       tetam = 2 * pii - tetam
   End If
   For i = 0 To 9
       xyzm(i * 2) = xc + (r * 1.1) * Math.Cos(tetam)
       xyzm(i * 2 + 1) = yc + (r * 1.1) * Math.Sin(tetam)
       tetam = tetam + aci / 9
   Next
   DaireYeNokta = xyzm
End Function

SEANT 发表于 2022-7-6 23:31:25

酷节目。
我不确定结果到底是什么,但很酷。

mftbrothers 发表于 2022-7-6 23:59:54

谢谢我为此工作了2天哈哈
一些数学和一些编程呵呵
页: [1]
查看完整版本: 选择