GetColor2 方法 (ActiveX)
返回指定命名单元格样式的颜色值。 支持的平台:仅限 Windows 签名VBA: RetVal = object.GetColor2(bstrCellStyle)
言论没有其他评论。 例子VBA: Sub Example_GetColor2()
' 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.GetBackgroundColor2("Title")
Set colRowCurrent = tableStyle.GetColor2("Data")
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.SetBackgroundColor2 "Title", col
col.SetRGB 255, 0, 0
tableStyle.SetColor2 "Data", 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.GetBackgroundColor2("Title")
Set colRowNew = tableStyle.GetColor2("Data")
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.SetBackgroundColor2 "Title", colCurrent
tableStyle.SetColor2 "Data", colRowCurrent
tableStyle.SetBackgroundColorNone acHeaderRow, colNoneCurrent
MsgBox "Reset the table style back to its original values."
End Sub
可视化 LISP: (vl-load-com)
(defun c:Example_GetColor2()
;; 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-GetBackgroundColor2 tableStyle "Title")
colRowCurrent (vla-GetColor2 tableStyle "Data")
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-GetBackgroundColor2 tableStyle "Title"))
(vla-SetRGB col 0 0 255)
(vla-SetBackgroundColor2 tableStyle "Title" col)
(vla-SetRGB col 255 0 0)
(vla-SetColor2 tableStyle "Data" col)
(vla-SetBackgroundColorNone tableStyle acHeaderRow (if (= colNoneCurrent :vlax-true) :vlax-false :vlax-true))
(setq colNew (vla-GetBackgroundColor2 tableStyle "Title")
colRowNew (vla-GetColor2 tableStyle "Data")
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-SetBackgroundColor2 tableStyle "Title" colCurrent)
(vla-SetColor2 tableStyle "Data" colRowCurrent)
(vla-SetBackgroundColorNone tableStyle acHeaderRow colNoneCurrent)
(alert "Reset the table style back to its original values.")
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-11-2 18:56
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.