6 Replies Latest reply on Jan 6, 2016 8:05 AM by chuckt

    Modeless Command Angle, current status

    cbedard

      I am interested in creating a shortcut key that will toggle the modeless command AA and AD, that is Line/Trace Angle from Any Angle to Diagonal Angle.

      I've figured out how to set up a separate shortcut keys for each, but making one shortcut key that toggles between the two angle modes is different.  It requires knowing the current state of Angle Mode.

      Is that information available?

       

      I know there are several ways to affect the route angle:

       

      Application.ExecuteCommand("Orthogonal Angle Mode")

      Application.ExecuteCommand("Diagonal Angle Mode")

      Application.ExecuteCommand("Any Angle Mode")

       

      OR

       

      Application.ExecuteCommand("Global Options")

      OptionsDlg.ActiveTab = "Routing|General"

      OptionsDlg.ActiveTab = "Design"

      OptionsDlg.DesignDlg.LineTraceAngle = 2

      OptionsDlg.DesignDlg.LineTraceAngle = 0

      OptionsDlg.DesignDlg.LineTraceAngle = 1

      OptionsDlg.Apply.Click()

      OptionsDlg.Ok.Click()

       

      OR

       

      Application.ModelessCommand("a")

      DlgModelessCmd.Command = "aa"

      DlgModelessCmd.Command = "ad"

      DlgModelessCmd.Command = "ao"

      DlgModelessCmd.OnOk()

       

       

      OR by typing the modeless commands

       

      AA

      AD

      AO

       

      I can also access the ROUTERFLAGS variable in the ASCII output file.

       

      Accessing the ascii file is not reasonable because I'm trying to do this in real time.  Using the Options dialog box is an option but it is MUCH slower than using the modeless commands.(even in an automated way)  A macro will complete the modeless command sequence 10x faster than setting the angle mode via the Options dialog box.

       

      This set of code works in a Macro to complete the Angle Diagonal Modeless command:

      Application.ModelessCommand("a")

      DlgModelessCmd.Command = "ad"

      DlgModelessCmd.OnOk()

       

      but when I try to wrap an If Then Else statement around that code it does not function.  I try to have the If statement access the information in the Options dialog box as follows:

      If OptionsDlg.DesignDlg.LineTraceAngle = 2 Then

      Application.ModelessCommand("a")

      DlgModelessCmd.Command = "ad"

      DlgModelessCmd.OnOk()

      Else

      Application.ModelessCommand("a")

      DlgModelessCmd.Command = "aa"

      DlgModelessCmd.OnOk()

      End If

       

      Does the Angle Mode status information exist in a place that I can access and use in the above If statement?

      Or am I just not using the correct syntax to access the information in OptionsDlg.DesignDlg.LineTraceAngle?

        • 1. Re: Modeless Command Angle, current status
          chuckt

          Have you tried it with the Options dialog box open?

           

          I tried this with the box open and it works:

           

          select case OptionsDlg.DesignDlg.LineTraceAngle

            case 0

            OptionsDlg.DesignDlg.LineTraceAngle = 2

            case 2

            OptionsDlg.DesignDlg.LineTraceAngle = 0

          end select

           

          I did not try to "apply" the setting or assign the macro to a hot key... but I do see the radio button change.

          • 2. Re: Modeless Command Angle, current status
            cbedard

            Great catch!  That totally works!  Even with the Options box open and minimized.  And because the dialog box is already open it's very quick.

             

            This is the code I used to make it toggle between Any Angle and Diagonal Angle.

             

            If OptionsDlg.DesignDlg.LineTraceAngle = 2 Then

            Application.ModelessCommand("a")

            DlgModelessCmd.Command = "ad"

            DlgModelessCmd.OnOk()

            Else

            Application.ModelessCommand("a")

            DlgModelessCmd.Command = "aa"

            DlgModelessCmd.OnOk()

            End If

             

            If you wanted to add the Orthogonal Angle setting in you could just add an ElseIf with the three lines of code with a "ao".  I almost never use Orthogonal though so AA and AD is good for me.

             

            Now I have a one button toggle instead of a three button, two hand modeless Command.

             

            Thanks!

            • 3. Re: Modeless Command Angle, current status
              cbedard

              Chuck,

              Here is code actually using the dialog box as you suggested...

               

              If OptionsDlg.DesignDlg.LineTraceAngle = 2 Then

              OptionsDlg.DesignDlg.LineTraceAngle = 0

              OptionsDlg.Apply.Click()

              Else

              OptionsDlg.DesignDlg.LineTraceAngle = 2

              OptionsDlg.Apply.Click()

              End If

               

              ...two less lines of code.

               

              Thanks again!

              • 4. Re: Modeless Command Angle, current status
                chuckt

                There is a macro command to open the options dialog (in case is not already open):

                 

                Application.OpenOptionsDialog()

                 

                but it doesn't work for me... IDK

                • 5. Re: Modeless Command Angle, current status
                  cbedard

                  True. 

                   

                  It seems to work with this:

                   

                  Application.ExecuteCommand("Global Options")

                  OptionsDlg.ActiveTab = "Design"

                   

                  The problem with relying on the macro to open the Option dialog box is that it slows the macro WAY down.  I'm OK with leaving it open but minimized in a corner somewhere.

                  • 6. Re: Modeless Command Angle, current status
                    chuckt

                    I'm going to use the Select Case version along with your Global Options stuff. It only seems slowish the first time, and I won't use it all that often anyway... I'll probably just use OK instead of Apply... mapped to Alt+A.

                     

                    I made a comment way back on the Ideas site for some kind of way to do this, but couldn't think of a good implementation. I think this will be fine.

                     

                    Thank YOU