484 发表于 2007-10-4 11:33:41

Autocad.activate或Autocad.setfocus

**** Hidden Message *****

灌水 发表于 2007-10-16 12:42:03


不确定您到底想做什么??

黑翼 发表于 2007-10-19 09:52:41

当Im调试时,使用F8来单步调试代码,当它到达一个选择点或选择对象时,我想将焦点发送到acad,而不需要我单击它(这有时会导致错误选择,这会在Im调试的代码中触发错误检查)

樱吧招人堂 发表于 2007-10-19 10:20:08

我看不到任何可行的方法。如果您正在逐句通过代码,您是在一次执行一行代码。如果您将焦点转移到所选内容的前一行,您就不能点击F8来进入所选内容。如果它是下一行,您只能在选择后才能跳到它。这将是令人敬畏的,但在我看来,这就像是一个谜中之谜。也许是一个外部应用程序,当它等待选择时,会将焦点切换到autocad,但我不知道。

口袋中心 发表于 2007-10-23 16:27:54


是的
我不知道;我确信我理解确切的需求,但是一行代码肯定会在不点击任何东西的情况下关注ACAD。
也许你可以写一个子或函数,上面写着
如果发生这种情况,那么
Application.VBE.MainWindow.Visible = False'Give focus to ACAD

结束如果
不确定
标记

中国灌水协会 发表于 2007-10-23 19:37:54

我认为鲍勃说得最好,VBA怎么知道我是否在打F8。我认为这是不可能的。好吧

雅莉 发表于 2007-10-24 09:34:01


坚持住,男人
让我们尝试一个愚蠢的小东西

雅莉 发表于 2007-10-24 09:34:29

我认为这
不会起作用:
语法有意义,但我不知道如何触发它
Mark
If SendKeys = "{F8}"
Then Application.VBE.MainWindow.Visible = False
End If

小罗 发表于 2007-10-24 12:47:21

曼梯·里,我不确定你是否正确地得到了他想要的东西。他正在谈论使用F8在VBAIDE中一次一行地单步调试他的代码。当acad中需要输入时,例如选择,他希望焦点切换到acad窗口。如果你使用应用程序。在单步执行代码时,它只是在转到下一行代码的瞬间关闭IDE。我尝试了旧的awesomey acad示例事件代码dvb,看看选择是否触发了任何事件,但似乎没有。我用了下面的代码。当宽度改变时,object modified事件被触发,但这是唯一一个为我触发的事件。

'      AutoCAD 2000
'
'      Events Example Code ActiveX Automation.
'
'      Copyright (C) 1999 by Autodesk, Inc.
'
'      Permission to use, copy, modify, and distribute this software
'      for any purpose and without fee is hereby granted, provided
'      that the above copyright notice appears in all copies and
'      that both that copyright notice and the limited warranty and
'      restricted rights notice below appear in all supporting
'      documentation.
'
'      AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
'      AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
'      MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.AUTODESK, INC.
'      DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
'      UNINTERRUPTED OR ERROR FREE.
'
'      Use, duplication, or disclosure by the U.S. Government is subject to
'      restrictions set forth in FAR 52.227-19 (Commercial Computer
'      Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
'      (Rights in Technical Data and Computer Software), as applicable.
'
Option Explicit
Public WithEvents PLine As AcadLWPolyline       ' Use with Modified Event Example
Public WithEvents ACADApp As AcadApplication    ' Use with Application Event Examples
'------------------------------------------------------------------
' Document Events
'------------------------------------------------------------------
Private Sub AcadDocument_Activate()
    ' This example intercepts a drawing Activate event.
    '
    ' This event is triggered when a drawing window becomes active.
    '
    ' To trigger this example event: Either open a new drawing or switch from
    ' one drawing window to another
    MsgBox "You have just activated a drawing!"
End Sub
Private Sub AcadDocument_BeginClose()
    ' This example intercepts a drawing BeginClose event.
    '
    ' This event is triggered when a drawing receives a request to close.
    '
    ' To trigger this example event: Close an open drawing
    MsgBox "A drawing has just been closed!"
End Sub
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
    ' This example intercepts a drawing BeginCommand event.
    '
    ' This event is triggered when a drawing receives
    ' any command compatible with this event.
    '
    ' To trigger this example event: Issue any command to an open drawing from
    ' either the command line, VBA, the ACAD menus, the ACAD toolbars, or LISP.
    ' Use the "CommandName" variable to determine which command was started
    MsgBox "A drawing has just been issued a " & CommandName & " command."
End Sub

'----------------------------------------------------------------------------
' Modified (PLINE) Event Sample
'----------------------------------------------------------------------------
Sub Example_Modified()
   ' This example creates a light weight polyline in model space and
   ' references the new PolyLine using the public variable (PLine) which
   ' is setup to intercept Modified events.
   '
   ' This example then modifies the new object, triggering the code
   ' in the Modified event.
   
    Dim points(0 To 9) As Double
   
    ' Define the 2D polyline points
    points(0) = 1: points(1) = 1
    points(2) = 1: points(3) = 2
    points(4) = 2: points(5) = 2
    points(6) = 3: points(7) = 2
    points(8) = 4: points(9) = 4
      
    ' Create a light weight Polyline object in model space
    '
    ' * Note: We are returning the new PolyLine object into a Module
    ' level variable.This allows us to intercept events associated
    ' with that particular object.
    Set PLine = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
   
    ThisDrawing.Application.ZoomAll
   
    ' Modify object to trigger event.
    '
    ' * Note: The event code for the PolyLine modification will be triggered
    ' before we move forward and refresh the view, so the line will not
    ' appear red when the event message box is displayed
    PLine.color = acRed
    ThisDrawing.Regen acAllViewports
   
End Sub
Private Sub PLine_Modified(ByVal pObject As AutoCAD.IAcadObject)
    ' This example intercepts an object's Modified event.
    '
    ' This event is triggered when an object supporting this event is modified
    '
    ' To trigger this code: Modifiy an object connected to this event
    ' * Note: By connected, we mean the object setup to intercept events using
    ' the VBA WithEvents statement
    ' Use the "pObject" variable to determine which object was modified
    MsgBox "You just modified an object with an ID of: " & pObject.ObjectID
   
End Sub
Sub test()
Dim objPL As AcadLWPolyline
Dim varPnt As Variant
ThisDrawing.Utility.GetEntity objPL, varPnt
objPL.ConstantWidth = 1
End Sub

亦菲互动 发表于 2007-10-24 14:04:02


嗨,鲍勃
,我确实明白他想要什么,但我不知道如何到达那里;我只是抓着吸管
CM,说,ACAD怎么知道我什么时候打F8?好吧,我只是说怎么做。
If SendKeys = "{F8}"
'whatever code you want
End If

我也说过我不知道他需要什么。
哦,好吧,我们不能拥有所有东西,对吧
马克
页: [1]
查看完整版本: Autocad.activate或Autocad.setfocus