zoukankan      html  css  js  c++  java
  • AutoCAD VBA:过三点创建一个圆

    基本思路,两点连线,两个线段中垂线交点就是圆心,圆心到任一点距离为半径,做圆。

    代码如下:

    Function BisectorPLine(Point1 As Variant, point2 As Variant) As AcadPolyline
    Dim Dist As Double
    Dim Circle1 As AcadCircle
    Dim Circle2 As AcadCircle
    Dim Pnts As Variant
    Dist = Distance(Point1, point2)
    Set Circle1 = ThisDrawing.ModelSpace.AddCircle(Point1, Dist)
    Set Circle2 = ThisDrawing.ModelSpace.AddCircle(point2, Dist)
    Pnts = Circle1.IntersectWith(Circle2, acExtendNone)
    Set BisectorPLine = ThisDrawing.ModelSpace.AddPolyline(Pnts)
    End Function


    Function Distance(Points1 As Variant, point2 As Variant) As Double
    Dim Line As AcadLine
    Set Line = ThisDrawing.ModelSpace.AddLine(Point1, point2)
    Distance = Line.Length
    Line.Delete
    End Function


    Function ThreePointCircle(pnt1 As Variant, pnt2 As Variant, pnt3 As Variant) As AcadCircle
    Dim Dist As Double
    Dim Pnts As Variant
    Dim Line1 As AcadPolyline
    Dim Line2 As AcadPolyline
    Set Line1 = BisectorPLine(pnt1, pnt2)
    Set Line2 = BisectorPLine(pnt1, pnt3)
    Pnts = Line1.lntersectwith(Line2, acExtendBoth)
    Line1.Delete
    Line2.Delete
    Dist = Distance(Pnts, pnt1)
    Set ThreePointCircle = ThisDrawing.ModelSpace.AddCircle(Pnts, Dist)
    End Function

    Public Sub DrawCircle()
    Dim P1 As Variant
    Dim P2 As Variant
    Dim P3 As Variant
    P1 = ThisDrawing.Utility.GetPoint(, vbCr & "第一点:")
    P2 = ThisDrawing.Utility.GetPoint(, vbCr & "第二点:")
    P3 = ThisDrawing.Utility.GetPoint(, vbCr & "第三点:")
    Dim C As AcadCircle
    Set C = ThreePointCricle(P1, P2, P3)
    End Sub

    不知道这些代码放在哪,悲剧。

    作者:codee
    文章千古事,得失寸心知。


  • 相关阅读:
    iframe脸面的页面和父页面之间的交互方法
    iframe高度自适应
    获取html元素所在页面的坐标
    自制的几个jquery插件
    将DataTable转换成Json格式
    QL 获取当前日期,年、月、日、周、时、分、秒
    DropdownList异步刷新GridView数据
    图片热区——map的用法
    Chart控件文档
    母版页改变被嵌套的页面中的控件ID的解决方法
  • 原文地址:https://www.cnblogs.com/bimgoo/p/2502890.html
Copyright © 2011-2022 走看看