若要向工具栏添加新的工具栏按钮,请使用该方法。此方法创建一个新对象并将其添加到指定的工具栏。AddToolbarButtonToolbarItem 仅应在工具栏可见时向工具栏添加按钮。 该方法将五个参数作为输入:索引、名称、帮助字符串、宏和浮出控件按钮。AddToolbarButton
向新工具栏添加按钮本示例创建一个新工具栏,并向该工具栏添加一个按钮。为按钮分配了一个宏,该宏将在选择按钮时执行 OPEN 命令。 Sub Ch6_AddButton() Dim currMenuGroup As AcadMenuGroup Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0) ' Create the new toolbar Dim newToolbar As AcadToolbar Set newToolbar = currMenuGroup.Toolbars.Add("TestToolbar") ' Add a button to the new toolbar Dim newButton As AcadToolbarItem Dim openMacro As String ' Assign the macro the VB equivalent of "ESC ESC _open " openMacro = Chr(3) + Chr(3) + "_open " Set newButton = newToolbar.AddToolbarButton _ ("", "NewButton", "Open a file.", openMacro) End Sub |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )
GMT+8, 2024-6-10 20:21
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.