CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2018 开发者帮助

AddRaster 方法 (ActiveX)

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

AddRaster 方法 (ActiveX)

基于现有影像文件创建新的光栅影像。

支持的平台:仅限 Windows

签名

VBA:

RetVal = object.AddRaster(ImageFileName, InsertionPoint, ScaleFactor, RotationAngle)
对象

类型:模型空间纸空间

此方法应用到的对象。

ImageFileName

访问:仅输入

类型:字符串

映像的完整路径和文件名。

插入点

访问:仅输入

类型:变体(双打的三元素阵列)

图形中将创建光栅图像的 3D WCS 坐标。

比例因子

访问:仅输入

类型:

栅格图像比例因子。默认图像比例因子为 1。比例因子必须为正数。可以将图像的比例设置为在 AutoCAD 图形中创建的几何图形的比例。

旋转角度

访问:仅输入

类型:

光栅图像的旋转角度(以弧度为单位)。

返回值 (RetVal)

类型:RasterImage

新创建的对象。RasterImage

言论

通过该方法置入的图像实际上不是图形文件的一部分。光栅图像通过路径名或文档 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."))
    )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-3-14 07:21

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部