CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

添加栅格方法 (ActiveX)

2023-1-4 12:32| 发布者: admin| 查看: 646| 评论: 0|来自: AutoCAD

摘要: 基于现有图像文件创建新的光栅图像。

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

支持的平台:仅窗口

签名

工 务 局:

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

类型:模型空间,图纸空间

此方法适用的对象。

图像文件名

访问:仅输入

类型:字符串

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

插入点

访问:仅输入

类型:变体(双精度的三元素数组)

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

比例因子

访问:仅输入

类型:

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

旋转角度

访问:仅输入

类型:

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

返回值(RetVal)

类型:栅格图像

新创建的对象。RasterImage

言论

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

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-11 23:58

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部