明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1315|回复: 3

求高手指点,若有交点,交点坐标写入数组,若无则不写入

[复制链接]
发表于 2008-10-21 11:57:00 | 显示全部楼层 |阅读模式

For Each ent In ThisDrawing.ModelSpace

      intPoints = vbEmpty

  intPoints = lineObj.IntersectWith(ent, acExtendNone)

      If VarType(intPoints) <> vbEmpty Then

      ReDim Preserve px(I) As Variant

      ReDim Preserve py(I) As Variant

      ReDim Preserve pz(I) As Variant

     

px(I) = intPoints(0)

      py(I) = intPoints(1)

      pz(I) = intPoints(2)

   

      MsgBox px(I) & py(I) & pz(I)

   End If

Next ent

发表于 2008-10-21 12:54:00 | 显示全部楼层
看不懂你的,我写了一个
  1. Sub test()
  2. On Error Resume Next
  3. Dim obj1 As AcadEntity
  4. Dim pt As Variant
  5. ThisDrawing.Utility.GetEntity obj1, pt
  6. Dim bpts(0 To 11) As Double
  7. Dim minpt As Variant
  8. Dim maxpt As Variant
  9. obj1.GetBoundingBox minpt, maxpt
  10. bpts(0) = minpt(0)
  11. bpts(1) = minpt(1)
  12. bpts(2) = minpt(2)
  13. bpts(3) = minpt(0)
  14. bpts(4) = maxpt(1)
  15. bpts(5) = minpt(2)
  16. bpts(6) = maxpt(0)
  17. bpts(7) = maxpt(1)
  18. bpts(8) = maxpt(2)
  19. bpts(9) = maxpt(0)
  20. bpts(10) = minpt(1)
  21. bpts(11) = maxpt(2)
  22. Dim ss As AcadSelectionSet
  23. ThisDrawing.SelectionSets.Add ("test")
  24. Set ss = ThisDrawing.SelectionSets.Item("test")
  25. ss.SelectByPolygon acSelectionSetCrossingPolygon, bpts
  26. For Each obj In ss
  27. If Not (obj Is obj1) Then
  28. 'MsgBox "OK"
  29. 'Else
  30. Dim ipts As Variant
  31. ipts = obj1.IntersectWith(obj, acExtendNone)
  32. MsgBox "有" & (UBound(ipts) + 1) / 3 & "个交点"
  33. End If
  34. Next
  35. End Sub
 楼主| 发表于 2008-10-21 14:06:00 | 显示全部楼层
我想获取模型空间中指定直线的交点,但是判断语句不对,执行时不管与指定直线有没有交点,i值总是加1
如何判断有交点时i加1,没有时i值不变?
 楼主| 发表于 2008-10-21 14:26:00 | 显示全部楼层
刚才运行了sailorcwx的代码,感觉判断语句有问题,结果上传如图。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-26 06:35 , Processed in 0.156751 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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