CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

布尔方法 (ActiveX)

2023-1-4 11:33| 发布者: admin| 查看: 641| 评论: 0|来自: AutoCAD

摘要: 在对象与另一个 3DSolid 或区域对象之间执行布尔运算(并集、相交或减去)。

在对象与另一个 3DSolid 或区域对象之间执行布尔运算(并集、相交或减去)。

支持的平台:仅窗口

签名

工 务 局:

object.Boolean(Operation, Object)
对象

类型:3DSolid地区

此方法适用的对象。

操作

访问:仅输入

类型:枚举AcBooleanType

  • acUnion:执行联合操作。
  • acIntersection:执行交集操作。
  • acSubtraction:执行减法运算。
对象

访问:仅输入

类型:3DSolid地区

对其执行操作的对象。

返回值(RetVal)

无返回值。

言论

第一个对象作为操作的结果被修改。



布尔交集前的实体



从布尔相交得到的实体

注意:如果操作没有结果,则不会更改第一个对象。例如,当查找两个非相交对象之间的交点时,第一个对象没有变化。

例子

工 务 局:

Sub Example_Boolean()
    ' This example creates a box and a cylinder in model space.
    ' It then performs a Boolean operation on the two solids.
    
    Dim boxObj As Acad3DSolid
    Dim boxLength As Double, boxWidth As Double, boxHeight As Double
    Dim boxCenter(0 To 2) As Double
    boxCenter(0) = 5#: boxCenter(1) = 5#: boxCenter(2) = 0
    boxLength = 10#: boxWidth = 7: boxHeight = 10#
    
    ' Create the box (3DSolid) object in model space
    Set boxObj = ThisDrawing.ModelSpace.AddBox(boxCenter, boxLength, boxWidth, boxHeight)
    
    ' Define the cylinder
    Dim cylinderObj As Acad3DSolid
    Dim cylinderCenter(0 To 2) As Double
    Dim cylinderRadius As Double
    Dim cylinderHeight As Double
    cylinderCenter(0) = 0#: cylinderCenter(1) = 0#: cylinderCenter(2) = 0#
    cylinderRadius = 5#
    cylinderHeight = 20#
    
    ' Create the Cylinder (3DSolid) object in model space
    Set cylinderObj = ThisDrawing.ModelSpace.AddCylinder(cylinderCenter, cylinderRadius, cylinderHeight)
    
    ' Change the viewing direction of the viewport
    Dim NewDirection(0 To 2) As Double
    NewDirection(0) = -1: NewDirection(1) = -1: NewDirection(2) = 1
    ThisDrawing.ActiveViewport.direction = NewDirection
    ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
    ZoomAll
    
    ' Perform an intersection on the two solids
    MsgBox "Perform an intersection on the two solids.", vbOKOnly, "Boolean Example"
    boxObj.Boolean acIntersection, cylinderObj
    ThisDrawing.Regen True
    
    MsgBox "Intersection complete.", , "Boolean Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Boolean()
    ;; This example creates a box and a cylinder in model space.
    ;; It then performs a Boolean operation on the two solids.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    (setq boxCenter (vlax-3d-point 5 5 0)
          boxLength 10
	         boxWidth 7
	         boxHeight 10)
    
    ;; Create the box (3DSolid) object in model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq boxObj (vla-AddBox modelSpace boxCenter boxLength boxWidth boxHeight))
    
    ;; Define the cylinder
    (setq cylinderCenter (vlax-3d-point 0 0 0)
          cylinderRadius 5
          cylinderHeight 20)
    
    ;; Create the Cylinder (3DSolid) object in model space
    (setq cylinderObj (vla-AddCylinder modelSpace cylinderCenter cylinderRadius cylinderHeight))
    
    ;; Change the viewing direction of the viewport
    (setq NewDirection (vlax-3d-point -1 -1 1))
    (setq activeViewport (vla-get-ActiveViewport doc))
    (vla-put-Direction activeViewport NewDirection)
    (vla-put-ActiveViewport doc activeViewport)
    (vla-ZoomAll acadObj)
    
    ;; Perform an intersection on the two solids
    (alert "Perform an intersection on the two solids.")
    (vla-Boolean boxObj acIntersection cylinderObj)
    (vla-Regen doc :vlax-true)
    
    (alert "Intersection complete.")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 14:28

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部