Vla-boolean
- 構文
- (vla-boolean vla-object1 Operation vla-object2)
- 機能
- オブジェクトと他の 3D ソリッドまたはリージョン オブジェクトとの間で、ブール演算(和、交差、または差)を実行する。
- 引数
-
- vla-object1 … メソッドが適用される元の VLA オブジェクト (3DSolid、Region)
- Operation … AcBooleanType 列挙型
- acUnion: 和
- acIntersection: 交差
- acSubtraction: 差
- vla-object2 … 演算を実行する対象の VLA オブジェクト (3DSolid、Region)
- memo : 最初のオブジェクトは演算の結果に応じて修正される。
- 戻り値
- nil
- サンプル
(vl-load-com)
(defun c:exp_boolean1 (/)
;; モデル空間に box と cylinder を作成して
;; Boolean を実行するサンプル
(setq *doc* (vla-get-ActiveDocument (vlax-get-acad-object)))
;; box の設定値
(setq boxCenter (vlax-3d-point 5 5 0)
boxLength 10
boxWidth 7
boxHeight 10)
;; box の 3DSolid を作成
(setq mSpace (vla-get-ModelSpace *doc*))
(setq boxObj (vla-AddBox modelSpace boxCenter boxLength boxWidth boxHeight))
;; cylinder の設定値
(setq cylinderCenter (vlax-3d-point 0 0 0)
cylinderRadius 5
cylinderHeight 20)
;; Cylinder の(3DSolid を作成
(setq cylinderObj (vla-AddCylinder mSpace cylinderCenter cylinderRadius cylinderHeight))
;;ビューの設定
(setq NewDirection (vlax-3d-point -1 -1 1))
(setq actView (vla-get-ActiveViewport *doc*))
(vla-put-Direction actView NewDirection)
(vla-put-ActiveViewport *doc* actView)
(vla-ZoomAll (vlax-get-acad-object))
;; ブールを交差で実行
(alert "ソリッドを交差するよー.")
(vla-Boolean boxObj acIntersection cylinderObj)
(vla-Regen *doc* :vlax-true)
(alert "交差をコンプリート.")
)
(defun c:exp_boolean2 ( / space e1 e2 )
;; 閉じた図形からリージョンを作成して
;; ブールするサンプル
(vl-load-com)
(setq space
(vlax-get-property (vla-get-ActiveDocument (vlax-get-acad-object))
(if (= 1 (getvar 'CVPORT))
'Paperspace
'Modelspace
)))
(if
(and
(setq e1 (car (entsel "\n外周図形を選択 : ")))
(vlax-curve-isClosed e1)
(setq e2 (car (entsel "\n内周図形を選択 : ")))
(vlax-curve-isClosed e2)
)
(vla-Boolean
(car (vlax-invoke space 'AddRegion (list (vlax-ename->vla-object e1)))) acSubtraction
(car (vlax-invoke space 'AddRegion (list (vlax-ename->vla-object e2))))
)
)
(princ)
)
関連事項