VB-VBA
明总你好,我有几个问题请教 先谢了1、先选择后执行,VBA怎样实现;<BR> 我看了<A href="dispbbs.asp?boardID=4&ID=28516&page=1" target="_blank" >dispbbs.asp?boardID=4&ID=28516&page=1</A> 的帖子,还是搞不太董。<BR> 下面是我自编的一个"删除图层上的所有实体"的程序
Sub TC1() '删除实体所在图层<BR> On Error Resume Next<BR> '删除图层中的对象<BR> Dim objDest As AcadEntity<BR> Dim ptBase As Variant<BR> Dim FilterType As Variant<BR> Dim FilterData As Variant<BR> Dim Sel As AcadSelectionSet<BR> Dim fdata(0) As Variant<BR> Dim ftype(0) As Integer<BR> Dim Pickedobj As AcadEntity<BR> Dim VByn As String<BR> Dim TCName As String<BR> Do<BR> '如果先选择了一个实体,这里应该怎样添加判断选择集不为空,就不用执行下面一行的程序。 <BR> ThisDrawing.Utility.GetEntity objDest, ptBase, "选择所删除图层中的实体>>"<BR> If objDest.ObjectName = "" Then<BR> VByn = MsgBox("请重新选择图层", 5, "删除图层")<BR> If VByn <> "4" Then<BR> Exit Sub<BR> End If<BR> Else<BR> Exit Do<BR> End If<BR> Loop<BR> ftype(0) = 8<BR> fdata(0) = objDest.Layer<BR> FilterType = ftype<BR> FilterData = fdata<BR> TCName = objDest.Layer<BR> If ThisDrawing.Layers(TCName).Lock = True Then<BR> VByn = MsgBox("该图层已锁定,删除", 4, "删除图层")<BR> If VByn = "6" Then<BR> ThisDrawing.Layers(TCName).Lock = False '解锁<BR> Else<BR> Exit Sub<BR> End If<BR> End If<BR> Set Sel = ThisDrawing.SelectionSets.Add("ssel")<BR> If Err Then<BR> Err.Clear<BR> ThisDrawing.SelectionSets("ssel").Delete<BR> Set Sel = ThisDrawing.SelectionSets.Add("ssel")<BR> End If<BR> Sel.Select acSelectionSetAll, , , FilterType, FilterData<BR> For Each Pickedobj In Sel<BR> Pickedobj.Delete<BR> Next<BR>End Sub<BR>如果先选择了一个实体,应该怎样加载运行这个宏?
2、按右键怎么运行上次执行的宏;<BR> 如果执行完上面的命令后,按右键怎么运行上次运行的程序,不要老是提示输入宏名称。
3、VB自编菜单命令怎样加载运行自己写的宏,老是说执行宏错误,宏应放在什么地方。<BR> '新菜单2<BR> Dim MenuOpenB As AcadPopupMenuItem<BR> Dim newMenuB As AcadPopupMenu<BR> Set newMenuB = currMenuGroup.Menus.Add("图层管理")<BR> <BR> Set MenuOpenB = newMenuB.AddMenuItem(newMenuB.Count + 1, "删除图层上的所有实体", "-vbarun TC1" & vbCr)<BR> Set MenuOpenB = newMenuB.AddMenuItem(newMenuB.Count + 1, "打开所有图层", "-vbarun TC2" & vbCr)<BR> newMenuB.InsertInMenuBar (6) '在菜单条上第6个位置显示菜单
Sub TC2() '打开所有图层<BR> Dim objLayer As AcadLayer<BR> For Each objLayer In acadapp.Layers<BR> objLayer.LayerOn = True<BR> Next<BR> End Sub
4、用比例缩放对象ScaleEntity方法缩放实体,是在X、Y、H三个方向上等比例缩放,我只要在X、Y平面上比例缩放,H高程不变,怎样实现?
页:
[1]