明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 979|回复: 1

VB6使用GetLoopAt时报错 “缺少函数或变量”

[复制链接]
发表于 2019-4-1 14:15:20 | 显示全部楼层 |阅读模式
完整代码:
Option Explicit
Private Sub Command1_Click()
    Dim acadApp As AcadApplication
    Set acadApp = GetObject(, "AutoCAD.Application")
    Dim hatchObj As AcadHatch
    Dim patternName As String
    Dim PatternType As Long
    Dim bAssociativity As Boolean
    '定义填充
    PatternType = 0
    patternName = "SOLID"
    bAssociativity = True '填充图案与边界相关联
    '创建填充对象
    Set hatchObj = acadApp.ActiveDocument.ModelSpace.AddHatch(PatternType, patternName, bAssociativity)
    '创建两个同心圆作为填充边界
    Dim OuterLoop(0 To 0) As AcadEntity
    Dim InnerLoop(0 To 0) As AcadEntity
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 1: center(1) = 2: center(2) = 0
    radius = 20
    Set OuterLoop(0) = acadApp.ActiveDocument.ModelSpace.AddCircle(center, radius)
    Set InnerLoop(0) = acadApp.ActiveDocument.ModelSpace.AddCircle(center, radius / 2)
    '向填充对象添加填充边界
    hatchObj.AppendOuterLoop (OuterLoop)
    hatchObj.AppendInnerLoop (InnerLoop)
    '用Evaluate方法进行求值并显示填充
    hatchObj.Evaluate
    acadApp.ActiveDocument.Regen True
    '输出填充的边界数
    Print (hatchObj.NumberOfLoops)
    '判断边界的类型
    Dim loopNum As Integer
    loopNum = hatchObj.NumberOfLoops
    Print (loopNum)

    Dim num As Integer
    num = 0
    Dim loopObjs As Variant
    Dim hatLoop As Object
   'hatLoop = Nothing
    Do While num < loopNum
        Set hatLoop = hatchObj.GetLoopAt(num, loopObjs)
        num = num + 1
        If hatLoop.IsPolyline Then
           Print (111)
        Else
           Print (222)
        End If
    Loop
    ZoomExtents

End Sub
其中Set hatLoop = hatchObj.GetLoopAt(num, loopObjs)这句一直报缺少函数或变量的错  不知道为什么

发表于 2019-4-8 16:36:28 | 显示全部楼层
GetLoopAt 没有返回值,你怎么让他返回呀
call hatchObj.GetLoopAt(num, loopObjs)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 07:20 , Processed in 0.138379 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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