Author Topic: VB.NET not MENULOAD from Initialize  (Read 2365 times)

0 Members and 1 Guest are viewing this topic.

FELIX

  • Bull Frog
  • Posts: 242
VB.NET not MENULOAD from Initialize
« on: July 08, 2014, 10:46:15 PM »
The MENULOAD at startup does not work and shows ERROR. Already run the TESTE command Works.
Code: [Select]
Imports Autodesk.AutoCAD.Runtime 
Imports Autodesk.AutoCAD.ApplicationServices   
Imports Autodesk.AutoCAD.Interop   
Imports Autodesk.AutoCAD.EditorInput   
Imports System 
 Namespace APPTESTENAME   
    Public Class Initialization   
        Implements IExtensionApplication   
        Public Sub Initialize() Implements IExtensionApplication.Initialize   
            MsgBox("START OK")   
            Try
                   Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument   
                Dim LINHA As String   
                LINHA = "(IF (NOT (MENUGROUP ""TOPOCAD2000"")) (PROGN(COMMAND ""_MENULOAD"" ""TOPOCAD2000"")(MENUCMD ""P15=+TOPOCAD2000.POP1""))(ALERT ""\nMENU ALREADY LOADED"") ) "
                  acDoc.SendStringToExecute(LINHA, True, False, False)
              Catch
                  MsgBox("ERRO")
              End Try
          End Sub
          Public Sub Terminate() Implements IExtensionApplication.Terminate
          End Sub
      End Class
      Public Class COMANDOS
          <CommandMethod("TESTE")> _
          Public Sub Teste()
              Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
              Dim LINHA As String
              LINHA = "(IF (NOT (MENUGROUP ""TOPOCAD2000"")) (PROGN(COMMAND ""_MENULOAD"" ""TOPOCAD2000"")(MENUCMD ""P15=+TOPOCAD2000.POP1""))(ALERT ""\nMENU ALREADY LOADED"") ) "
              acDoc.SendStringToExecute(LINHA, True, False, False)
          End Sub
      End Class
  End Namespace
OK.

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: VB.NET not MENULOAD from Initialize
« Reply #1 on: July 09, 2014, 12:01:47 AM »
Me no VB but in c# we inherit at the start of the class and then override the methods of initialize and terminate

Edit: This is the case I think

http://msdn.microsoft.com/en-us/library/818x9db9(v=vs.90).aspx
« Last Edit: July 09, 2014, 12:08:15 AM by WILL HATCH »

nekitip

  • Guest
Re: VB.NET not MENULOAD from Initialize
« Reply #2 on: July 09, 2014, 03:56:36 AM »
do you have your MdiActiveDocument at the time of init?
(is any document loaded at all?)

FELIX

  • Bull Frog
  • Posts: 242
Re: VB.NET not MENULOAD from Initialize
« Reply #3 on: July 09, 2014, 09:51:23 AM »
The command is executed when AutoCAD is opened.
OK.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: VB.NET not MENULOAD from Initialize
« Reply #4 on: July 09, 2014, 12:46:09 PM »
Hasn't MENULOAD been obsolete for several versions, replaced with CUILOAD?
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

huiz

  • Swamp Rat
  • Posts: 918
  • Certified Prof C3D
Re: VB.NET not MENULOAD from Initialize
« Reply #5 on: July 09, 2014, 01:50:44 PM »
You could try to catch the error and show that. Though I thought errors while initializing are silently handled, so I am surprised you see the error messagebox.

I think the document is not loaded yet, so you can not send commands to the commandline.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.