CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

检查干涉方法 (ActiveX)

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

摘要: 检查两个实体之间的干涉,如果指定,则根据干涉创建实体。

检查两个实体之间的干涉,如果指定,则根据干涉创建实体。

支持的平台:仅窗口

签名

工 务 局:

RetVal = object.CheckInterference(Object, CreateInterferenceSolid, SolidsInterfere)
对象

类型:3DSolid

此方法适用的对象。

对象

访问:仅输入

类型:3DSolid

要检查的对象。

创建干扰固体

访问:仅输入

类型:布尔

  • True:创建干涉实体。
  • False:不创建干涉实体。
固体干扰

访问:仅输出

类型:布尔

  • True:固体会干扰。
  • False:固体不会干扰。

返回值(RetVal)

类型:3DSolid

生成的对象(如果设置为“创建干扰固体”)。True

言论

没有额外的评论。

例子

工 务 局:

Sub Example_CheckInterference()
    ' This example creates a box and a cylinder in model space.
    ' It then finds the interference between the two solids and
    ' creates a new solid from that interference.
    
    ' For ease of viewing, different colors are used for the box, the
    ' cylinder, and the interference solid.
    
    Dim color As AcadAcCmColor
    Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor." & Left(AcadApplication.Version, 2))

    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)
    Call color.SetRGB(80, 100, 244)
	   boxObj.TrueColor = color
    
    ' 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)
    Call color.SetRGB(244, 150, 50)
	   cylinderObj.TrueColor = color
    
    ' Find the interference between the two solids and create a new solid from it
    Dim solidObj As Acad3DSolid
    Dim bSolidsInterfere As Boolean
    Set solidObj = boxObj.CheckInterference(cylinderObj, True, bSolidsInterfere)
    Call color.SetRGB(200, 150, 244)
	   solidObj.TrueColor = color

    ' 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
    
    ' You can now delete the box and cylinder in AutoCAD to
    ' see the interference solid more clearly.
               
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_CheckInterference()
    ;; This example creates a box and a cylinder in model space.
    ;; It then finds the interference between the two solids and
    ;; creates a new solid from that interference.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))   
    
    ;; For ease of viewing, different colors are used for the box, the
    ;; cylinder, and the interference solid.
    (setq color (vlax-create-object (strcat "AutoCAD.AcCmColor." (substr (getvar "ACADVER") 1 2))))

    (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))

    (vla-SetRGB color 80 100 244)
    (vla-put-TrueColor boxObj color)
    
    ;; 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))
    (vla-SetRGB color 244 150 50)
    (vla-put-TrueColor cylinderObj color)
    
    ;; Find the interference between the two solids and create a new solid from it
    (setq solidObj (vla-CheckInterference boxObj cylinderObj :vlax-true :vlax-true))
    (vla-SetRGB color 200 150 244)
    (vla-put-TrueColor solidObj color)

    ;; 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)
    
    ;; You can now delete the box and cylinder in AutoCAD to
    ;; see the interference solid more clearly.
    (vlax-release-object color)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-11 23:37

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部