明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1416|回复: 2

(求助)请帮我看一下这段代码为什么不行?

[复制链接]
发表于 2006-3-20 13:14:00 | 显示全部楼层 |阅读模式

本人初学VBA,请各位多多指教,这段代码为什么不行

找到实体层中各直线的交点,并把它们打印出来.

 Sub findpoint()
Dim newlayer As AcadLayer
Dim intpoints As Variant
Set newlayer = ThisDrawing.Layers("实体层")
ThisDrawing.ActiveLayer = newlayer
For Each lineobj1 In ThisDrawing.ModelSpace
  For Each lineobj2 In ThisDrawing.ModelSpace
    If lineobj1.ObjectID <> lineobj2.ObjectID Then
      intpoints = lineobj1.IntersectWith(lineobj2.acExtendNone)
    End If
  Next
Next
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
      谢谢大家了

发表于 2006-3-20 14:21:00 | 显示全部楼层

问题出在这里:

If lineobj1.ObjectID <> lineobj2.ObjectID Then
      intpoints = lineobj1.IntersectWith(lineobj2.acExtendNone)
    End If
lineobj2.acExtendNone,该是“lineobj2,acExtendNone”而不是一个“.”

 楼主| 发表于 2006-3-20 14:36:00 | 显示全部楼层

太感谢你了,都是我马虎造成的,给大家添麻烦了

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

本版积分规则

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

GMT+8, 2024-11-27 06:29 , Processed in 0.186644 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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