CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2018 开发者帮助

ClipBoundary 方法 (ActiveX)

2024-5-18 16:53| 发布者: admin| 查看: 70| 评论: 0|原作者: admin|来自: AutoCAD

ClipBoundary 方法 (ActiveX)

指定光栅图像或参考底图的剪切边界。

支持的平台:仅限 Windows

签名

VBA:

object.ClipBoundary PointsArray
对象

类型:DgnUnderlayDwfUnderlayPdfUnderlayRasterImageWipeout

此方法应用到的对象。

点数组

访问:仅输入

类型:变体(双精度的二元数组数组)

指定光栅图像或参考底图的剪切边界的 2D WCS 坐标数组。

返回值 (RetVal)

无返回值。

言论

您可以通过裁剪对象来定义图像或参考底图对象的区域,以便进行显示和打印。同一对象的多个实例可以具有不同的边界。

剪裁边界必须是闭合的 2D 多边形或矩形,其顶点被约束为位于图像或参考底图的边界内。

要裁剪图像或参考底图,对象的边界必须可见。使用该属性打开或关闭剪裁边界。ClippingEnabled

例子

VBA:

Sub Example_ClipBoundary()
    ' This example adds a raster image in model space.
    ' It then clips the image based on a clip boundary.
    
    ' This example uses the "2d Projected Polylines.jpg" found in the Sample
    ' directory. If you do not have the image, or if it is located
    ' in a different directory, insert a valid path and name for the
    ' imageName variable below.
    
    Dim insertionPoint(0 To 2) As Double
    Dim scalefactor As Double
    Dim rotationAngle As Double
    Dim imageName As String
    Dim rasterObj As AcadRasterImage
    
    imageName = "C:\AutoCAD\sample\2d Projected Polylines.jpg"
    insertionPoint(0) = 5#: insertionPoint(1) = 5#: insertionPoint(2) = 0#
    scalefactor = 2#
    rotationAngle = 0
    
    On Error Resume Next
    ' Creates a raster image in model space
    Set rasterObj = ThisDrawing.ModelSpace.AddRaster(imageName, insertionPoint, scalefactor, rotationAngle)
    
    If Err.Description = "Filer error" Then
        MsgBox imageName & " could not be found."
        Exit Sub
    End If
    
    ZoomAll
    MsgBox "Clip the image?", , "ClipBoundary Example"
    
    ' Establish the clip boundary with an array of points
    Dim clipPoints(0 To 9) As Double
    clipPoints(0) = 6: clipPoints(1) = 6.75
    clipPoints(2) = 7: clipPoints(3) = 6
    clipPoints(4) = 6: clipPoints(5) = 5
    clipPoints(6) = 5: clipPoints(7) = 6
    clipPoints(8) = 6: clipPoints(9) = 6.75
    
    ' Clip the image
    rasterObj.clipBoundary clipPoints
    
    ' Enable the display of the clip
    rasterObj.ClippingEnabled = True
    ThisDrawing.Regen acActiveViewport
    MsgBox "The image has been clipped.", , "ClipBoundary Example"
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_ClipBoundary()
    ;; This example adds a raster image in model space.
    ;; It then clips the image based on a clip boundary.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; This example uses the "2d Projected Polylines.jpg" found in the Sample
    ;; directory. If you do not have the image, or if it is located
    ;; in a different directory, insert a valid path and name for the
    ;; imageName variable below.
    (setq insertionPoint (vlax-3d-point 5 5 0)
          imageName ".\\Sample\\VBA\\2d Projected Polylines.jpg"
          scalefactor 2
          rotationAngle 0)

    (if (/= (findfile ".\\Sample\\VBA\\2d Projected Polylines.jpg") nil)
        (progn  
	    ;; Creates a raster image in model space
            (setq modelSpace (vla-get-ModelSpace doc))
            (setq rasterObj (vla-AddRaster modelSpace (findfile ".\\Sample\\VBA\\2d Projected Polylines.jpg") insertionPoint scalefactor rotationAngle))
    
	    (vla-ZoomAll acadObj)
	    (alert "Clip the image?")
	    
	    ;; Establish the clip boundary with an array of points
	    (setq clipPoints (vlax-make-safearray vlax-vbDouble '(0 . 9)))
	    (vlax-safearray-fill clipPoints '(6 6.75
					                                  7 6
					                                  6 5
					                                  5 6
					                                  6 6.75
					                                 )
	    )
	    
	    ;; Clip the image
	    (vla-ClipBoundary rasterObj clipPoints)
	    
	    ;; Enable the display of the clip
	    (vla-put-ClippingEnabled rasterObj :vlax-true)
	    (vla-Regen doc acActiveViewport)
	    (alert "The image has been clipped.")
        )
        (alert (strcat imageName " could not be found."))
    )    
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 11:46

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部