明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1899|回复: 2

创建区域的问题,大虾,请教一下,在此谢谢了!!!

[复制链接]
发表于 2003-8-18 17:04:00 | 显示全部楼层 |阅读模式
Private Sub CommandButton1_Click()
Dim curves(0 To 1) As AcadEntity

Dim centerpoint(0 To 2) As Double

Dim radius As Double

Dim startangle As Double

Dim endangle As Double

centerpoint(0) = 125#: centerpoint(1) = 75#: centerpoint(2) = 0#
radius = 50#
startangle = 0
endangle = 3.141592
Set curves(0) = ThisDrawing.ModelSpace.AddArc(centerpoint, radius, startangle, endangle)

Set curves(1) = ThisDrawing.ModelSpace.AddLine(curves(0).StartPoint, curves(0).EndPoint)

Dim regionobj As Variant

regionobj = ThisDrawing.ModelSpace.AddRegion(curves)

regionobj(0).Color = acRed
ZoomAll

Dim i As Integer
For i = LBound(regionobj) To UBound(regionobj)

MsgBox "区域的名称为:" & regionobj(i).ObjectName

Next


End Sub

这是书上的例子,创建了一个由圆弧和直线组成的区域。我的问题是,我的直线和圆弧已知,在图上已生成了。于是我想用选择集的办法,从屏幕上直接选取要组成区域的这俩图元。然后生成面域。可是生成域的命令却执行不了。说是方法addregion作用于iacadmodelspace时失败。
我的程序是

Private Sub CommandButton1_Click()
Dim ssetobj As AcadSelectionSet
Dim i As Integer
Dim regions As Variant
Dim entobj(2) As Variant
Dim ssetcount As Integer

If ThisDrawing.SelectionSets.Count <> 0 Then
For i = 0 To ThisDrawing.SelectionSets.Count - 1
Set ssetobj = ThisDrawing.SelectionSets.Item(i)
   ssetobj.Delete
    Next
   End If
Set ssetobj = ThisDrawing.SelectionSets.Add("test")
ssetobj.SelectOnScreen
ssetcount = ssetobj.Count

For i = 0 To ssetcount - 1
   Set entobj(i) = ssetobj.Item(i)
   MsgBox "选择集的图元名称为:" & entobj(i).ObjectName

   Next

regions = ThisDrawing.ModelSpace.AddRegion(entobj)           ‘就是这句话执行不了方法addregion作用于iacadmodelspace时失败
End Sub
发表于 2003-8-19 00:52:00 | 显示全部楼层
注意Dim entobj(2) As Variant这里有误。
程序可以这样写:
  1. Private Sub lick()
  2. Dim ssetobj As AcadSelectionSet
  3. Dim i As Integer
  4. Dim regions As Variant
  5. Dim entobj() As AcadEntity
  6. Dim ssetcount As Integer

  7. If ThisDrawing.SelectionSets.Count <> 0 Then
  8. For i = 0 To ThisDrawing.SelectionSets.Count - 1
  9. Set ssetobj = ThisDrawing.SelectionSets.Item(i)
  10.    ssetobj.Delete
  11.     Next
  12.    End If
  13. Set ssetobj = ThisDrawing.SelectionSets.Add("test")
  14. ssetobj.SelectOnScreen
  15. ssetcount = ssetobj.Count
  16. ReDim entobj(ssetcount - 1) As AcadEntity
  17. For i = 0 To ssetcount - 1
  18.    Set entobj(i) = ssetobj.Item(i)
  19.    'MsgBox "选择集的图元名称为:" & entobj(i).ObjectName

  20.    Next

  21. regions = ThisDrawing.ModelSpace.AddRegion(entobj)
  22. End Sub

 楼主| 发表于 2003-8-19 11:19:00 | 显示全部楼层
的确是啊,高人呢!谢谢了!谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-28 14:29 , Processed in 0.150817 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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