CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

关于显示和隐藏剪切边界 (VBA/ActiveX)

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

摘要: 可以使用剪切边界显示剪切的图像,也可以隐藏剪切边界并显示原始图像边界。

可以使用剪切边界显示剪切的图像,也可以隐藏剪切边界并显示原始图像边界。

若要隐藏剪切边界并显示原始图像,请将该属性设置为 FALSE。若要显示剪裁的图像,请将该属性设置为 TRUE。ClippingEnabledClippingEnabled

裁剪光栅图像边界

本示例在模型空间中添加光栅图像。然后,它根据剪辑边界裁剪图像。此示例使用在示例目录中找到的downtown.jpg文件。如果没有此映像,或者它位于其他目录中,请为imageName变量插入有效的路径和文件名。

Sub Ch10_ClippingRasterBoundary()
 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\downtown.jpg"
 insertionPoint(0) = 5
 insertionPoint(1) = 5
 insertionPoint(2) = 0
 scalefactor = 2
 rotationAngle = 0

 On Error GoTo ERRORHANDLER
 ' Creates a raster image in model space
 Set rasterObj = ThisDrawing.ModelSpace.AddRaster _
 (imageName, insertionPoint, _
 scalefactor, rotationAngle)
 ZoomAll
 ' 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
 Exit Sub

ERRORHANDLER:
 MsgBox Err.Description
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 03:11

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部