明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1989|回复: 9

各位高手请帮忙!!

[复制链接]
发表于 2003-5-21 22:48 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2003-5-21 22:48:13 编辑

请问如何用VBA实现:在执行一个交互命令(如:获取点坐标)时,先中断,然后去执行另一个CAD的内部命令(如:缩放命令),当执行完这个命令后,再返回到中断的交互命令中继续执行。如果方便的话,请传给我一个实例代码。
我的邮件地址:LUCKNHL@163.COM
发表于 2003-5-21 22:19 | 显示全部楼层

必须是透明命令才可以如此

必须是透明命令才可以如此
发表于 2003-5-23 14:34 | 显示全部楼层

能否说详细点?

什么是 透明命令阿 ?
能否举个例子啊?
 楼主| 发表于 2003-5-23 21:01 | 显示全部楼层

透明指令大概是这个意思

命令可分为模式的(modeal)或透明的。一条透明命令可以在提示用户输入时调用。一条模式命令只能在command提示符下调用并且不能有其它命令或程序处于活动状态;
在绘图过程中经常要使用透明命令,Zoom、Pan、Ortho、Snap、cal(计算)、Redraw、Layer……使用时,可以在执行某个命令过程中,单击透明命令按钮(原命令不中止)或从菜单中选择其选项,也可以在命令行输入一个撇( '),再输入透明命令.
发表于 2003-5-24 12:17 | 显示全部楼层

关于这个!

对不起,我想请教你一个问题!
放在模块中的宏,怎样在命令行运行!
发表于 2003-5-28 17:15 | 显示全部楼层

关于透明命令

发表于 2003-5-28 17:17 | 显示全部楼层

关于透明命令

如何才能在使用sendcommand 命令时实现模式命令与透明命令之间的转换呢?
 楼主| 发表于 2003-5-28 21:49 | 显示全部楼层

这样是否可以

要想在CAD命令中执行VBA编辑的宏,好象应该使用VBRUN命令。
发表于 2003-5-29 16:33 | 显示全部楼层

是不是这样可以帮你

是不是这样的,我这个程序在标序号是可以对较形进行缩放,拖动等透明命令
(因为有个窗口没有传上来,所以你不能进行设置)

Sub bxh()

On Error Resume Next

'*********定义变量***********
Dim textCon As String
Dim varPnt As Variant
Dim keywd As String
Dim textobj As Object
Dim Found As Boolean
Dim layerObj As AcadLayer
Dim currLayer, newlayer As AcadLayer
Static textH As Single
Static textXh As Integer
Static textPre As String
Static textSuf As String

'********选择图层***********
Found = False
For Each layerObj In ThisDrawing.Layers
If StrComp(layerObj.Name, "序号", 1) = 0 Then
   Found = True
   End If
   Next
If Not Found Then
  Set newlayer = ThisDrawing.Layers.add("序号")
  newlayer.color = acMagenta
  End If
Set newlayer = ThisDrawing.Layers("序号")

currLayer = ThisDrawing.ActiveLayer
ThisDrawing.ActiveLayer = newlayer


'*******主程序***********
bzxh:

If textH = 0 Then
  pubTexth = 1: textH = 1: PubtextPre = "(": PubtextSuf = ")"
  textSuf = ")": textPre = "("
  textXh = 1
  Else:
   PubtextPre = textPre
   PubtextSuf = textSuf
   pubTexth = textH
  End If

youForm1.TextBox4.text = pubTexth
youForm1.TextBox1.text = PubtextXh
youForm1.TextBox2.text = PubtextPre
youForm1.TextBox3.text = PubtextSuf

Err.Clear
ThisDrawing.Utility.InitializeUserInput 128, "E S"
varPnt = ThisDrawing.Utility.GetPoint(, "输入点(右键或 E 结束)/S(设置):")

'**************出错设置**************
If Err <> 0 Then
   If Err.Number = -2147352567 Then keywd = "": Err.Clear: GoTo bzxh
    Err.Clear
    keywd = ""
    ThisDrawing.Utility.InitializeUserInput 0, "E S"
    keywd = ThisDrawing.Utility.GetInput
      
    If keywd = "s" Or keywd = "S" Then '进入窗口设置
      youForm1.TextBox1.text = textXh
      youForm1.TextBox4.text = textH
      youForm1.TextBox2.text = textPre
      youForm1.TextBox3.text = textSuf
      
     
      youForm1.Show
       textH = pubTexth
       textXh = PubtextXh
       textPre = PubtextPre
       textSuf = PubtextSuf
      GoTo bzxh
      End If
      
   If keywd = "e" Or keywd = "E" Or keywd = "" Then
     GoTo en
        End If
   
   Err.Clear
   GoTo bzxh
   
  End If

'****************进行标注*************
youForm1.TextBox1.text = textXh
textCon = textPre + youForm1.TextBox1.text + textSuf
Set textobj = ThisDrawing.ModelSpace.AddText(textCon, varPnt, textH)
  textobj.Alignment = acAlignmentMiddleCenter
  textobj.TextAlignmentPoint = varPnt
  textXh = textXh + 1
GoTo bzxh
'*************end************
en:
End Sub
发表于 2003-6-1 11:54 | 显示全部楼层

哦 明了 谢谢

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-6-17 06:59 , Processed in 0.152866 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表