明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1521|回复: 3

选择集中的点转成数组后出现的问题?

[复制链接]
发表于 2006-8-12 08:30:00 | 显示全部楼层 |阅读模式

选择集中的点转成数组后出现的问题?源程序如下:

Sub mm()
  On Error Resume Next
   Dim sset As AcadSelectionSet
    Dim objcir As AcadCircle
    Dim radius As Double
   
    Dim filtertype(0) As Integer
    Dim filterdata(0) As Variant
   
    If Not IsNull(ThisDrawing.SelectionSets.Item("Circles")) Then
       Set sset = ThisDrawing.SelectionSets.Item("Circles")
       sset.Delete
    End If
    Set sset = ThisDrawing.SelectionSets.Add("Circles")
   
    filtertype(0) = 0 '设置选择过滤器
    filterdata(0) = "circle"
 
    sset.SelectOnScreen filtertype, filterdata
     Dim ptarr()
    Dim count As Integer
    count = sset.count
    ReDim ptarr(count - 1)
     For Each objcir In sset
   
     Dim ptcen As Variant
     ptcen = objcir.Center
     Dim i As Integer
     For i = 0 To count - 1
     Dim cir1 As AcadCircle
     Set cir1 = sset.Item(i)
     cir1.Center = ptarr(i)
     Next i
     Next
    Dim pt1 As Variant
    pt1 = ptarr(0)
    MsgBox pt1(0)
    MsgBox pt1(1)
    
End Sub

运行后无任何反应!

发表于 2006-8-12 09:24:00 | 显示全部楼层

ReDim ptarr(count - 1,2)
dim ii,i as Integer    

ii=0

i=0 

For Each objcir In sset
   
     Dim ptcen As Variant
    ' ptcen = objcir.Center

  Set ptcen = objcir.Center
     For i = 0 To 2

ptarr(ii,i)=ptcen(i)
         Next i

ii=ii+1
     Next
改成这样试试

 楼主| 发表于 2006-8-12 17:37:00 | 显示全部楼层

先谢谢!

还是不行

Dim x As Double
 Dim y As Double
 x = ptarr(0, 0)
 y = ptarr(0, 1)
    MsgBox x
    MsgBox y

任何时候显示为0,0

 

发表于 2006-8-12 18:28:00 | 显示全部楼层
  1. ReDim ptarr(sset.count - 1)
  2. For i= 0 to sset.count-1   
  3.      ptarr(i)=sset(i).Center
  4. Next
  5. msgbox ptarr(0)(0) & "," & ptarr(0)(1) & "," & ptarr(0)(2)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-27 00:28 , Processed in 0.166731 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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