明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 559|回复: 1

求大神帮忙看下为什么求不出P4点

[复制链接]
发表于 2016-10-6 17:54:44 | 显示全部楼层 |阅读模式
本帖最后由 opqtanxunch 于 2016-10-6 18:10 编辑

Sub ch2()
    Dim p1 As Variant
    Dim p2 As Variant
    Dim p4 As Variant
    Dim p3 As Variant
    ' 获取用户输入的点
    p1 = ThisDrawing.Utility.GetPoint
    p2 = ThisDrawing.Utility.GetPoint
    p3 = ThisDrawing.Utility.GetPoint
    ' 根据这些点创建二维多段线
    Dim polyObj As AcadLWPolyline
    Dim vertices(0 To 3) As Double
    vertices(0) = p1(0): vertices(1) = p1(1)
    vertices(2) = p2(0): vertices(3) = p2(1)
    Set polyObj = ThisDrawing.ModelSpace.AddLightWeightPolyline _
                  (vertices)

    p3 = ThisDrawing.Utility.GetPoint
    Dim d As Double
    d = (p2(1) - p1(1)) / (p2(0) - p1(0))
    p4(0) = (p3(1) - p1(1) + d * p1(0) + (1 / d) * p3(0)) / ((1 / d) + d)
    p4(1) = d * p4(0) - p1(0) * d + p1(1)
    Dim pointObj As AcadPoint
    Set pointObj = ThisDrawing.ModelSpace.AddPoint(p4)
    ThisDrawing.SetVariable "PDMODE", 34
    ThisDrawing.SetVariable "PDSIZE", 1
    ZoomAll

End Sub
怎么加悬赏明经币啊


 楼主| 发表于 2016-10-13 20:04:19 | 显示全部楼层
已自己解决
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 09:53 , Processed in 0.219110 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表