土木在线论坛 \ 建筑设计 \ CAD下载及教程 \ 请教从一点引圆的切线vba

请教从一点引圆的切线vba

发布于:2006-10-19 17:26:19 来自:建筑设计/CAD下载及教程 [复制转发]
请教个问题,
已知一点和一圆,
如何求该点到该圆的切线,
并手动选择留哪一条。
怎么做?
我是求出切线长,画圆,两圆交两点,
如何把两点分出来,选择其中一个

初学vba 望指点

全部回复(3 )

只看楼主 我来说两句
  • kays
    kays 沙发
    Sub Test()
    Dim Pnt As Variant
    Dim CirCenter As Variant
    Dim Radius1 As Double, Radius2 As Double
    Dim Circle1 As AcadCircle, Circle2 As AcadCircle
    Dim TempLine As AcadLine
    Dim DistPtCen As Double
    Dim PolylinePt As Variant
    Dim Polyline As AcadPolyline
    Dim Line1 As AcadLine, Line2 As AcadLine


    ’Enter the center and radius of the circle
    CirCenter = ThisDrawing.Utility.GetPoint(, "圆心位置:")
    Radius1 = ThisDrawing.Utility.GetDistance(CirCenter, "圆的半径:")
    ’Draw the circle
    Set Circle1 = ThisDrawing.ModelSpace.AddCircle(CirCenter, Radius1)
    ’Specify the point from where the tangent line start
    Pnt = ThisDrawing.Utility.GetPoint(, "切线起点:")
    ’Draw the point
    ThisDrawing.ModelSpace.AddPoint (Pnt)
    ’Calculate the length of the tangent line
    Set TempLine = ThisDrawing.ModelSpace.AddLine(CirCenter, Pnt)
    DistPtCen = TempLine.Length
    TempLine.Delete
    Radius2 = Sqr(DistPtCen ^ 2 - Radius1 ^ 2)
    ’Draw a auxiliary circle with radius equals the length of tangent line
    Set Circle2 = ThisDrawing.ModelSpace.AddCircle(Pnt, Radius2)
    PolylinePt = Circle1.IntersectWith(Circle2, acExtendNone)
    Set Polyline = ThisDrawing.ModelSpace.AddPolyline(PolylinePt)

    ’Add tangent lines
    Set Line1 = ThisDrawing.ModelSpace.AddLine(Pnt, Polyline.Coordinate(0))
    Set Line2 = ThisDrawing.ModelSpace.AddLine(Pnt, Polyline.Coordinate(1))

    ’Delete the auxiliary circle and polyline
    Circle2.Delete
    Polyline.Delete


    End Sub
    2006-10-23 17:16:23

    回复 举报
    赞同0
  • kays
    kays 板凳
    Sub Test()
    Dim Pnt As Variant
    Dim CirCenter As Variant
    Dim Radius1 As Double, Radius2 As Double
    Dim Circle1 As AcadCircle, Circle2 As AcadCircle
    Dim TempLine As AcadLine
    Dim DistPtCen As Double
    Dim PolylinePt As Variant
    Dim Polyline As AcadPolyline
    Dim Line1 As AcadLine, Line2 As AcadLine


    ’Enter the center and radius of the circle
    CirCenter = ThisDrawing.Utility.GetPoint(, "圆心位置:")
    Radius1 = ThisDrawing.Utility.GetDistance(CirCenter, "圆的半径:")
    ’Draw the circle
    Set Circle1 = ThisDrawing.ModelSpace.AddCircle(CirCenter, Radius1)
    ’Specify the point from where the tangent line start
    Pnt = ThisDrawing.Utility.GetPoint(, "切线起点:")
    ’Draw the point
    ThisDrawing.ModelSpace.AddPoint (Pnt)
    ’Calculate the length of the tangent line
    Set TempLine = ThisDrawing.ModelSpace.AddLine(CirCenter, Pnt)
    DistPtCen = TempLine.Length
    TempLine.Delete
    Radius2 = Sqr(DistPtCen ^ 2 - Radius1 ^ 2)
    ’Draw a auxiliary circle with radius equals the length of tangent line
    Set Circle2 = ThisDrawing.ModelSpace.AddCircle(Pnt, Radius2)
    PolylinePt = Circle1.IntersectWith(Circle2, acExtendNone)
    Set Polyline = ThisDrawing.ModelSpace.AddPolyline(PolylinePt)

    ’Add tangent lines
    Set Line1 = ThisDrawing.ModelSpace.AddLine(Pnt, Polyline.Coordinate(0))
    Set Line2 = ThisDrawing.ModelSpace.AddLine(Pnt, Polyline.Coordinate(1))

    ’Delete the auxiliary circle and polyline
    Circle2.Delete
    Polyline.Delete


    End Sub

    虽然写得不好,不过也可以做切线了,
    才学vba不到一个月,还请大家指教。
    2006-10-23 17:15:23

    回复 举报
    赞同0
加载更多
这个家伙什么也没有留下。。。

CAD下载及教程

返回版块

52.08 万条内容 · 666 人订阅

猜你喜欢

阅读下一篇

求助天正结构事例(最好从头开始的那种)

谢谢

回帖成功

经验值 +10