AddRaster 方法 (ActiveX)
基于现有影像文件创建新的光栅影像。 支持的平台:仅限 Windows 签名VBA: RetVal = object.AddRaster(ImageFileName, InsertionPoint, ScaleFactor, RotationAngle) 言论通过该方法置入的图像实际上不是图形文件的一部分。光栅图像通过路径名或文档 ID 链接到图形文件,可以使用该属性随时更改或删除链接的图像路径。通过使用链接的图像路径附着图像,可以在不增加图形文件大小的情况下将图像置入图形中。AddRasterSupportPath 可以多次将同一光栅图像文件添加到图形文件中。每个实例都有自己的剪辑边界以及自己的亮度、对比度、淡入淡出和透明度设置。单个图像可以剪切成多个部分,这些部分可以在图形中独立重新排列。 例子VBA: Sub Example_AddRaster()
' This example adds a raster image in model space.
' This example uses a file named "2d Projected Polylines.jpg."
' You should change this example to use
' a raster file on your computer.
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\2d Projected Polylines.jpg"
insertionPoint(0) = 5#: insertionPoint(1) = 5#: insertionPoint(2) = 0#
scalefactor = 1#
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 = "File error" Then
MsgBox imageName & " could not be found."
Exit Sub
End If
ZoomExtents
End Sub
可视化 LISP: (vl-load-com)
(defun c:Example_AddRaster()
;; This example adds a raster image in model space.
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
;; This example uses a file named "2d Projected Polylines.jpg."
;; You should change this example to use
;; a raster file on your computer.
(setq insertionPoint (vlax-3d-point 5 5 0)
imageName ".\\Sample\\VBA\\2d Projected Polylines.jpg"
scalefactor 1
rotationAngle 0)
;; Creates a raster image in model space
(if (/= (findfile imageName) nil)
(progn
(setq modelSpace (vla-get-ModelSpace doc))
(setq rasterObj (vla-AddRaster modelSpace (findfile imageName) insertionPoint scalefactor rotationAngle))
(vla-ZoomExtents acadObj)
)
(alert (strcat imageName " could not be found."))
)
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-24 08:23
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.