macro doesn't start

Discussion in 'AutoCAD' started by antmjr, Mar 31, 2005.

  1. antmjr

    antmjr Guest

    I'm not understanding anything. Sometimes my macros do not start: I click a command button but it doesn't trigger anything. If I quit and enter AutoCAD again, everything works again. Has something similar ever happened to you?
     
    antmjr, Mar 31, 2005
    #1
  2. antmjr

    bcoward Guest

    Antmjr,

    "Has something similar ever happened to you? "

    Yes, I created the little monster....

    If you post your code others are very interested to assist you. I bet it is one line of code causing your "enhancement".

    Good luck,

    Bob Coward
     
    bcoward, Apr 1, 2005
    #2
  3. antmjr

    antmjr Guest

    I haven't a particular macro not working, suddenly all my macros do not work; it seems to me that there may be something still active when I try to start one of my macros. I was thinking the cause might lie in some events, so I unloaded the only macro using them; in Thisdrawing Module I still have the following:

    Option Explicit

    Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

    Private Const ALERT_1 As Long = 5000
    Private Const ALERT_2 As Long = 100

    Private Const VK_CAPITAL = &H14
    Private Const KEYEVENTF_KEYUP = &H2
    Private Const KEYEVENTF_EXTENDEDKEY = &H1
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long

    Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
    Select Case CommandName
    Case "MOVE"
    Call Beep(ALERT_1, 150)
    Case "DIMCONTINUE", "DIMALIGNED", "DIMLINEAR", "DIMANGULAR", "DIMORDINATE", _
    "DIMBASELINE", "DIMDIAMETER", "DIMRADIUS", "DIMBASELINE", "LEADER", _
    "QLEADER"
    If Not (UCase(ThisDrawing.ActiveLayer.Name) Like "QUOTE*") Then
    Call Beep(ALERT_1, 150)
    End If
    Case "DDEDIT"
    'if you are DDEDITing, it switches to CAPITAL letter and alerts with a beep
    If GetKeyState(VK_CAPITAL) = 0 Then
    On Error GoTo GO_ON 'I don't remember why I have written it this way
    Call keybd_event(vbKeyCapital, _
    MapVirtualKey(vbKeyCapital, 0), _
    KEYEVENTF_EXTENDEDKEY, 0)
    Call keybd_event(vbKeyCapital, MapVirtualKey(vbKeyCapital, 0), _
    KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)
    GO_ON:
    Call Beep(ALERT_2, 150)
    End If
    Case "PLOT"
    ThisDrawing.SetVariable "TEXTFILL", 1
    Case Else
    'per studio:
    ' ThisDrawing.Utility.Prompt "* " & CommandName & " *"
    End Select
    End Sub

    - - -
    another possibility might be that there are some variables conflicting each other: is it possible that they can cause all the macros not to work?
     
    antmjr, Apr 1, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.