Menuload in On_Start.lsp

How can I load/unload menus in on_start.lsp?

Comments

  • I have never tried to do this with on_start.lsp, But this should work:

    Load:
    [code](if (menugroup mnuName)
      (command "_.menuunload" mnuName)
    )
    (command "_.menuload" mnuFile)[/code]
    Unload:
    [code](if (menugroup mnuName)
      (command "_.menuunload" mnuName)
    )[/code]
  • Here are the functions I use, which avoid a command call

    Load:
    [code]; CCL-LOADMENU
    ; Load menu will check to see if the given Menu group is loaded.
    ; If it isn't, then it will be loaded

    (defun CCL-LOADMENU ( groupnm menufile / oACAD oMenuGrps)
        (setq oAcad (vlax-get-Acad-Object)) ; retrieve Acad-Object
        (setq oMenuGrps (vla-get-menugroups oAcad)) ; retrieve menugroups
        (if (not (menugroup groupnm)) ; if the menugroup isn't loaded
                (if (setq menufile (findfile menufile)) (vla-load oMenuGrps menufile)) ; THEN load menu if it exists
                (vla-item oMenuGrps groupnm) ; ELSE return menu object
        )
    )[/code]

    Unload:
    [code]; CCL-UNLOADMENU
    ; Unload menu will check to see if the given Menu group is loaded.
    ; If it is, then it will be unloaded

    (defun CCL-UNLOADMENU ( groupnm / oACAD oMenuGrps)
        (if (menugroup groupnm) ; if the menu group is loaded
            (progn ; THEN
                (setq oAcad (vlax-get-Acad-Object)) ; retrieve Acad-Object
                (setq oMenuGrps (vla-get-menugroups oAcad)) ; retrieve menugroups
                (vla-unload (vla-item oMenuGrps groupnm)) ; unload the menu
                T
            )
        )
    )[/code]

    I have a Sample BricsCAD setup on my website where you can see these functions being called in On_Start.lsp


    Regards,
    Jason Bourhill

  • Thanks, that looks great.  My on-start.lsp looks like this ... it is continually getting improved...

    ;;; Set application search paths for Hunsaker & Associates San Diego
    ;;;
    ;;;

    ;; Support Paths
      (setq sRootPath "C:\\CADD_Support\\Shared")

      (setenv "BricsCAD"
        (strcat
          "N:\\BricsCAD Support;"
          "C:\\CADD_Support\\BricsCAD;"
          sRootPath ";"
          sRootPath "\\Blocks;"
          sRootPath "\\Fonts;"
          sRootPath "\\Icons;"
          sRootPath "\\Tools;"
          "C:\\Program Files\\Bricsys\\BricsCAD V15 en_US\\Support;"
          "C:\\Program Files (x86)\\DotSoft\\MapWorks;"
          "C:\\Program Files (x86)\\DotSoft\\ToolPac;"
        )
      )

    ;; Open and Save Settings
      (setvar "ACADLSPASDOC" 0)
      (setvar "PROXYNOTICE" 1)
      (setvar "PROXYSHOW" 1)
      (setvar "SAVEFILEPATH" "C:\\CADD_Support\\Temp")
      (setvar "SAVETIME" 20) ;
      (setvar "ISAVEBAK" 1) ;create a backup copy
      (setvar "ISAVEPERCENT" 25)
      (setvar "SAVEFORMAT" 1)
      (setvar "SAVETIME" 30)
      (setvar "SHOWFULLPATHINTITLE" 1)
      (setvar "VBAMACROS" 0) ;64 bit does not support vba

    ;; Template Settings
      (setvar "BASEFILE" "C:\\CADD_Support\\Shared\\Templates\\HASD-Empty.dwt")
      (setenv "DefaultNewSheetSetTemplate" "C:\\CADD_Support\\Shared\\Templates\\SheetSets\\!HASD Standard Sheet Set.dwt")
      (setenv "QnewTemplate" "C:\\CADD_Support\\Shared\\Templates\\HASD-Empty.dwt")
      (setvar "SheetSetTemplatePath" "C:\\CADD_Support\\Shared\\Templates\\SheetSets\\")
      (setvar "TemplatePath" "C:\\CADD_Support\\Shared\\Templates\\")

    ;; Printer Settings - These are unique to BricsCAD
      (setvar "CPLOTSTYLE" "BYLAYER")
      (setvar "DEFLPLSTYLE" "Solid")
      (setvar "DEFPLSTYLE" "BYLAYER")
      (setvar "PlotCfgPath" "C:\\CADD_Support\\Shared\\Plot Setup\\PMP Files\\")
      (setvar "PlotOutputPath" "C:\\CADD_Support\\Temp\\")
      (setvar "PlotStylePath" "C:\\CADD_Support\\Shared\\Plot Setup\\")
      (setvar "PSTYLEPOLICY" 0) ;plot styles are not associated with color

    ;; XREF Settings
      (setvar "HIDEXREFSCALES" 1)
      (setvar "XLOADPATH" "C:\\CADD_Support\\Temp")

    ;; Misc Settings
      (setvar "BKGCOLOR" 256)
      (setvar "DCTCUST" "C:\\CADD_Support\\Shared\\HASD.dic")
      (setvar "EXPINSALIGN" "1") ;BricsCAD only
      (setvar "EXPINSFIXSCALE" "1") ;BricsCAD only
      (setvar "EXPINSSCALE" "1") ;BricsCAD only
      (setvar "FONTALT" "romans.shx")
      (setvar "LOGFILEPATH" "C:\\CADD_Support\\Temp\\")
      (setvar "PICKADD" 1)
      (setvar "PICKFIRST" 1)
      (setvar "PLINEGEN" 1)
      (setvar "QUADDISPLAY" 0) ;BricsCAD only
      (setvar "SHOWDOCTABS" 1) ;BricsCAD only

    ;; Let me know
      (princ "\nSupport Paths Defined\n")

This discussion has been closed.