明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2805|回复: 3

用vba如何创建面域啊?

[复制链接]
发表于 2007-7-19 22:05:00 | 显示全部楼层 |阅读模式

我用addline方法画了几条封闭线段(线段定义的不是一个数组),用addregion想将这几条线段创建面域不知为何做不了

刚接触VBA,望高手赐教~

有没有一个方法象Autolisp那样指定两个点就可以将两点范围内的封闭曲线做成面域?

谢谢哦~~

发表于 2007-7-20 11:26:00 | 显示全部楼层

下面是我弄的一个构建面域的试验程序,你可以用选择集来构建。

Sub q()
Dim obj(0 To 1) As AcadPolyline

Dim x1(0 To 14) As Double
Dim x2(0 To 14) As Double
Dim y1(0 To 3) As Double
Dim y2(0 To 3) As Double
x1(0) = 915.532
x1(1) = 459.517
x1(2) = 0
x1(3) = 948.256
x1(4) = 461.206
x1(5) = 0
x1(6) = 948.256
x1(7) = 434.545
x1(8) = 0
x1(9) = 905.75
x1(10) = 435.993
x1(11) = 0
x1(12) = 915.532
x1(13) = 459.517
x1(14) = 0
x2(0) = 948.541
x2(1) = 458.139
x2(2) = 0
x2(3) = 956.261
x2(4) = 439.321
x2(5) = 0
x2(6) = 956.261
x2(7) = 404.46
x2(8) = 0
x2(9) = 915.497
x2(10) = 429.448
x2(11) = 0
x2(12) = 948.541
x2(13) = 458.139
x2(14) = 0
Set obj(0) = ThisDrawing.ModelSpace.AddPolyline(x1)
Set obj(1) = ThisDrawing.ModelSpace.AddPolyline(x2)
Dim regions As Variant
regions = ThisDrawing.ModelSpace.AddRegion(obj)
Dim r1 As AcadRegion
Dim r2 As AcadRegion
 Set r1 = regions(0)
 Set r2 = regions(1)
 
 r1.Boolean acIntersection, r2
 MsgBox "mj is :" & r1.Area
End Sub

 楼主| 发表于 2007-7-20 18:36:00 | 显示全部楼层

谢谢laoxie指教~

试试好不好用~

发表于 2007-7-23 10:38:00 | 显示全部楼层

不错,不过面域相交用的一般比较少吧!想差用的可能比较多

.....................

.................

if regions(0)>region(1) then

r1=regions(0)

r2=regions(1)

else

 r1=regions(1)

r2=regions(0)

end if

r1.boolean acsubtraction r2

.....................

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-26 14:24 , Processed in 0.167780 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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