EntityColor プロパティ(ActiveX)

True Color の色の値を指定します。

サポートされているプラットフォーム: Windows のみ

構文と要素

VBA:

object.EntityColor
object

タイプ: AcCmColor

このプロパティが適用されるオブジェクト。

プロパティの値

読み込み専用: いいえ

タイプ: 長整数型

True Color の色の値。

注意

このプロパティは、色の 32 ビット AcCMEntityColor 部分を指定します。

VBA:

Sub Example_EntityColor()
    Dim color As AcadAcCmColor
    Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.20")
    Dim y As Long
    y = MakeLong(MakeWord(194, 122), MakeWord(133, 144))
    color.EntityColor = y
    Dim line As AcadLine
    Set line = CreateLine
    line.TrueColor = color
    Dim retcolor As AcadAcCmColor
    Set retcolor = line.TrueColor
    
    Dim x As Long
    x = retcolor.EntityColor
    
    Dim BreakLong(3) As Byte
    BreakLong(0) = x And &HFF&
    BreakLong(1) = (x And &HFF00&) \ &H100&
    BreakLong(2) = (x And &HFF0000) \ &H10000
    BreakLong(3) = (x And &H7F000000) \ &H1000000
    If x < 0 Then BreakLong(3) = BreakLong(3) Or &H80
    
    MsgBox "ColorMethod = " & BreakLong(3) & vbCrLf & _
     "Red = " & BreakLong(2) & vbCrLf & _
     "Green = " & BreakLong(1) & vbCrLf & _
     "Blue = " & BreakLong(0)
End Sub

Private Function CreateLine() As AcadLine
    Dim lineObj As AcadLine
    Dim startPoint(0 To 2) As Double
    Dim endPoint(0 To 2) As Double
    
    startPoint(0) = 1#: startPoint(1) = 1#: startPoint(2) = 0#
    endPoint(0) = 5#: endPoint(1) = 5#: endPoint(2) = 0#
    
    Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
    Set CreateLine = lineObj
    ZoomAll
End Function

Private Function MakeLong(WordHi As Variant, WordLo As Integer) As Long

   ' High word is coerced to a variant on the call, to allow
   ' it to overflow the limits of multiplication, which shifts
   ' it left.

   MakeLong = (WordHi * &H10000) + (WordLo And &HFFFF&)
End Function

Private Function MakeWord(ByteHi As Byte, ByteLo As Byte) As Integer
   ' If the high byte would push the final result out of the
   ' signed integer range, it must be slid back.

   If ByteHi > &H7F Then
      MakeWord = ((ByteHi * &H100&) + ByteLo) - &H10000
   Else
      MakeWord = (ByteHi * &H100&) + ByteLo
   End If
End Function

Visual LISP:

(vl-load-com)
(defun c:Example_EntityColor()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    (setq color (vlax-create-object "AutoCAD.AcCmColor.20"))
  
    (setq y (MakeLong (MakeWord 194 122) (MakeWord 133 144)))
    (vla-put-EntityColor color y)

    (setq modelSpace (vla-get-ModelSpace doc))
    (setq line (CreateLine))
    (vla-put-TrueColor line color)
    (setq retcolor (vla-get-TrueColor line))
    
    (setq x (vla-get-EntityColor retcolor))
    
    (setq BreakLong (vlax-make-safearray vlax-vbDouble '(0 . 3)))
    (vlax-safearray-put-element BreakLong 0 (logand x 255))
    (vlax-safearray-put-element BreakLong 1 (/ (logand x 65280) 256))
    (vlax-safearray-put-element BreakLong 2 (/ (logand x 16711680) 65536))
    (vlax-safearray-put-element BreakLong 3 (/ (logand x 2130706432) 16777216))

    (if (< x 0)
        (vlax-safearray-put-element BreakLong 3 (logior (fix (vlax-safearray-get-element BreakLong 3)) 128))
    )
    
    (alert (strcat "ColorMethod = " (itoa (fix (vlax-safearray-get-element BreakLong 3))) "\n"
                   "Red = " (itoa (fix (vlax-safearray-get-element BreakLong 2))) "\n"
                   "Green = " (itoa (fix (vlax-safearray-get-element BreakLong 1))) "\n"
                   "Blue = " (itoa (fix (vlax-safearray-get-element BreakLong 0)))))

    (vlax-release-object color)
)


(defun CreateLine()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    (setq startPoint (vlax-3d-point 1 1 0)
          endPoint (vlax-3d-point 5 5 0)) 

    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq lineObj (vla-AddLine modelSpace startPoint endPoint))
    (vla-ZoomAll acadObj)
    lineObj
)

(defun MakeLong (WordHi WordLo)
   ;; High word is coerced to a variant on the call, to allow
   ;; it to overflow the limits of multiplication, which shifts
   ;; it left.
   (+ (* WordHi 65536) (logand WordLo 65535))
)

(defun MakeWord(ByteHi ByteLo)
   ;; If the high byte would push the final result out of the
   ;; signed integer range, it must be slid back.
   (if (> ByteHi 127)
      (- (+ (* ByteHi 256) ByteLo) 65536)
      (+ (* ByteHi 256) ByteLo)
   )
)