CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

关于编辑三维实体 (VBA/ActiveX)

2023-1-4 20:58| 发布者: admin| 查看: 1319| 评论: 0|来自: AutoCAD

摘要: 创建实体后,可以通过组合实体来创建更复杂的形状。

创建实体后,可以通过组合实体来创建更复杂的形状。

您可以连接实体、相互减去实体或查找实体的公共体积(重叠部分)。使用理论方法执行这些组合。BooleanCheckInterference



通过获得固体的 2D 横截面或将固体切成两块来进一步修改实体。使用该方法查找固体的横截面,并使用该方法将固体切成两块。SectionSolidSliceSolid

查找两个实体之间的干涉

本示例在模型空间中创建一个框和一个圆柱体。然后,它找到两个实体之间的干涉,并从该干涉创建一个新的固体。为了便于查看,盒子的颜色为白色,圆柱体为青色,干涉固体为红色。

Sub Ch8_FindInterferenceBetweenSolids()
    ' Define the box
    Dim boxObj 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

    ' Create the box object in model space
    ' and color it white
    Set boxObj = ThisDrawing.ModelSpace. _
 AddBox(center, length, width, height)
    boxObj.Color = acWhite

    ' Define the cylinder
    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

    ' Create the Cylinder and
    ' color it cyan
    Set cylinderObj = ThisDrawing.ModelSpace.AddCylinder _
 (center, cylinderRadius, cylinderHeight)
    cylinderObj.Color = acCyan

    ' Find the interference between the two solids
    ' and create a new solid from it. Color the
    ' new solid red.
    Dim solidObj As Acad3DSolid
    Dim bSolidsInterfere As Boolean
    Set solidObj = boxObj.CheckInterference(cylinderObj, True, bSolidsInterfere)
    solidObj.Color = acRed
    ZoomAll
End Sub

将一个固体切成两个固体

本示例在模型空间中创建一个框。然后,它根据由三个点定义的平面对盒子进行切片。切片以 a 形式返回。3DSolid

Sub Ch8_SliceABox()
    ' Create the box object
    Dim boxObj 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#

    ' Create the box (3DSolid) object in model space
    Set boxObj = ThisDrawing.ModelSpace. _
 AddBox(center, length, width, height)
    boxObj.Color = acWhite

    ' Define the section plane with three points
    Dim slicePt1(0 To 2) As Double
    Dim slicePt2(0 To 2) As Double
    Dim slicePt3(0 To 2) As Double

    slicePt1(0) = 1.5: slicePt1(1) = 7.5: slicePt1(2) = 0
    slicePt2(0) = 1.5: slicePt2(1) = 7.5: slicePt2(2) = 10
    slicePt3(0) = 8.5: slicePt3(1) = 2.5: slicePt3(2) = 10

    ' slice the box and color the new solid red
    Dim sliceObj As Acad3DSolid
    Set sliceObj = boxObj.SliceSolid _
 (slicePt1, slicePt2, slicePt3, True)
    sliceObj.Color = acRed
    ZoomAll
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-19 12:45

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部