sjtd 发表于 2008-11-20 13:35:00

[求助] 如何使自己创建的工具栏 在CAD重启后不需要再运行创建宏1

本帖最后由 作者 于 2008-11-24 20:22:53 编辑 <br /><br /> <p>我创建的工具栏,再CAD2007中保存不了,每次启动都要运行创建宏,请大侠,高手帮我看看问题出那里了,谢谢!</p><p></p><p><font size="5">有没有高手呀。帮帮忙啦。。。。。</font></p><p></p><p>原代码如下::</p><font color="#1111ee">Public Sub AddmyBar()<br/>&nbsp;Dim i As Integer<br/>&nbsp;&nbsp;&nbsp; Dim currMenuGroup As AcadMenuGroup<br/>&nbsp;&nbsp;&nbsp; Dim newToolBar As AcadToolbar<br/>&nbsp;&nbsp;&nbsp; Dim openMacro(10) As String<br/>&nbsp;&nbsp;&nbsp; Dim NewButton(10) As AcadToolbarItem<br/>&nbsp;&nbsp;&nbsp; Dim smallbitmapname(10) As String<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim pathS As String<br/>&nbsp;&nbsp;&nbsp; Dim appPath As String<br/>&nbsp;&nbsp;&nbsp; appPath = ThisDrawing.Application.Path<br/>&nbsp;&nbsp;&nbsp; pathS = "\Support\Survey\Icon\"<br/>&nbsp;&nbsp;&nbsp; pathS = appPath &amp; pathS<br/>'创建自己标注工具栏<br/>&nbsp;&nbsp;&nbsp; Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Set newToolBar = currMenuGroup.Toolbars.Add("都成军_专用工具栏")<br/>&nbsp;&nbsp;&nbsp; newToolBar.Float 300, 300, 1<br/>&nbsp; <br/>&nbsp;&nbsp;&nbsp; openMacro(0) = "-vbarun" + " " + "xzFont" + " "<br/>&nbsp;&nbsp;&nbsp; Set NewButton(0) = newToolBar.AddToolbarButton(newToolBar.Count + 1, "将文字角度改为 0", "将文字角度改为 0", openMacro(0))<br/>&nbsp;&nbsp;&nbsp; '设置第1个按钮的图标<br/>&nbsp;&nbsp;&nbsp; smallbitmapname(0) = pathS &amp; "fb.bmp"<br/>&nbsp;&nbsp;&nbsp; NewButton(0).SetBitmaps smallbitmapname(0), smallbitmapname(0)<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; openMacro(1) = "-vbarun" + " " + "zd" + " "<br/>&nbsp;&nbsp;&nbsp; Set NewButton(1) = newToolBar.AddToolbarButton(newToolBar.Count + 1, "展临时点/摘录控制点/点位坐标标注", "展临时点,摘录控制点,点位坐标标准", openMacro(1))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '设置第2个按钮的图标<br/>&nbsp;&nbsp;&nbsp; smallbitmapname(1) = pathS &amp; "ATA.BMP"<br/>&nbsp;&nbsp;&nbsp; NewButton(1).SetBitmaps smallbitmapname(1), smallbitmapname(1)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp; openMacro(2) = "-vbarun" + " " + "dcj_modi.cs" + " "<br/>&nbsp;&nbsp;&nbsp; Set NewButton(2) = newToolBar.AddToolbarButton(newToolBar.Count + 1, "平面标注、修改", "平面标注、修改", openMacro(2))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '设置第3个按钮的图标<br/>&nbsp;&nbsp;&nbsp; smallbitmapname(2) = pathS &amp; "XXWZ.BMP"<br/>&nbsp;&nbsp;&nbsp; NewButton(2).SetBitmaps smallbitmapname(2), smallbitmapname(2)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp; openMacro(3) = "-vbarun" + " " + "Survey.DimDrawing.SetTextStyle" + " "<br/>&nbsp;&nbsp;&nbsp; Set NewButton(3) = newToolBar.AddToolbarButton(newToolBar.Count + 1, "更换文本字体", "更换文本字体", openMacro(3))<br/>&nbsp;&nbsp;&nbsp; '设置第1个按钮的图标<br/>&nbsp;&nbsp;&nbsp; smallbitmapname(3) = pathS &amp; "TextStyle.bmp"<br/>&nbsp;&nbsp;&nbsp; NewButton(3).SetBitmaps smallbitmapname(3), smallbitmapname(3)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; openMacro(4) = "-vbarun" + " " + "swline" + " "<br/>&nbsp;&nbsp;&nbsp; Set NewButton(4) = newToolBar.AddToolbarButton(newToolBar.Count + 1, "绘制3DLINE", "绘制三维线,以确保管道实长", openMacro(4))<br/>&nbsp;&nbsp;&nbsp; '设置第1个按钮的图标<br/>&nbsp;&nbsp;&nbsp; smallbitmapname(4) = pathS &amp; "XYZ_LINE.bmp"<br/>&nbsp;&nbsp;&nbsp; NewButton(4).SetBitmaps smallbitmapname(4), smallbitmapname(0)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; openMacro(5) = "-vbarun" + " " + "ljfft" + " "<br/>&nbsp;&nbsp;&nbsp; Set NewButton(5) = newToolBar.AddToolbarButton(newToolBar.Count + 1, "拼接分幅图.", "拼接分幅图.", openMacro(5))<br/>&nbsp;&nbsp;&nbsp; '设置第1个按钮的图标<br/>&nbsp;&nbsp;&nbsp; smallbitmapname(5) = pathS &amp; "ljfft.bmp"<br/>&nbsp;&nbsp;&nbsp; NewButton(5).SetBitmaps smallbitmapname(5), smallbitmapname(5)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; openMacro(6) = "-vbarun" + " " + "lcjs" + " "<br/>&nbsp;&nbsp;&nbsp; Set NewButton(6) = newToolBar.AddToolbarButton(newToolBar.Count + 1, "计算里程.", "计算里程.", openMacro(6))<br/>&nbsp;&nbsp;&nbsp; '设置第1个按钮的图标<br/>&nbsp;&nbsp;&nbsp; smallbitmapname(6) = pathS &amp; "lcjs.bmp"<br/>&nbsp;&nbsp;&nbsp; NewButton(6).SetBitmaps smallbitmapname(6), smallbitmapname(6)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; openMacro(7) = "-vbarun" + " " + "bgxd" + " "<br/>&nbsp;&nbsp;&nbsp; Set NewButton(7) = newToolBar.AddToolbarButton(newToolBar.Count + 1, "管线点变大变小.", "管线点变大变小.", openMacro(7))<br/>&nbsp;&nbsp;&nbsp; '设置第1个按钮的图标<br/>&nbsp;&nbsp;&nbsp; smallbitmapname(7) = pathS &amp; "sgxd.bmp"<br/>&nbsp;&nbsp;&nbsp; NewButton(7).SetBitmaps smallbitmapname(7), smallbitmapname(7)<br/>&nbsp;currMenuGroup.Save acMenuFileSource</font>

mccad 发表于 2008-11-22 12:39:00

<p>一般不建议在程序中创建菜单或工具栏,除非你的东西是动态的。</p><p>建议直接使用菜单文件建立这些东西。</p><p>一般程序建立的工具栏或菜单,只能当前进程有效,关了再开就没了。要重新再来。就象你运行程序道理是一样。</p>

sjtd 发表于 2008-11-22 13:10:00

那在CAD2004中是可以的呀。

mccad 发表于 2008-11-22 17:35:00

<p>好象从2006版本后,菜单系统就有了变化,使用了配置方式,确实麻烦了许多。</p>
页: [1]
查看完整版本: [求助] 如何使自己创建的工具栏 在CAD重启后不需要再运行创建宏1