明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2785|回复: 10

关于创建面域的问题,进来看看吧,很简单的!!!

[复制链接]
发表于 2006-5-22 10:56:00 | 显示全部楼层 |阅读模式

各位大虾:

       我想把圆创建成一个面域,可是有问题代码如下,希望能帮我看看哪里出了问题

     Sub addRegion()

      Dim circle As AcadEntity
      Dim regionObj As Variant
      Dim point(0 To 2) As Double
      Dim radius As Double
      point(0) = 300
      point(1) = 300
      point(2) = 300
      radius = 80
      Set circle = ThisDrawing.ModelSpace.AddCircle(point, radius)
      regionObj = ThisDrawing.ModelSpace.AddRegion(circle)  

    End Sub

发表于 2006-5-22 11:22:00 | 显示全部楼层

  Sub addRegion()

      Dim eircle(0) As AutoCAD.AcadEntity
  
      Dim regionObj As Variant
      Dim point(0 To 2) As Double
      Dim radius As Double
      point(0) = 300
      point(1) = 300
      point(2) = 300
      radius = 80
      Set eircle(0) = ThisDrawing.ModelSpace.AddCircle(point, radius)
      regionObj = ModelSpace.addRegion(eircle)
      ZoomAll
    End Sub

circle为系统标识,你不能用;另外生成面域的曲线似乎要用数组

发表于 2006-5-22 11:22:00 | 显示全部楼层

注意,增加区域的时候,添加的对象必须是一个对象数组,应该将circle定义成一个数组就行了。。。下面是改完的程序

Dim circle1(0) As AcadEntity
Dim regionObj As Variant
Dim point(0 To 2) As Double
Dim radius As Double
point(0) = 300
point(1) = 300
point(2) = 300
radius = 80
Set circle1(0) = ThisDrawing.ModelSpace.AddCircle(point, radius)
regionObj = ThisDrawing.ModelSpace.AddRegion(circle1)

发表于 2006-5-22 11:25:00 | 显示全部楼层
呵呵!比楼上的晚了1秒啊。。。。。。^_^!真巧。。。。。
 楼主| 发表于 2006-5-22 13:10:00 | 显示全部楼层

呵呵,谢谢楼上两位的帮忙,还有一个问题,我想要生成圆环

步骤:1.先画两个同心圆,分别生成面域

        2.运用布尔差运算,外圆减去内圆,生成圆环.程序还是有问题

程序如下:

Dim circle1(0) As AcadEntity
   Dim circle2(0) As AcadEntity
   Dim regionObj1 As Variant
   Dim regionObj2 As Variant
   Dim point(0 To 2) As Double
   Dim radius1 As Double
   Dim radius2 As Double
   point(0) = 300
   point(1) = 300
   point(2) = 300
   radius1 = 80
   radius2 = 60
  
   '创建面域
   Set circle1(0) = ThisDrawing.ModelSpace.AddCircle(point, radius1)
   Set circle2(0) = ThisDrawing.ModelSpace.AddCircle(point, radius2)
   regionObj1 = ThisDrawing.ModelSpace.AddRegion(circle1)
   regionObj2 = ThisDrawing.ModelSpace.AddRegion(circle2)
  
   '布尔运算
   regionObj1.Boolean acSubtraction, regionObj2

应该是最后一句有问题,可不知道怎么改

发表于 2006-5-22 14:42:00 | 显示全部楼层

改成:

regionObj1(0).Boolean acSubtraction, regionObj2(0)

就行了!

发表于 2006-6-9 16:25:00 | 显示全部楼层
面域生成后拉申为实体,实体转动后,面域不动,delete 也删除不了,请问如何去掉面域?
发表于 2006-6-9 16:41:00 | 显示全部楼层
邪门,delete不了?
发表于 2013-5-19 12:14:45 | 显示全部楼层
autocad 真他妈邪门,我有两段代码,结构一模一样,一个布尔运算成功,另一个就是不成功,快他妈疯了,我查,这autodesk公司是越来越不行了!!!
发表于 2013-5-29 11:39:48 | 显示全部楼层
bihumanbu 发表于 2006-5-22 11:22
  Sub addRegion()
      Dim eircle(0) As AutoCAD.AcadEntity &nbsp ...

yes,I agree with you,必须得用数组才行
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 13:14 , Processed in 0.169633 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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