既存のイメージ ファイルに基づいて、新しいラスター イメージ図形を作成します。
サポートされているプラットフォーム: Windows のみ
VBA:
RetVal = object.AddRaster(ImageFileName, InsertionPoint, ScaleFactor, RotationAngle)
タイプ: Block、ModelSpace、PaperSpace
このメソッドが適用されるオブジェクト。
アクセス: 入力のみ
タイプ: 文字列
イメージの絶対パスとファイル名。
アクセス: 入力のみ
タイプ: バリアント型(3 要素の倍精度浮動小数点数型配列)
ラスター イメージが作成される図面内の位置を示す 3D WCS 座標。
アクセス: 入力のみ
タイプ: 倍精度浮動小数点数型
ラスター イメージの尺度係数。既定のイメージ尺度係数は 1 です。尺度係数は正の数である必要があります。AutoCAD 図面で作成されたジオメトリの尺度に合わせて、イメージの尺度を設定することができます。
アクセス: 入力のみ
タイプ: 倍精度浮動小数点数型
ラスター イメージ回転角度(ラジアン)。
AddRaster メソッドを介して配置されたイメージは、実際の図面ファイルの一部にはなりません。ラスター イメージは、パス名またはドキュメント ID によって、図面ファイルにリンクされます。リンク イメージのパスは、SupportPath プロパティを使用して、いつでも変更したり削除することができます。リンク イメージのパスを使用してイメージをアタッチすれば、図面のファイル サイズを増加させずに、図面にイメージを配置することができます。
同じラスター イメージ ファイルを、何度でも図面ファイルに追加することができます。各インスタンスには、独自のクリップ境界と、明るさ、コントラスト、フェード、および透過性の設定があります。1 つのイメージを複数の部分に分割して、それを図面中に個別に再配置することができます。
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
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."))
)
)