找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1431|回复: 2

[求助] 输出在文本中 请各位专家帮我看看 我是才学 谢谢了

[复制链接]
发表于 2015-11-5 22:06:04 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
'曲线求交,把交点输出在文本中
Sub curveintersectionandoutput()
Dim v2 As AcadEntity
Dim ss1 As AcadSelectionSet

On Error GoTo ss

  ThisDrawing.Utility.GetEntity v2, ppp, "select an ent"
  Set ss1 = ThisDrawing.SelectionSets.Add("ssss")
  ss1.SelectOnScreen
  
  np = 0
  
  Open "C:\Users\Antony\Desktop\test.txt" For Output As #1    ' 打开输出文件。
  
  For Each ent In ss1
   Ipa = ent.IntersectWith(v2, acExtendNone) '求交点
   
   cc = (UBound(Ipa) + 1) / 3
   If cc >= 1 Then
    Dim pt(0 To 2) As Double
    pt(0) = Ipa(0)
    pt(1) = Ipa(1)
    pt(2) = ent.LinetypeScale
Print #1, pt(1); " " ' 将文本数据写入文件。
    np = np + 1
    Set point = ThisDrawing.ModelSpace.AddPoint(pt)

   End If
  Next
  
  Close #1
  
ss:
ss1.Delete
If Err.Number Then MsgBox Err.Description
End Sub

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
 楼主| 发表于 2015-11-5 22:07:19 | 显示全部楼层
请问函数intersectwith函数的返回值是什么 谢谢前辈
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 264个

财富等级: 日进斗金

发表于 2015-11-6 14:49:50 | 显示全部楼层
看看手册中的 Sample
Sub Example_IntersectWith()
    ' This example creates a line and circle and finds the points at
    ' which they intersect.
   
    ' Create the line
    Dim lineObj As AcadLine
    Dim startPt(0 To 2) As Double
    Dim endPt(0 To 2) As Double
    startPt(0) = 1: startPt(1) = 1: startPt(2) = 0
    endPt(0) = 5: endPt(1) = 5: endPt(2) = 0
    Set lineObj = ThisDrawing.ModelSpace.AddLine(startPt, endPt)
        
    ' Create the circle
    Dim circleObj As AcadCircle
    Dim centerPt(0 To 2) As Double
    Dim radius As Double
    centerPt(0) = 3: centerPt(1) = 3: centerPt(2) = 0
    radius = 1
    Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPt, radius)
    ZoomAll
      
    ' Find the intersection points between the line and the circle
    Dim intPoints As Variant
    intPoints = lineObj.IntersectWith(circleObj, acExtendNone)
   
    ' Print all the intersection points
    Dim I As Integer, j As Integer, k As Integer
    Dim str As String
    If VarType(intPoints) <> vbEmpty Then
        For I = LBound(intPoints) To UBound(intPoints)
            str = "Intersection Point[" & k & "] is: " & intPoints(j) & "," & intPoints(j + 1) & "," & intPoints(j + 2)
            MsgBox str, , "IntersectWith Example"
            str = ""
            I = I + 2
            j = j + 3
            k = k + 1
        Next
    End If
End Sub
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-4-28 13:21 , Processed in 0.233438 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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