TrueColorImages 属性 (ActiveX)
确定光栅和渲染图像是以真彩色还是托盘化颜色显示。 支持的平台:仅限 Windows 属性值只读:不 类型:布尔
言论此属性的初始值为 False。 例子VBA: Sub Example_TrueColorImages()
' This example reads and modifies the preference value which determines
' if raster and render images are displayed at True Color or palletized color.
' When finished, this example resets the preference value back to
' it's original value.
'
' This example uses the "2d Projected Polylines.jpg" found in the sample
' directory. If you do not have this image, or it is located
' in a different directory, insert a valid path and file name
' for the imageName variable below.
Dim ACADPref As AcadPreferencesDisplay
Dim originalValue As Variant, newValue As Variant
Dim insertionPoint(0 To 2) As Double
Dim scalefactor As Double, rotationAngle As Double
Dim imageName As String
Dim rasterObj As AcadRasterImage
imageName = "c:\AutoCAD\sample\2d Projected Polylines.jpg"
' Define Raster object
insertionPoint(0) = 5: insertionPoint(1) = 5: insertionPoint(2) = 0
scalefactor = 5#: rotationAngle = 0
On Error GoTo ERRORTRAP
' Loads a raster image into model space
Set rasterObj = ThisDrawing.ModelSpace.AddRaster(imageName, insertionPoint, scalefactor, rotationAngle)
ThisDrawing.Application.ZoomAll
' Get the display preferences object
Set ACADPref = ThisDrawing.Application.Preferences.Display
' Read and display the original value
originalValue = ACADPref.TrueColorImages
MsgBox "The TrueColorImages preference is set to: " & originalValue
' Modify the TrueColorImages preference by toggling the value
ACADPref.TrueColorImages = Not (originalValue)
newValue = ACADPref.TrueColorImages
ThisDrawing.Regen acAllViewports
MsgBox "The TrueColorImages preference has been set to: " & newValue
' Reset the preference back to it's original value
'
' * Note: Comment out this last section to leave the change to
' this preference in effect
ACADPref.TrueColorImages = originalValue
ThisDrawing.Regen acAllViewports
MsgBox "The TrueColorImages preference was reset back to: " & originalValue
Exit Sub
' If you got an error (most likely a problem with the file path),
' then display an error message
ERRORTRAP:
If Err.Description <> "" Then
MsgBox Err.Description
End If
End Sub
可视化 LISP: (vl-load-com)
(defun c:Example_TrueColorImages()
;; This example reads and modifies the preference value which determines
;; if raster and render images are displayed at True Color or palletized color.
;; When finished, this example resets the preference value back to
;; it's original value.
;;
;; This example uses the "2d Projected Polylines.jpg" found in the sample
;; directory. If you do not have this image, or it is located
;; in a different directory, insert a valid path and file name
;; for the imageName variable below.
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
;; Define Raster object
(setq insertionPoint (vlax-3d-point 5 5 0)
imageName ".\\Sample\\VBA\\2d Projected Polylines.jpg"
scalefactor 5
rotationAngle 0)
(if (/= (findfile imageName) nil)
(progn
;; Creates a raster image in model space
(setq modelSpace (vla-get-ModelSpace doc))
(setq raster (vla-AddRaster modelSpace (findfile imageName) insertionPoint scalefactor rotationAngle))
(vla-ZoomExtents acadObj)
;; Get the display preferences object
(setq ACADPref (vla-get-Display (vla-get-Preferences acadObj)))
;; Read and display the original value
(setq originalValue (vla-get-TrueColorImages ACADPref))
(alert (strcat "The TrueColorImages preference is set to: " (if (= originalValue :vlax-true) "True" "False")))
;; Modify the TrueColorImages preference by toggling the value
(vla-put-TrueColorImages ACADPref (if (= originalValue :vlax-true) :vlax-false :vlax-true))
(vla-Regen doc acAllViewports)
(alert (strcat "The TrueColorImages preference has been set to: " (if (= (vla-get-TrueColorImages ACADPref) :vlax-true) "True" "False")))
;; Reset the preference back to it's original value
;;
;; * Note: Comment out this last section to leave the change to
;; this preference in effect
(vla-put-TrueColorImages ACADPref originalValue)
(vla-Regen doc acAllViewports)
(alert (strcat "The TrueColorImages preference was reset back to: " (if (= (vla-get-TrueColorImages ACADPref) :vlax-true) "True" "False")))
)
(alert (strcat imageName " could not be found."))
)
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-11-2 03:16
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.