EntityColor Пример

Sub Example_EntityColor()
    Dim color As AcadAcCmColor
    Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.16")
    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

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

Private Function MakeWord(ByteHi As Byte, ByteLo As Byte) As Integer
   If ByteHi > &H7F Then
      MakeWord = ((ByteHi * &H100&) + ByteLo) - &H10000
   Else
      MakeWord = (ByteHi * &H100&) + ByteLo
   End If
End Function
Сайт управляется системой uCoz