基于现有图像文件创建新的光栅图像。 支持的平台:仅窗口 签名工 务 局: RetVal = object.AddRaster(ImageFileName, InsertionPoint, ScaleFactor, RotationAngle) 言论通过该方法放置的图像实际上不是图形文件的一部分。光栅图像通过路径名或文档 ID 链接到图形文件。可以使用该属性随时更改或删除链接的图像路径。通过使用链接的图像路径附着图像,可以在图形中放置图像,而不会增加图形的文件大小。AddRasterSupportPath 可以将同一光栅图像文件多次添加到图形文件中。每个实例都有自己的剪辑边界以及自己的亮度、对比度、淡入淡出和透明度设置。可以将单个图像剪切成多个部分,这些部分可以在图形中独立重新排列。 例子工 务 局: 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
Visual 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-11-28 14:05
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.