How to keep the "ORTHO" mode always active

How to keep the "ORTHO" mode always active

mecoman6GF27
Advocate Advocate
562 Views
3 Replies
Message 1 of 4

How to keep the "ORTHO" mode always active

mecoman6GF27
Advocate
Advocate

Hello everybody.
To activate the "ORTHO" mode I do this:

Application.DocumentManager.MdiActiveDocument.Database.Orthomode = True

But how can I prevent the "ORTHO" mode from being deactivated during the execution of a command I made in VB.NET?
Thanks a lot, bye.

0 Likes
563 Views
3 Replies
Replies (3)
Message 2 of 4

arcticad
Advisor
Advisor
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.SystemVariableChanged += systemVariableChangedEventHandler;

private void systemVariableChangedEventHandler(object sender, Autodesk.AutoCAD.DatabaseServices.SystemVariableChangedEventArgs e)
        {
            if (Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Count > 0 &&
                Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument != null)
            {
                if (e.Name == "ORTHOMODE")
                {
                    if (Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.Orthomode == false)
                        Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.Orthomode = true;
                }
            }
        }
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 3 of 4

mecoman6GF27
Advocate
Advocate

Hi arcticad, thanks for the reply.
I am trying your code but I would like to test it in VB and I am having problems with this line of code: "Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.SystemVariableChanged + = systemVariableChangedEventHandler;".
How should I change it in VB?
Thanks a lot, bye.

0 Likes
Message 4 of 4

arcticad
Advisor
Advisor
Implements Autodesk.AutoCAD.Runtime.IExtensionApplication

Public Sub Initialize() Implements IExtensionApplication.Initialize

    Dim dm As DocumentCollection = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
    AddHandler dm.MdiActiveDocument.Database.SystemVariableChanged, AddressOf DocumentManager_SystemVariableChanged
End Sub

Private Sub DocumentManager_SystemVariableChanged(sender As Object, e As Autodesk.AutoCAD.DatabaseServices.SystemVariableChangedEventArgs)
    If (Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Count > 0 And
    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument IsNot Nothing) Then
        If (e.Name = "ORTHOMODE") Then
            If (Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.Orthomode = False) Then
                Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.Orthomode = True
            End If
        End If
    End If
End Sub
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes