cadvba吧 关注:17贴子:30
  • 7回复贴,共1

小白请教差集问题

只看楼主收藏回复

Sub 差集()
' 定义长方体
Dim boxObj As Acad3DSolid
Dim cylinderObj As Acad3DSolid
Dim solidObj As Acad3DSolid
Dim length As Double
Dim width As Double
Dim height As Double
Dim center(0 To 2) As Double
center(0) = 5: center(1) = 5: center(2) = 0
length = 5
width = 7
height = 10
' 在模型空间中创建长方体对象
' 并着色为白色
Set boxObj = ThisDrawing.ModelSpace. _
AddBox(center, length, width, height)
boxObj.color = acWhite
' 定义圆柱体
'Dim cylinderObj As Acad3DSolid
Dim cylinderRadius As Double
Dim cylinderHeight As Double
center(0) = 0: center(1) = 0: center(2) = 0
cylinderRadius = 5
cylinderHeight = 20
' 创建圆柱体并
' 着色为青色
Set cylinderObj = ThisDrawing.ModelSpace.AddCylinder _
(center, cylinderRadius, cylinderHeight)
cylinderObj.color = acCyan
' 找出两个实体之间的干涉
' 并由干涉创建新的实体。新实体
' 着色为红色。
'Dim solidObj As Acad3DSolid
Set solidObj = boxObj.Boolean(acIntersection, cylinderObj)
solidObj.color = acRed
ZoomAll
End Sub


IP属地:广东1楼2022-04-27 00:11回复

    ’划线部分代码改为以下语句就可以了。
    boxObj.Boolean acIntersection, cylinderObj
    boxObj.color = acRed
    运行后的结果。


    IP属地:广东2楼2022-04-28 14:42
    收起回复
      谢谢大神,做出来了,


      IP属地:广东3楼2022-05-09 22:40
      收起回复