CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2024 开发者帮助

SetGridVisibility 方法 (ActiveX)

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

SetGridVisibility 方法 (ActiveX)

设置指定网格线型和行类型的网格可见性值。

支持的平台:仅限 Windows

签名

VBA:

object.SetGridVisibility gridLineTypes, rowTypes, bValue
对象

类型:TableTableStyle

此方法应用到的对象。

gridLineTypes

访问:仅输入

类型:枚举AcGridLineType

要更改的网格线类型。

  • acHorzBottom
  • acHorzInside
  • acHorzTop
  • acInvalidGridLine
  • acVertInside
  • acVertLeft
  • acVertRight
行类型

访问:仅输入

类型:枚举AcRowType

要更改的行类型。

  • acDataRow
  • acHeaderRow
  • acTitleRow
  • acUnknownRow
b值

访问:仅输入

类型:布尔

  • True:网格对于指定的行类型可见。
  • False:对于指定的行类型,网格不可见。

返回值 (RetVal)

无返回值。

言论

没有其他评论。

例子

VBA:

Sub Example_SetGridVisibility()
    ' 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 colGridCurrent As AcadAcCmColor, lwGridCurrent As ACAD_LWEIGHT, visGridCurrent As Boolean
    Set colGridCurrent = tableStyle.GetGridColor(acHorzBottom, acTitleRow)
    lwGridCurrent = tableStyle.GetGridLineWeight(acHorzBottom, acTitleRow)
    visGridCurrent = tableStyle.GetGridVisibility(acHorzTop, acTitleRow)

    MsgBox "Grid settings " & vbLf & _
           "nColor (Bottom) = " & colGridCurrent.ColorIndex & vbLf & _
           "nLineweight (Bottom) = " & lwGridCurrent & vbLf & _
           "Visibility (Top) =  " & visGridCurrent
  
    Dim col As AcadAcCmColor
    Set col = tableStyle.GetGridColor(acHorzBottom, acTitleRow)
    col.SetRGB 0, 0, 255

    tableStyle.SetGridColor acHorzBottom, acTitleRow, col
    tableStyle.SetGridLineWeight acHorzBottom, acTitleRow, acLnWt025

    If visGridCurrent = False Then
        tableStyle.SetGridVisibility acHorzTop, acTitleRow, True
    Else
        tableStyle.SetGridVisibility acHorzTop, acTitleRow, False
    End If
      
    Dim colGridNew As AcadAcCmColor, lwGridNew As ACAD_LWEIGHT, visGridNew As Boolean
    Set colGridNew = tableStyle.GetGridColor(acHorzBottom, acTitleRow)
    lwGridNew = tableStyle.GetGridLineWeight(acHorzBottom, acTitleRow)
    visGridNew = tableStyle.GetGridVisibility(acHorzTop, acTitleRow)

    MsgBox "Grid settings " & vbLf & _
           "nColor (Bottom) = " & colGridNew.ColorIndex & vbLf & _
           "nLineweight (Bottom) = " & lwGridNew & vbLf & _
           "Visibility (Top) =  " & visGridNew
             
    tableStyle.SetGridColor acHorzBottom, acTitleRow, colGridCurrent
    tableStyle.SetGridLineWeight acHorzBottom, acTitleRow, lwGridCurrent
    tableStyle.SetGridVisibility acHorzTop, acTitleRow, visGridCurrent
      
    MsgBox "Reset the table style back to its original values."
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_SetGridVisibility()
    ;; 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 colGridCurrent (vla-GetGridColor tableStyle acHorzBottom acTitleRow)
          lwGridCurrent (vla-GetGridLineWeight tableStyle acHorzBottom acTitleRow)
          visGridCurrent (vla-GetGridVisibility tableStyle acHorzTop acTitleRow))

    (alert (strcat "Grid settings"
                   "\nColor (Bottom) = " (itoa (vla-get-ColorIndex colGridCurrent))
                   "\nLineweight (Bottom) = " (itoa lwGridCurrent)
                   "\nVisibility (Top)= " (if (= visGridCurrent :vlax-true) "True" "False")))

    (setq col (vla-GetGridColor tableStyle acHorzBottom acTitleRow))
    (vla-SetRGB col 0 0 255)

    (vla-SetGridColor tableStyle acHorzBottom acTitleRow col)
    (vla-SetGridLineWeight tableStyle acHorzBottom acTitleRow acLnWt025)
    (vla-SetGridVisibility tableStyle acHorzTop acTitleRow (if (= visGridCurrent :vlax-true) :vlax-false :vlax-true))

    (setq colGridNew (vla-GetGridColor tableStyle acHorzBottom acTitleRow)
          lwGridNew (vla-GetGridLineWeight tableStyle acHorzBottom acTitleRow)
          visGridNew (vla-GetGridVisibility tableStyle acHorzTop acTitleRow))

    (alert (strcat "Grid settings"
                   "\nColor (Bottom) = " (itoa (vla-get-ColorIndex colGridNew))
                   "\nLineweight (Bottom) = " (itoa lwGridNew)
                   "\nVisibility (Top)= " (if (= visGridNew :vlax-true) "True" "False")))

    (vla-SetGridColor tableStyle acHorzBottom acTitleRow colGridCurrent)
    (vla-SetGridLineWeight tableStyle acHorzBottom acTitleRow lwGridCurrent)
    (vla-SetGridVisibility tableStyle acHorzBottom acTitleRow visGridCurrent)
  
    (alert "Reset the table style back to its original values.")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 11:49

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部