明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1881|回复: 2

斑竹,帮我看看

[复制链接]
发表于 2003-5-29 09:36:00 | 显示全部楼层 |阅读模式
下面代码中,没有错误,只是为什么再执行到for循环语句时没有msgbox显示呀!!谢谢!!
public sstext1 as acadselectionset
public acadobj as acadobjec
public entobj as acadentity
public line as acadline
public aa as acadarc
public ellispe as acadellispe
publid sub aa()
'选择集选择对象
     Dim mode As Integer
     'Dim sstext1 As AcadSelectionSet
     Set sstext1 = thisdrawing.ActiveDocument.SelectionSets.Add("ss1")
     Dim corner1(0 To 2) As Double
     Dim corner2(0 To 2) As Double
     '选择集参数设置
     mode = acSelectionSetCrossing
     corner1(0) = -800
     corner1(1) = 700
     corner1(2) = 0
     corner2(0) = 1830
     corner2(1) = -196
     corner2(2) = 0
    '选择过滤条件
    Dim gpcode(0) As Integer
    Dim datavalue(0) As Variant
    gpcode(0) = 8
    datavalue(0) = "layer1"
    Dim filtertype As Variant
    Dim filterdata As Variant
    filtertype = gpcode
    filterdata = datavalue
    sstext1.Select mode, corner1, corner2, filtertype, filterdata
    Dim entcount As Integer
    entcount = sstext1.Count
    MsgBox "  选择集中的图元数量:" & entcount
    'Dim entobj As AcadEntity
     Dim j As Integer
' 提取选择集中对象的属性
For j = 0 To entcount - 1
    Set acadobj = sstext1.Item(j)
    Select Case acadobj.ObjectName
      Case "AcDbline"
        Set line = thisdrawing.ActiveDocument.SelectionSets.Item(j)
        MsgBox "选择集中图元名称:" & acadobj.ObjectName
        'startpt1 = line.StartPoint(0)
        'startpt2 = line.StartPoint(1)
        'endpt1 = line.EndPoint(0)
        'endpt2 = line.EndPoint(1)
        'leng = line.length
        MsgBox " 直线的起始横坐标" & line.StartPoint(0)
        MsgBox "直线的起始纵坐标" & line.startpoint(1)
        MsgBox "直线的终点横坐标" & line.endpoint(0)
        MsgBox "直线的终点纵坐标" & line.endpoint(1)
        MsgBox "直线的长度" & line.length
      Case "AcDbarc"
         Set aa = thisdrawing.ActiveDocument.SelectionSets.Item(j)
         MsgBox "选择集中图元名称:" & entobj.ObjectName
         'startpt1 = aa.Center(0)
         'startpt2 = aa.Center(1)
         'cenrad = aa.Radius
         'cenare = aa.Area
         MsgBox " 圆的中心横坐标" & aa.Center(0)
         MsgBox "圆的中心纵坐标" & aa.center(1)
         MsgBox "圆的半径" & aa.radius
         MsgBox "圆的面积" & aa.are
         'Call save
       Case "AcDbellispe"
         Set ellispe = thisdrawing.ActiveDocument.SelectionSets.Item(j)
         MsgBox "选择集中图元名称:" & entobj.ObjectName
         startpt1 = ellispe.Center(0)
         startpt2 = ellispe.Center(1)
         cenare = ellispe.Area
       End Select
      
    Next
end sub
发表于 2003-5-29 19:58:00 | 显示全部楼层

AcDbline应为AcDbLine ,而AcDbarc应为AcDbArc,注意大小写

发表于 2003-5-31 08:35:00 | 显示全部楼层

正是如此

实体的图元名都有一定规律的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-28 16:53 , Processed in 0.167853 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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