CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2025 开发者帮助

GetBackgroundColor 方法 (ActiveX)

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

GetBackgroundColor 方法 (ActiveX)

返回指定行类型的背景颜色值。

支持的平台:仅限 Windows

签名

VBA:

RetVal = object.GetBackgroundColor(rowType)
对象

类型:TableTableStyle

此方法应用到的对象。

行类型

访问:仅输入

类型:枚举AcRowType

行类型。

  • acDataRow
  • acHeaderRow
  • acTitleRow
  • acUnknownRow

返回值 (RetVal)

类型:AcCmColor

指定给行类型的背景色的 AutoCAD 真彩色对象。

言论

没有其他评论。

例子

VBA:

Sub Example_GetBackgroundColor()
    ' This example creates a TableStyle object and sets values for
    ' the style name and other attributes.
    
    Dim dictionaries As AcadDictionaries
    Set dictionaries = ThisDrawing.Database.dictionaries
  
    Dim dictObj As AcadDictionary
    Set dictObj = dictionaries.Item("acad_tablestyle")
  
    ' Get the current TableStyle object
    Dim tableStyle As AcadTableStyle
    Set tableStyle = dictObj.Item(ThisDrawing.GetVariable("CTABLESTYLE"))
  
    Dim colCurrent As AcadAcCmColor, colRowCurrent As AcadAcCmColor, colNoneCurrent As Boolean
    Set colCurrent = tableStyle.GetBackgroundColor(acTitleRow)
    Set colRowCurrent = tableStyle.GetColor(acDataRow)
    colNoneCurrent = tableStyle.GetBackgroundColorNone(acHeaderRow)

    MsgBox "Table colors " & vbLf & _
           "Background ACI value = " & colCurrent.ColorIndex & vbLf & _
           "Row Text ACI value = " & colRowCurrent.ColorIndex & vbLf & _
           "Background None = " & colNoneCurrent
  
    Dim col As AcadAcCmColor
    Set col = tableStyle.GetBackgroundColor(acTitleRow)
    col.SetRGB 0, 0, 255
    tableStyle.SetBackgroundColor acTitleRow, col
    col.SetRGB 255, 0, 0
    tableStyle.SetColor acDataRow, col
    If colNoneCurrent = False Then
        tableStyle.SetBackgroundColorNone acHeaderRow, True
    Else
        tableStyle.SetBackgroundColorNone acHeaderRow, False
    End If
      
    Dim colNew As AcadAcCmColor, colRowNew As AcadAcCmColor, colNoneNew As Boolean
    Set colNew = tableStyle.GetBackgroundColor(acTitleRow)
    Set colRowNew = tableStyle.GetColor(acDataRow)
    colNoneNew = tableStyle.GetBackgroundColorNone(acHeaderRow)

    MsgBox "Table colors " & vbLf & _
           "Background ACI value = " & colNew.ColorIndex & vbLf & _
           "Row Text ACI value = " & colRowNew.ColorIndex & vbLf & _
           "Background None = " & colNoneNew
  
    tableStyle.SetBackgroundColor acTitleRow, colCurrent
    tableStyle.SetColor acDataRow, colRowCurrent
    tableStyle.SetBackgroundColorNone acHeaderRow, colNoneCurrent
    
    MsgBox "Reset the table style back to its original values."
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_GetBackgroundColor()
    ;; This example creates a TableStyle object and sets values for 
    ;; the style name and other attributes.
    (setq acadObj (vlax-get-acad-object)
          doc (vla-get-ActiveDocument acadObj))

    (setq dictionaries (vla-get-Dictionaries doc)
          dictObj (vla-Item dictionaries "acad_tablestyle"))
    
    ;; Get the current TableStyle object
    (setq tableStyle (vla-Item dictObj (vla-GetVariable doc "CTABLESTYLE")))
      
    (setq colCurrent (vla-GetBackgroundColor tableStyle acTitleRow)
          colRowCurrent (vla-GetColor tableStyle acDataRow)
          colNoneCurrent (vla-GetBackgroundColorNone tableStyle acHeaderRow))

    (alert (strcat "Table colors \n"
                   "Background ACI value = " (itoa (vla-get-ColorIndex colCurrent)) "\n"
                   "Row Text ACI value = " (itoa (vla-get-ColorIndex colRowCurrent)) "\n"
                   "Background None = " (if (= colNoneCurrent :vlax-true) "True" "False")))

    (setq col (vla-GetBackgroundColor tableStyle acTitleRow))
    (vla-SetRGB col 0 0 255)
    (vla-SetBackgroundColor tableStyle acTitleRow col)
    (vla-SetRGB col 255 0 0)
    (vla-SetColor tableStyle acDataRow col)
    (vla-SetBackgroundColorNone tableStyle acHeaderRow (if (= colNoneCurrent :vlax-true) :vlax-false :vlax-true))
  
    (setq colNew (vla-GetBackgroundColor tableStyle acTitleRow)
          colRowNew (vla-GetColor tableStyle acDataRow)
          colNoneNew (vla-GetBackgroundColorNone tableStyle acHeaderRow))

    (alert (strcat "Table colors \n"
                   "Background ACI value = " (itoa (vla-get-ColorIndex colNew)) "\n"
                   "Row Text ACI value = " (itoa (vla-get-ColorIndex colRowNew)) "\n"
                   "Background None = " (if (= colNoneNew :vlax-true) "True" "False")))

    (vla-SetBackgroundColor tableStyle acTitleRow colCurrent)
    (vla-SetColor tableStyle acDataRow colRowCurrent)
    (vla-SetBackgroundColorNone tableStyle acHeaderRow colNoneCurrent)

    (alert "Reset the table style back to its original values.")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-6-27 15:59

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部